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.
This commit is contained in:
Bobby Holley 2015-10-02 15:42:15 -07:00
Родитель 5558525f6c
Коммит f729d738ab
3 изменённых файлов: 32 добавлений и 2 удалений

Просмотреть файл

@ -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();
}
}

Просмотреть файл

@ -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]

Просмотреть файл

@ -0,0 +1,29 @@
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({ title: "getUserMedia Basic Audio Test", bug: "1208656" });
/**
* Run a test to verify that we can spin the event loop from within a mozGUM callback.
*/
runTest(() => {
var testAudio = createMediaElement('audio', 'testAudio');
return new Promise((resolve, reject) => {
navigator.mozGetUserMedia({ audio: true }, () => {
var syncXHR = new XMLHttpRequest();
syncXHR.open('GET', location, false);
syncXHR.send();
ok(true, "Didn't crash");
resolve();
}, () => {});
});
});
</script>
</pre>
</body>
</html>