Bug 1402681 - part1 : do not queue the task without task queue. draft
authorAlastor Wu <alwu@mozilla.com>
Tue, 26 Sep 2017 17:29:34 +0800
changeset 670335 512a5af55a7f1bf05b0c61f1ee3965cb92ace6a8
parent 669596 7e962631ba4298bcefa571008661983d77c3e652
child 670336 ea3f1c00eca70c09cece01e76c429d3f96dc640a
child 670342 03fa77094ebca4a024fa3a36b6ae1ece1cb39334
push id81602
push useralwu@mozilla.com
push dateTue, 26 Sep 2017 09:32:21 +0000
bugs1402681
milestone58.0a1
Bug 1402681 - part1 : do not queue the task without task queue. Since the source buffer is a wrapped native, it would be unlinked twice and then the TrackBuffersManager::Detach() would also be called twice. The first detach task would clear the task queue of TrackBuffersManager, and then we won't accept any new task without task queue. The second detach task should not be executed. MozReview-Commit-ID: AWTzVbRH5B1
dom/media/mediasource/TrackBuffersManager.cpp
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -140,16 +140,25 @@ TrackBuffersManager::DoAppendData(alread
   QueueTask(task);
 
   return p;
 }
 
 void
 TrackBuffersManager::QueueTask(SourceBufferTask* aTask)
 {
+  // The source buffer is a wrapped native, it would be unlinked twice and so
+  // the TrackBuffersManager::Detach() would also be called twice. Since the
+  // detach task has been done before, we could ignore this task.
+  if (!GetTaskQueue()) {
+    MOZ_ASSERT(aTask->GetType() == Type::Detach,
+               "only Detach task could happen here!");
+    return;
+  }
+
   if (!OnTaskQueue()) {
     GetTaskQueue()->Dispatch(NewRunnableMethod<RefPtr<SourceBufferTask>>(
       "TrackBuffersManager::QueueTask",
       this,
       &TrackBuffersManager::QueueTask,
       aTask));
     return;
   }