From f729d738ab71c794ee6b9145d31efd14fecdb7c0 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Fri, 2 Oct 2015 15:42:15 -0700 Subject: [PATCH] Bug 1208656 - Grab the tail dispatch each time in case the runnable spins the event loop. r=khuey If the runnable spins the event loop, we may end up firing the tail dispatcher, which causes the AutoTaskDispatcher to be destroyed, after which point invoking methods on it will crash. We need to grab it each time so that it will be lazily instantiated as-needed. --- dom/media/MediaStreamGraph.cpp | 3 +- dom/media/tests/mochitest/mochitest.ini | 2 ++ .../test_getUserMedia_spinEventLoop.html | 29 +++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 dom/media/tests/mochitest/test_getUserMedia_spinEventLoop.html diff --git a/dom/media/MediaStreamGraph.cpp b/dom/media/MediaStreamGraph.cpp index d862685f8414..34e1a6ff3e3f 100644 --- a/dom/media/MediaStreamGraph.cpp +++ b/dom/media/MediaStreamGraph.cpp @@ -1497,7 +1497,6 @@ MediaStreamGraphImpl::RunInStableState(bool aSourceIsMSG) mLifecycleState >= LIFECYCLE_WAITING_FOR_THREAD_SHUTDOWN; #endif - TaskDispatcher& tailDispatcher = AbstractThread::MainThread()->TailDispatcher(); for (uint32_t i = 0; i < runnables.Length(); ++i) { runnables[i]->Run(); // "Direct" tail dispatcher are supposed to run immediately following the @@ -1509,7 +1508,7 @@ MediaStreamGraphImpl::RunInStableState(bool aSourceIsMSG) // and we need to make sure that the watcher responding to "stream available" // has a chance to run before the second notification starts tearing things // down. - tailDispatcher.DrainDirectTasks(); + AbstractThread::MainThread()->TailDispatcher().DrainDirectTasks(); } } diff --git a/dom/media/tests/mochitest/mochitest.ini b/dom/media/tests/mochitest/mochitest.ini index 37862eac4188..ef80a8ecfe62 100644 --- a/dom/media/tests/mochitest/mochitest.ini +++ b/dom/media/tests/mochitest/mochitest.ini @@ -54,6 +54,8 @@ skip-if = toolkit == 'gonk' || buildapp == 'mulet' || buildapp == 'mulet' # Bug [test_getUserMedia_playAudioTwice.html] [test_getUserMedia_playVideoAudioTwice.html] [test_getUserMedia_playVideoTwice.html] +[test_getUserMedia_spinEventLoop.html] +skip-if = (toolkit == 'gonk' || buildapp == 'mulet' && debug) # copied from basicAudio [test_getUserMedia_stopAudioStream.html] [test_getUserMedia_stopAudioStreamWithFollowupAudio.html] [test_getUserMedia_stopVideoAudioStream.html] diff --git a/dom/media/tests/mochitest/test_getUserMedia_spinEventLoop.html b/dom/media/tests/mochitest/test_getUserMedia_spinEventLoop.html new file mode 100644 index 000000000000..1990dbde39f6 --- /dev/null +++ b/dom/media/tests/mochitest/test_getUserMedia_spinEventLoop.html @@ -0,0 +1,29 @@ + + + + + + +
+
+
+ +