Bug 1302612 - SourceMediaStream: Don't lock mMutex when disconnecting consumers. r=jesup a=gchang
authorAndreas Pehrson <pehrsons@gmail.com>
Mon, 24 Oct 2016 07:46:21 +0200
changeset 358612 27607838026a6e1a3185c1e18b5cdaa7405da592
parent 358611 46f75e5764770c6b6f24881aea714b2613fb509b
child 358613 b44e1445660d445ff883584de9de069a765760e8
push id1324
push usermtabara@mozilla.com
push dateMon, 16 Jan 2017 13:07:44 +0000
treeherdermozilla-release@a01c49833940 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, gchang
bugs1302612
milestone51.0a2
Bug 1302612 - SourceMediaStream: Don't lock mMutex when disconnecting consumers. r=jesup a=gchang MozReview-Commit-ID: 7F4BXQbzUSx
dom/media/MediaStreamGraph.cpp
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -2633,16 +2633,23 @@ SourceMediaStream::CloseAudioInput()
   mInputListener = nullptr;
 }
 
 void
 SourceMediaStream::DestroyImpl()
 {
   CloseAudioInput();
 
+  GraphImpl()->AssertOnGraphThreadOrNotRunning();
+  for (int32_t i = mConsumers.Length() - 1; i >= 0; --i) {
+    // Disconnect before we come under mMutex's lock since it can call back
+    // through RemoveDirectTrackListenerImpl() and deadlock.
+    mConsumers[i]->Disconnect();
+  }
+
   // Hold mMutex while mGraph is reset so that other threads holding mMutex
   // can null-check know that the graph will not destroyed.
   MutexAutoLock lock(mMutex);
   MediaStream::DestroyImpl();
 }
 
 void
 SourceMediaStream::SetPullEnabled(bool aEnabled)