Bug 836599 - Part 5: Make MediaStreamGraphImpl::RunInStableState not assume that it's the only graph; r=roc
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 04 Feb 2013 12:27:54 -0500
changeset 130823 12715a3b5a0872e2fb1c033c5b102847092f62e2
parent 130822 66c03536917a2730356e88d3fac64c2dddc1e096
child 130824 189766068d9994b4ecf980997339e800d7307f6b
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs836599
milestone21.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 836599 - Part 5: Make MediaStreamGraphImpl::RunInStableState not assume that it's the only graph; r=roc
content/media/MediaStreamGraph.cpp
--- a/content/media/MediaStreamGraph.cpp
+++ b/content/media/MediaStreamGraph.cpp
@@ -1213,21 +1213,23 @@ MediaStreamGraphImpl::RunInStableState()
       // the graph might exit immediately on finding it has no streams. The
       // first message for a new graph must create a stream.
       nsCOMPtr<nsIRunnable> event = new MediaStreamGraphThreadRunnable(this);
       NS_NewThread(getter_AddRefs(mThread), event);
     }
 
     if (mCurrentTaskMessageQueue.IsEmpty()) {
       if (mLifecycleState == LIFECYCLE_WAITING_FOR_MAIN_THREAD_CLEANUP && IsEmpty()) {
-        NS_ASSERTION(gGraph == this, "Not current graph??");
         // Complete shutdown. First, ensure that this graph is no longer used.
         // A new graph graph will be created if one is needed.
-        LOG(PR_LOG_DEBUG, ("Disconnecting MediaStreamGraph %p", gGraph));
-        gGraph = nullptr;
+        LOG(PR_LOG_DEBUG, ("Disconnecting MediaStreamGraph %p", this));
+        if (this == gGraph) {
+          // null out gGraph if that's the graph being shut down
+          gGraph = nullptr;
+        }
         // Asynchronously clean up old graph. We don't want to do this
         // synchronously because it spins the event loop waiting for threads
         // to shut down, and we don't want to do that in a stable state handler.
         mLifecycleState = LIFECYCLE_WAITING_FOR_THREAD_SHUTDOWN;
         nsCOMPtr<nsIRunnable> event = new MediaStreamGraphShutDownRunnable(this);
         NS_DispatchToMainThread(event);
       }
     } else {