Bug 1452416 - Release GraphDrivers outside of StableState runnable to avoid spinning the event queue. r=smaug, r=padenot, a=RyanVM
authorRandell Jesup <rjesup@jesup.org>
Fri, 13 Jan 2017 13:54:20 -0500
changeset 357019 f89ab96a2532c986e6a81193b8891fdf92da805a
parent 357018 ad9a885b0df41c8896c8685ab76b1e9c0730d515
child 357020 c61127b443f2f893ecd293eba221a324a08c49bb
push id7628
push userryanvm@gmail.com
push dateTue, 10 Apr 2018 13:40:59 +0000
treeherdermozilla-esr52@f89ab96a2532 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, padenot, RyanVM
bugs1452416
milestone52.7.4
Bug 1452416 - Release GraphDrivers outside of StableState runnable to avoid spinning the event queue. r=smaug, r=padenot, a=RyanVM
dom/media/MediaStreamGraph.cpp
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -1710,16 +1710,20 @@ MediaStreamGraphImpl::RunInStableState(b
         // take locks, and we don't want to deadlock.
         LIFECYCLE_LOG("Starting a graph (%p) ! %s\n",
                       this,
                       CurrentDriver()->AsAudioCallbackDriver() ? "AudioDriver" :
                                                                  "SystemDriver");
         RefPtr<GraphDriver> driver = CurrentDriver();
         MonitorAutoUnlock unlock(mMonitor);
         driver->Start();
+        // It's not safe to Shutdown() a thread from StableState, and
+        // releasing this may shutdown a SystemClockDriver thread.
+        // Proxy the release to outside of StableState.
+        NS_ReleaseOnMainThread(driver.forget(), true); // always proxy
       }
     }
 
     if ((mForceShutDown || !mRealtime) &&
         mLifecycleState == LIFECYCLE_WAITING_FOR_MAIN_THREAD_CLEANUP) {
       // Defer calls to RunDuringShutdown() to happen while mMonitor is not held.
       for (uint32_t i = 0; i < mBackMessageQueue.Length(); ++i) {
         MessageBlock& mb = mBackMessageQueue[i];