From 4471953140f8ee5dd7cfdcf32ba8f28df5bed0ea Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Tue, 14 Jul 2015 12:17:07 +1200 Subject: [PATCH] Bug 1182928 - Disable dormant mode for EME videos in Firefox Beta and Release. r=sotaro --- dom/media/MediaDecoder.cpp | 24 ++++++++++++++++++++---- dom/media/MediaDecoder.h | 3 +++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/dom/media/MediaDecoder.cpp b/dom/media/MediaDecoder.cpp index f59c0a5e9a0d..a6edac3c3f68 100644 --- a/dom/media/MediaDecoder.cpp +++ b/dom/media/MediaDecoder.cpp @@ -159,6 +159,19 @@ void MediaDecoder::NotifyOwnerActivityChanged() StartDormantTimer(); } +bool +MediaDecoder::IsHeuristicDormantSupported() const +{ + return +#if defined(MOZ_EME) && defined(RELEASE_BUILD) + // We disallow dormant for encrypted media on Beta and Release until + // bug 1181864 is fixed. + mInfo && + !mInfo->IsEncrypted() && +#endif + mIsHeuristicDormantSupported; +} + void MediaDecoder::UpdateDormantState(bool aDormantTimeout, bool aActivity) { MOZ_ASSERT(NS_IsMainThread()); @@ -174,9 +187,11 @@ void MediaDecoder::UpdateDormantState(bool aDormantTimeout, bool aActivity) } DECODER_LOG("UpdateDormantState aTimeout=%d aActivity=%d mIsDormant=%d " - "ownerActive=%d ownerHidden=%d mIsHeuristicDormant=%d mPlayState=%s", + "ownerActive=%d ownerHidden=%d mIsHeuristicDormant=%d " + "mPlayState=%s encrypted=%s", aDormantTimeout, aActivity, mIsDormant, mOwner->IsActive(), - mOwner->IsHidden(), mIsHeuristicDormant, PlayStateStr()); + mOwner->IsHidden(), mIsHeuristicDormant, PlayStateStr(), + (!mInfo ? "Unknown" : (mInfo->IsEncrypted() ? "1" : "0"))); bool prevDormant = mIsDormant; mIsDormant = false; @@ -188,10 +203,11 @@ void MediaDecoder::UpdateDormantState(bool aDormantTimeout, bool aActivity) mIsDormant = true; } #endif + // Try to enable dormant by idle heuristic, when the owner is hidden. bool prevHeuristicDormant = mIsHeuristicDormant; mIsHeuristicDormant = false; - if (mIsHeuristicDormantSupported && mOwner->IsHidden()) { + if (IsHeuristicDormantSupported() && mOwner->IsHidden()) { if (aDormantTimeout && !aActivity && (mPlayState == PLAY_STATE_PAUSED || IsEnded())) { // Enable heuristic dormant @@ -252,7 +268,7 @@ void MediaDecoder::DormantTimerExpired(nsITimer* aTimer, void* aClosure) void MediaDecoder::StartDormantTimer() { MOZ_ASSERT(NS_IsMainThread()); - if (!mIsHeuristicDormantSupported) { + if (!IsHeuristicDormantSupported()) { return; } diff --git a/dom/media/MediaDecoder.h b/dom/media/MediaDecoder.h index d8d9579c369f..3e80f3228894 100644 --- a/dom/media/MediaDecoder.h +++ b/dom/media/MediaDecoder.h @@ -1057,6 +1057,9 @@ protected: virtual void CallSeek(const SeekTarget& aTarget); + // Returns true if heuristic dormant is supported. + bool IsHeuristicDormantSupported() const; + MediaPromiseRequestHolder mSeekRequest; // True when seeking or otherwise moving the play position around in