Bug 1247189 - part3 : don't process any task after detached.
From [1], the task was executed after finished detach task. It would be caused
by queuing two detach tasks in the task queue.
If the previous detach task is still waiting in the task queue when we're calling
the second detach(), then we might have two detach tasks in the queue.
[1] https://treeherder.mozilla.org/logviewer.html#?job_id=134315866&repo=try&lineNumber=2540
MozReview-Commit-ID: HohgKqeZy0s
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -167,16 +167,29 @@ TrackBuffersManager::QueueTask(SourceBuf
MOZ_ASSERT(OnTaskQueue());
mQueue.Push(aTask);
ProcessTasks();
}
void
TrackBuffersManager::ProcessTasks()
{
+ // A second Detach task was queued, prior the first one running, ignore it.
+ if (!GetTaskQueue()) {
+ RefPtr<SourceBufferTask> task = mQueue.Pop();
+ if (!task) {
+ return;
+ }
+ MOZ_RELEASE_ASSERT(task->GetType() == SourceBufferTask::Type::Detach,
+ "only detach task could happen here!");
+ MSE_DEBUG("Could not process the task '%s' after detached",
+ task->GetTypeName());
+ return;
+ }
+
MOZ_ASSERT(OnTaskQueue());
typedef SourceBufferTask::Type Type;
if (mCurrentTask) {
// Already have a task pending. ProcessTask will be scheduled once the
// current task complete.
return;
}