commit ffcf40b7a0e9 Author: Alastor Wu Date: Tue Sep 26 17:48:19 2017 +0800 Bug 1402681 - Part 1: Do not queue the task without task queue. r=jya, a=sledru 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 --HG-- extra : source : 145eac8ba70636cdb1a235d6d7094b87bbfd8022 --- dom/media/mediasource/TrackBuffersManager.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git dom/media/mediasource/TrackBuffersManager.cpp dom/media/mediasource/TrackBuffersManager.cpp index 50293810064b..cda89faaff51 100644 --- dom/media/mediasource/TrackBuffersManager.cpp +++ dom/media/mediasource/TrackBuffersManager.cpp @@ -145,6 +145,15 @@ TrackBuffersManager::DoAppendData(already_AddRefed aData, 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() == SourceBufferTask::Type::Detach, + "only detach task could happen here!"); + return; + } + if (!OnTaskQueue()) { GetTaskQueue()->Dispatch(NewRunnableMethod>( "TrackBuffersManager::QueueTask", commit 99e2204da6a1 Author: Alastor Wu Date: Tue Sep 26 17:48:39 2017 +0800 Bug 1402681 - Part 2: Add log. r=jya, a=sledru MozReview-Commit-ID: 8qINxSCKrvg --HG-- extra : source : 0cac2e15b4ca7cf03e75ee208da624495215382f --- dom/media/mediasource/SourceBufferTask.h | 7 +++++++ dom/media/mediasource/TrackBuffersManager.cpp | 4 ++++ 2 files changed, 11 insertions(+) diff --git dom/media/mediasource/SourceBufferTask.h dom/media/mediasource/SourceBufferTask.h index 183e7b4b2a0b..b73094fbd282 100644 --- dom/media/mediasource/SourceBufferTask.h +++ dom/media/mediasource/SourceBufferTask.h @@ -32,6 +32,7 @@ public: typedef MozPromise RangeRemovalPromise; virtual Type GetType() const = 0; + virtual const char* GetTypeName() const = 0; template ReturnType* As() @@ -54,6 +55,7 @@ public: static const Type sType = Type::AppendBuffer; Type GetType() const override { return Type::AppendBuffer; } + const char* GetTypeName() const override { return "AppendBuffer"; } RefPtr mBuffer; SourceBufferAttributes mAttributes; @@ -64,12 +66,14 @@ class AbortTask : public SourceBufferTask { public: static const Type sType = Type::Abort; Type GetType() const override { return Type::Abort; } + const char* GetTypeName() const override { return "Abort"; } }; class ResetTask : public SourceBufferTask { public: static const Type sType = Type::Reset; Type GetType() const override { return Type::Reset; } + const char* GetTypeName() const override { return "Reset"; } }; class RangeRemovalTask : public SourceBufferTask { @@ -80,6 +84,7 @@ public: static const Type sType = Type::RangeRemoval; Type GetType() const override { return Type::RangeRemoval; } + const char* GetTypeName() const override { return "RangeRemoval"; } media::TimeInterval mRange; MozPromiseHolder mPromise; @@ -94,6 +99,7 @@ public: static const Type sType = Type::EvictData; Type GetType() const override { return Type::EvictData; } + const char* GetTypeName() const override { return "EvictData"; } media::TimeUnit mPlaybackTime; int64_t mSizeToEvict; @@ -103,6 +109,7 @@ class DetachTask : public SourceBufferTask { public: static const Type sType = Type::Detach; Type GetType() const override { return Type::Detach; } + const char* GetTypeName() const override { return "Detach"; } }; } // end mozilla namespace diff --git dom/media/mediasource/TrackBuffersManager.cpp dom/media/mediasource/TrackBuffersManager.cpp index cda89faaff51..b9b768b726a2 100644 --- dom/media/mediasource/TrackBuffersManager.cpp +++ dom/media/mediasource/TrackBuffersManager.cpp @@ -151,6 +151,8 @@ TrackBuffersManager::QueueTask(SourceBufferTask* aTask) if (!GetTaskQueue()) { MOZ_ASSERT(aTask->GetType() == SourceBufferTask::Type::Detach, "only detach task could happen here!"); + MSE_DEBUG("Could not queue the task '%s' without task queue", + aTask->GetTypeName()); return; } @@ -183,6 +185,8 @@ TrackBuffersManager::ProcessTasks() // nothing to do. return; } + + MSE_DEBUG("Process task '%s'", task->GetTypeName()); switch (task->GetType()) { case Type::AppendBuffer: mCurrentTask = task;