Bug 1310594 - MDSM::DumpDebugInfo() should dispatch the printing task immediately.
MozReview-Commit-ID: 2FQlWJ0YnHJ
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -3145,17 +3145,22 @@ MediaDecoderStateMachine::DumpDebugInfo(
"mAudioStatus=%s mVideoStatus=%s mDecodedAudioEndTime=%lld mDecodedVideoEndTime=%lld "
"mAudioCompleted=%d mVideoCompleted=%d",
GetMediaTime(), mMediaSink->IsStarted() ? GetClock() : -1, mMediaSink.get(),
ToStateStr(), mPlayState.Ref(), mSentFirstFrameLoadedEvent, IsPlaying(),
AudioRequestStatus(), VideoRequestStatus(), mDecodedAudioEndTime, mDecodedVideoEndTime,
mAudioCompleted.Ref(), mVideoCompleted.Ref());
});
- OwnerThread()->DispatchStateChange(r.forget());
+ // Since the task is run asynchronously, it is possible other tasks get first
+ // and change the object states before we print them. Therefore we want to
+ // dispatch this task immediately without waiting for the tail dispatching
+ // phase so object states are less likely to change before being printed.
+ OwnerThread()->Dispatch(r.forget(),
+ AbstractThread::AssertDispatchSuccess, AbstractThread::TailDispatch);
}
void MediaDecoderStateMachine::AddOutputStream(ProcessedMediaStream* aStream,
bool aFinishWhenEnded)
{
MOZ_ASSERT(NS_IsMainThread());
DECODER_LOG("AddOutputStream aStream=%p!", aStream);
mOutputStreamManager->Add(aStream, aFinishWhenEnded);