Bug 1383653 P1 - add debug messages for understanding the status of suspending video decoder; r?jwwang
MozReview-Commit-ID: 2pI6XRQQgbG
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -1267,56 +1267,64 @@ MediaDecoder::SetSuspendTaint(bool aTain
UpdateVideoDecodeMode();
}
void
MediaDecoder::UpdateVideoDecodeMode()
{
// The MDSM may yet be set.
if (!mDecoderStateMachine) {
+ LOG("UpdateVideoDecodeMode(), early return because we don't have MDSM.");
return;
}
// If an element is in-tree with UNTRACKED visibility, the visibility is
// incomplete and don't update the video decode mode.
if (mIsElementInTree && mElementVisibility == Visibility::UNTRACKED) {
+ LOG("UpdateVideoDecodeMode(), early return because we have incomplete visibility states.");
return;
}
// If mHasSuspendTaint is set, never suspend the video decoder.
if (mHasSuspendTaint) {
+ LOG("UpdateVideoDecodeMode(), set Normal because the element has been tainted.");
mDecoderStateMachine->SetVideoDecodeMode(VideoDecodeMode::Normal);
return;
}
// Don't suspend elements that is not in tree.
if (!mIsElementInTree) {
+ LOG("UpdateVideoDecodeMode(), set Normal because the element is not in tree.");
mDecoderStateMachine->SetVideoDecodeMode(VideoDecodeMode::Normal);
return;
}
// If mForcedHidden is set, suspend the video decoder anyway.
if (mForcedHidden) {
+ LOG("UpdateVideoDecodeMode(), set Suspend because the element is forced to be suspended.");
mDecoderStateMachine->SetVideoDecodeMode(VideoDecodeMode::Suspend);
return;
}
// Resume decoding in the advance, even the element is in the background.
if (mIsBackgroundVideoDecodingAllowed) {
+ LOG("UpdateVideoDecodeMode(), set Normal because the tab is in background and hovered.");
mDecoderStateMachine->SetVideoDecodeMode(VideoDecodeMode::Normal);
return;
}
// Otherwise, depends on the owner's visibility state.
// A element is visible only if its document is visible and the element
// itself is visible.
if (mIsDocumentVisible &&
mElementVisibility == Visibility::APPROXIMATELY_VISIBLE) {
+ LOG("UpdateVideoDecodeMode(), set Normal because the element visible.");
mDecoderStateMachine->SetVideoDecodeMode(VideoDecodeMode::Normal);
} else {
+ LOG("UpdateVideoDecodeMode(), set Suspend because the element is not visible.");
mDecoderStateMachine->SetVideoDecodeMode(VideoDecodeMode::Suspend);
}
}
bool
MediaDecoder::HasSuspendTaint() const
{
MOZ_ASSERT(NS_IsMainThread());
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -3161,31 +3161,34 @@ void MediaDecoderStateMachine::SetVideoD
&MediaDecoderStateMachine::SetVideoDecodeModeInternal,
aMode);
OwnerThread()->DispatchStateChange(r.forget());
}
void MediaDecoderStateMachine::SetVideoDecodeModeInternal(VideoDecodeMode aMode)
{
MOZ_ASSERT(OnTaskQueue());
- LOG("VideoDecodeModeChanged: VideoDecodeMode=(%s->%s), mVideoDecodeSuspended=%c",
- mVideoDecodeMode == VideoDecodeMode::Normal ? "Normal" : "Suspend",
- aMode == VideoDecodeMode::Normal ? "Normal" : "Suspend",
- mVideoDecodeSuspended ? 'T' : 'F');
// Should not suspend decoding if we don't turn on the pref.
if (!MediaPrefs::MDSMSuspendBackgroundVideoEnabled() &&
aMode == VideoDecodeMode::Suspend) {
+ LOG("SetVideoDecodeModeInternal(), early return because preference off and set to Suspend");
return;
}
if (aMode == mVideoDecodeMode) {
+ LOG("SetVideoDecodeModeInternal(), early return because the mode does not change");
return;
}
+ LOG("SetVideoDecodeModeInternal(), VideoDecodeMode=(%s->%s), mVideoDecodeSuspended=%c",
+ mVideoDecodeMode == VideoDecodeMode::Normal ? "Normal" : "Suspend",
+ aMode == VideoDecodeMode::Normal ? "Normal" : "Suspend",
+ mVideoDecodeSuspended ? 'T' : 'F');
+
// Set new video decode mode.
mVideoDecodeMode = aMode;
// Start timer to trigger suspended video decoding.
if (mVideoDecodeMode == VideoDecodeMode::Suspend) {
TimeStamp target = TimeStamp::Now() + SuspendBackgroundVideoDelay();
RefPtr<MediaDecoderStateMachine> self = this;