Bug 1595603 - part2 : delay seeking task when media is inactive r=bryce

When media element is inactive, asking MDSM to seek is actually useless, because all the data we decode won't be showed to user. In addition, we have to store extra pending events for `seeking` and `seeked`, which might result in memory overflow if the inactive page is calling `seek()` all the time.

Therfore, we should delay all seeking tasks while media is inactive, and perform the latest seeking task when media becomes active.

Differential Revision: https://phabricator.services.mozilla.com/D58918
This commit is contained in:
alwu
2020-01-09 17:10:08 +00:00
parent 0e0b0572c4
commit d3d8a3d56e
4 changed files with 36 additions and 2 deletions

View File

@@ -6526,6 +6526,7 @@ void HTMLMediaElement::SuspendOrResumeElement(bool aSuspendElement) {
if (mDecoder) {
mDecoder->Pause();
mDecoder->Suspend();
mDecoder->SetDelaySeekMode(true);
}
mEventDeliveryPaused = true;
// We won't want to resume media element from the bfcache.
@@ -6540,6 +6541,7 @@ void HTMLMediaElement::SuspendOrResumeElement(bool aSuspendElement) {
if (!mPaused && !mDecoder->IsEnded()) {
mDecoder->Play();
}
mDecoder->SetDelaySeekMode(false);
}
if (mEventDeliveryPaused) {
mEventDeliveryPaused = false;