Bug 1247189 - part3 : don't process any task after detached. draft
authorAlastor Wu <alwu@mozilla.com>
Thu, 12 Oct 2017 10:49:10 +0800
changeset 678942 27a49e98782c152f169d948c247c9e9e504f7f81
parent 678303 c39e6eba4a9fea6f5b316c0b98457cc220fd723d
child 678943 57e7a9b93609665e7fba4f0815842028c56dff41
push id84076
push useralwu@mozilla.com
push dateThu, 12 Oct 2017 02:49:38 +0000
bugs1247189
milestone58.0a1
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
dom/media/mediasource/TrackBuffersManager.cpp
--- 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;
   }