Bug 1511235 - part1 : suspend video decoding for video whose visibility state is UNTRACK. r=jya

If video has not been within the potential visible range (which is larger than viewport) yet, its visibility state won't
be updated and would stay in 'UNTRACK'. As those kinds of video are still invisible to users, we don't need to decode
any video frames, we can suspend their video decoding until they're going to be visible.

Differential Revision: https://phabricator.services.mozilla.com/D13804

--HG--
extra : moz-landing-system : lando
This commit is contained in:
alwu 2018-12-20 20:02:24 +00:00
Родитель 7fb92b8c44
Коммит 41df7a6715
1 изменённых файлов: 10 добавлений и 8 удалений

Просмотреть файл

@ -966,14 +966,6 @@ void MediaDecoder::UpdateVideoDecodeMode() {
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;
}
// Seeking is required when leaving suspend mode.
if (!mMediaSeekable) {
LOG("UpdateVideoDecodeMode(), set Normal because the media is not "
@ -1014,6 +1006,16 @@ void MediaDecoder::UpdateVideoDecodeMode() {
return;
}
// If the element is in-tree with UNTRACKED visibility, that means the element
// is not close enough to the viewport so we have not start to update its
// visibility. In this case, it's equals to invisible.
if (mIsElementInTree && mElementVisibility == Visibility::UNTRACKED) {
LOG("UpdateVideoDecodeMode(), set Suspend because element hasn't be "
"updated visibility state.");
mDecoderStateMachine->SetVideoDecodeMode(VideoDecodeMode::Suspend);
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.