Bug 1346116 part 1 - initialize MediaDecoder::mIsDocumentVisible and MediaDecoder::mIsElementVisible at HTMLMediaElement::FinishDecoderSetup(); r?jwwang draft
authorKaku Kuo <kaku@mozilla.com>
Sun, 12 Mar 2017 13:56:43 +0800
changeset 497409 0b7abd405150916ed4ae8b95630b73f43a568112
parent 497408 ab664369c19c3e3969006ab3a1742d30aa62ee74
child 497410 21bcc4e67c33907e82e5ca86328eaad39b4bea42
push id48889
push userbmo:kaku@mozilla.com
push dateMon, 13 Mar 2017 08:47:52 +0000
reviewersjwwang
bugs1346116
milestone55.0a1
Bug 1346116 part 1 - initialize MediaDecoder::mIsDocumentVisible and MediaDecoder::mIsElementVisible at HTMLMediaElement::FinishDecoderSetup(); r?jwwang Initialize the MediaDecoder::mIsElementVisible to be "!aOwner->IsHidden()" at the MediaDecoder's constructor is wrong. Insted, we initialize both MediaDecoder::mIsDocumentVisible and MediaDecoder::mIsElementVisible to be false at the construtor, and then assign the HTMLMediaElement's real values to them at HTMLMediaElement::FinishDecoderSetup() via the the MediaDecoder::SetActiviyChangesToDecoder(). The initialization values of MediaDecoder::mIsDocumentVisible and MediaDecoder::mIsElementVisible (in the constructor) do not matter because the valuse are not read untile the first MediaDecoder::SetActiviyChangesToDecoder() method call. MozReview-Commit-ID: Cdovq5pG9Nv
dom/html/HTMLMediaElement.cpp
dom/media/MediaDecoder.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -4708,16 +4708,18 @@ nsresult HTMLMediaElement::FinishDecoder
   mDecoder->SetVolume(mMuted ? 0.0 : mVolume);
   mDecoder->SetPreservesPitch(mPreservesPitch);
   mDecoder->SetPlaybackRate(mPlaybackRate);
   if (mPreloadAction == HTMLMediaElement::PRELOAD_METADATA) {
     mDecoder->SetMinimizePrerollUntilPlaybackStarts();
   }
   // Notify the decoder of suspend taint.
   mDecoder->SetSuspendTaint(mHasSuspendTaint);
+  // Notify the decoder of the initial activity status.
+  NotifyDecoderActivityChanges();
 
   // Update decoder principal before we start decoding, since it
   // can affect how we feed data to MediaStreams
   NotifyDecoderPrincipalChanged();
 
   nsresult rv = aDecoder->Load(aListener);
   if (NS_FAILED(rv)) {
     ShutdownDecoder();
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -390,18 +390,18 @@ MediaDecoder::MediaDecoder(MediaDecoderO
   , mAbstractMainThread(aOwner->AbstractMainThread())
   , mFrameStats(new FrameStatistics())
   , mVideoFrameContainer(aOwner->GetVideoFrameContainer())
   , mPlaybackStatistics(new MediaChannelStatistics())
   , mPinnedForSeek(false)
   , mMinimizePreroll(false)
   , mMediaTracksConstructed(false)
   , mFiredMetadataLoaded(false)
-  , mIsDocumentVisible(!aOwner->IsHidden())
-  , mIsElementVisible(!aOwner->IsHidden())
+  , mIsDocumentVisible(false)
+  , mIsElementVisible(false)
   , mForcedHidden(false)
   , mHasSuspendTaint(false)
   , INIT_MIRROR(mStateMachineIsShutdown, true)
   , INIT_MIRROR(mBuffered, TimeIntervals())
   , INIT_MIRROR(mNextFrameStatus, MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE)
   , INIT_MIRROR(mCurrentPosition, 0)
   , INIT_MIRROR(mStateMachineDuration, NullableTimeUnit())
   , INIT_MIRROR(mPlaybackPosition, 0)