Bug 1298027 - Shut down CDMs when a containing document becomes inactive. r=cpearce

The previous changeset against this bug relaxed the conditions under which the
CDM and associated objects were shut down. This was to address moving a tab to a
new window breaking EME videos. However, this had the unwanted side effect of
not shutting down those objects early enough when pages are closed.

This changeset introduces a new check to see if the containing document is
currently active, if not we shutdown the CDM. This means CDMs are shutdown on
time, while retaining the desired behaviour that CDMs should not be shut down on
moving tabs to new windows. Shutdowns previously happened because we shut down
if a page hide happened, which took place during a reparent.

MozReview-Commit-ID: K5CD3ej43Y0

--HG--
extra : rebase_source : 28fdc277a89c371ad204d5e545779a5950063494
This commit is contained in:
Bryce Van Dyk 2016-11-14 15:02:48 +13:00
parent 5dbd650b59
commit 51b7a05529

View File

@ -5303,7 +5303,7 @@ void HTMLMediaElement::SuspendOrResumeElement(bool aPauseElement, bool aSuspendE
mMediaKeys->GetKeySystem(keySystem);
// If we're using Primetime we need to shutdown the key system and
// decoder to preserve secure stop like behavior, other CDMs don't
// implement this so we don't need to worry with them.
// implement this so we don't need to worry with them on a suspend.
if (IsPrimetimeKeySystem(keySystem)) {
mMediaKeys->Shutdown();
mMediaKeys = nullptr;
@ -5361,6 +5361,15 @@ void HTMLMediaElement::NotifyOwnerDocumentActivityChanged()
bool pauseElement = ShouldElementBePaused();
SuspendOrResumeElement(pauseElement, !IsActive());
// If the owning document has become inactive we should shutdown the CDM.
if (!OwnerDoc()->IsCurrentActiveDocument() && mMediaKeys) {
mMediaKeys->Shutdown();
mMediaKeys = nullptr;
if (mDecoder) {
ShutdownDecoder();
}
}
AddRemoveSelfReference();
}