From b8ed2ee25c60ff42b59c9cd6bc046d6ab14f55a2 Mon Sep 17 00:00:00 2001 From: Andreas Pehrson Date: Wed, 31 Aug 2016 14:07:53 +0200 Subject: [PATCH] Bug 1299172 - Assert on MSG thread in DispatchToMainThreadAfterStreamStateUpdate. r=jesup MozReview-Commit-ID: 9ihJduZOSa --HG-- extra : rebase_source : 1088fc98f97456c933f146565ba91ce0358e6a4c --- dom/media/MediaStreamGraph.cpp | 19 +++++++++++++++++++ dom/media/MediaStreamGraph.h | 3 +++ dom/media/MediaStreamGraphImpl.h | 20 ++------------------ 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/dom/media/MediaStreamGraph.cpp b/dom/media/MediaStreamGraph.cpp index 5254a9730344..acc4273b96e2 100644 --- a/dom/media/MediaStreamGraph.cpp +++ b/dom/media/MediaStreamGraph.cpp @@ -1077,6 +1077,25 @@ MediaStreamGraph::NotifyOutputData(AudioDataValue* aBuffer, size_t aFrames, } } +void +MediaStreamGraph::AssertOnGraphThreadOrNotRunning() const +{ + // either we're on the right thread (and calling CurrentDriver() is safe), + // or we're going to assert anyways, so don't cross-check CurrentDriver +#ifdef DEBUG + MediaStreamGraphImpl const * graph = + static_cast(this); + // if all the safety checks fail, assert we own the monitor + if (!graph->mDriver->OnThread()) { + if (!(graph->mDetectedNotRunning && + graph->mLifecycleState > MediaStreamGraphImpl::LIFECYCLE_RUNNING && + NS_IsMainThread())) { + graph->mMonitor.AssertCurrentThreadOwns(); + } + } +#endif +} + bool MediaStreamGraphImpl::ShouldUpdateMainThread() { diff --git a/dom/media/MediaStreamGraph.h b/dom/media/MediaStreamGraph.h index a9f852be213f..e606091b3850 100644 --- a/dom/media/MediaStreamGraph.h +++ b/dom/media/MediaStreamGraph.h @@ -1353,6 +1353,7 @@ public: */ virtual void DispatchToMainThreadAfterStreamStateUpdate(already_AddRefed aRunnable) { + AssertOnGraphThreadOrNotRunning(); *mPendingUpdateRunnables.AppendElement() = aRunnable; } @@ -1374,6 +1375,8 @@ public: void NotifyOutputData(AudioDataValue* aBuffer, size_t aFrames, TrackRate aRate, uint32_t aChannels); + void AssertOnGraphThreadOrNotRunning() const; + protected: explicit MediaStreamGraph(TrackRate aSampleRate) : mSampleRate(aSampleRate) diff --git a/dom/media/MediaStreamGraphImpl.h b/dom/media/MediaStreamGraphImpl.h index 7349a5876c97..72ba363ab101 100644 --- a/dom/media/MediaStreamGraphImpl.h +++ b/dom/media/MediaStreamGraphImpl.h @@ -202,24 +202,8 @@ public: nsISupports* aData, const nsTArray& aAudioStreamSizes); - // The following methods run on the graph thread (or possibly the main thread if - // mLifecycleState > LIFECYCLE_RUNNING) - void AssertOnGraphThreadOrNotRunning() const - { - // either we're on the right thread (and calling CurrentDriver() is safe), - // or we're going to assert anyways, so don't cross-check CurrentDriver -#ifdef DEBUG - // if all the safety checks fail, assert we own the monitor - if (!mDriver->OnThread()) { - if (!(mDetectedNotRunning && - mLifecycleState > LIFECYCLE_RUNNING && - NS_IsMainThread())) { - mMonitor.AssertCurrentThreadOwns(); - } - } -#endif - } - + // The following methods run on the graph thread (or possibly the main thread + // if mLifecycleState > LIFECYCLE_RUNNING) void CollectSizesForMemoryReport( already_AddRefed aHandleReport, already_AddRefed aHandlerData);