Bug 1311904 - move |mOwner->FirstFrameLoaded()| to the bottom of FirstFrameLoaded() to prevent shutdown from happening in the middle of FirstFrameLoaded().
MozReview-Commit-ID: FnRsGMhxeZV
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -992,34 +992,37 @@ MediaDecoder::FirstFrameLoaded(nsAutoPtr
DECODER_LOG("FirstFrameLoaded, channels=%u rate=%u hasAudio=%d hasVideo=%d mPlayState=%s mIsDormant=%d",
aInfo->mAudio.mChannels, aInfo->mAudio.mRate,
aInfo->HasAudio(), aInfo->HasVideo(), PlayStateStr(), mIsDormant);
mInfo = aInfo.forget();
Invalidate();
- if (aEventVisibility != MediaDecoderEventVisibility::Suppressed) {
- mOwner->FirstFrameLoaded();
- }
// This can run cache callbacks.
mResource->EnsureCacheUpToDate();
// The element can run javascript via events
// before reaching here, so only change the
// state if we're still set to the original
// loading state.
if (mPlayState == PLAY_STATE_LOADING && !mIsDormant) {
ChangeState(mNextState);
}
// Run NotifySuspendedStatusChanged now to give us a chance to notice
// that autoplay should run.
NotifySuspendedStatusChanged();
+
+ // mOwner->FirstFrameLoaded() might call us back. Put it at the bottom of
+ // this function to avoid unexpected shutdown from reentrant calls.
+ if (aEventVisibility != MediaDecoderEventVisibility::Suppressed) {
+ mOwner->FirstFrameLoaded();
+ }
}
void
MediaDecoder::NetworkError()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!IsShutdown());
mOwner->NetworkError();