Bug 1586387 - Don't append a device change message to a graph that is going away. r=padenot
authorAndreas Pehrson <apehrson@mozilla.com>
Tue, 08 Oct 2019 21:39:30 +0000
changeset 496941 ead1bd9a7f61aeca97db2285b1c640c04d5bee55
parent 496940 961e7c50c3e012756e0d94e0302661be17ac3bfa
child 496942 85e51a860dae62fb65d52c37576ad20b878f9762
push id97544
push userpehrsons@gmail.com
push dateWed, 09 Oct 2019 09:19:38 +0000
treeherderautoland@ead1bd9a7f61 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1586387
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1586387 - Don't append a device change message to a graph that is going away. r=padenot Differential Revision: https://phabricator.services.mozilla.com/D48553
dom/media/MediaTrackGraph.cpp
--- a/dom/media/MediaTrackGraph.cpp
+++ b/dom/media/MediaTrackGraph.cpp
@@ -861,16 +861,25 @@ void MediaTrackGraphImpl::DeviceChanged(
         : ControlMessage(nullptr),
           mGraphImpl(static_cast<MediaTrackGraphImpl*>(aGraph)) {}
     void Run() override { mGraphImpl->DeviceChangedImpl(); }
     // We know that this is valid, because the graph can't shutdown if it has
     // messages.
     MediaTrackGraphImpl* mGraphImpl;
   };
 
+  if (mMainThreadTrackCount == 0 && mMainThreadPortCount == 0) {
+    // This is a special case where the origin of this event cannot control the
+    // lifetime of the graph, because the graph is controling the lifetime of
+    // the AudioCallbackDriver where the event originated.
+    // We know the graph is soon going away, so there's no need to notify about
+    // this device change.
+    return;
+  }
+
   // Reset the latency, it will get fetched again next time it's queried.
   MOZ_ASSERT(NS_IsMainThread());
   mAudioOutputLatency = 0.0;
 
   AppendMessage(MakeUnique<Message>(this));
 }
 
 void MediaTrackGraphImpl::ReevaluateInputDevice() {