Bug 1290364 - clear mOwner in Shutdown(). r=cpearce
authorJW Wang <jwwang@mozilla.com>
Fri, 29 Jul 2016 14:44:22 +0800
changeset 308525 06eca66de01d82da85866faca70fad0e7a489fc7
parent 308524 9dc08c2240db8b52fbb39e29285a28c509afc1be
child 308526 ae2cbe1419d188ae85ba1d7619f2cf9a1d0f8e4e
push id31130
push userjwwang@mozilla.com
push dateMon, 08 Aug 2016 02:38:55 +0000
treeherderautoland@06eca66de01d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1290364
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1290364 - clear mOwner in Shutdown(). r=cpearce MozReview-Commit-ID: 2CsYKcSrEOJ
dom/media/MediaDecoder.cpp
dom/media/MediaDecoder.h
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -157,17 +157,17 @@ MediaDecoder::ResourceCallback::Disconne
   mTimer->Cancel();
   mTimer = nullptr;
 }
 
 MediaDecoderOwner*
 MediaDecoder::ResourceCallback::GetMediaOwner() const
 {
   MOZ_ASSERT(NS_IsMainThread());
-  return mDecoder ? mDecoder->GetOwner() : nullptr;
+  return mDecoder ? mDecoder->mOwner : nullptr;
 }
 
 void
 MediaDecoder::ResourceCallback::SetInfinite(bool aInfinite)
 {
   MOZ_ASSERT(NS_IsMainThread());
   if (mDecoder) {
     mDecoder->SetInfinite(aInfinite);
@@ -566,17 +566,17 @@ MediaDecoder::MediaDecoder(MediaDecoderO
   , mPlaybackRateReliable(AbstractThread::MainThread(), true,
                           "MediaDecoder::mPlaybackRateReliable (Canonical)")
   , mDecoderPosition(AbstractThread::MainThread(), 0,
                      "MediaDecoder::mDecoderPosition (Canonical)")
   , mMediaSeekable(AbstractThread::MainThread(), true,
                    "MediaDecoder::mMediaSeekable (Canonical)")
   , mMediaSeekableOnlyInBufferedRanges(AbstractThread::MainThread(), false,
                    "MediaDecoder::mMediaSeekableOnlyInBufferedRanges (Canonical)")
-  , mIsVisible(AbstractThread::MainThread(), !mOwner->IsHidden(),
+  , mIsVisible(AbstractThread::MainThread(), !aOwner->IsHidden(),
                "MediaDecoder::mIsVisible (Canonical)")
   , mTelemetryReported(false)
 {
   MOZ_COUNT_CTOR(MediaDecoder);
   MOZ_ASSERT(NS_IsMainThread());
   MediaMemoryTracker::AddMediaDecoder(this);
 
   mAudioChannel = AudioChannelService::GetDefaultAudioChannel();
@@ -662,16 +662,17 @@ MediaDecoder::Shutdown()
   // to prevent shutdown from deadlocking.
   if (mResource) {
     mResource->Close();
   }
 
   CancelDormantTimer();
 
   ChangeState(PLAY_STATE_SHUTDOWN);
+  mOwner = nullptr;
 }
 
 MediaDecoder::~MediaDecoder()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MediaMemoryTracker::RemoveMediaDecoder(this);
   UnpinForSeek();
   MOZ_COUNT_DTOR(MediaDecoder);
@@ -1852,17 +1853,17 @@ MediaMemoryTracker::CollectReports(nsIHa
   return NS_OK;
 }
 
 MediaDecoderOwner*
 MediaDecoder::GetOwner() const
 {
   MOZ_ASSERT(NS_IsMainThread());
   // mOwner is valid until shutdown.
-  return !IsShutdown() ? mOwner : nullptr;
+  return mOwner;
 }
 
 void
 MediaDecoder::ConstructMediaTracks()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(!IsShutdown());
 
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -668,19 +668,19 @@ protected:
   // Ensures our media stream has been unpinned.
   void UnpinForSeek();
 
   const char* PlayStateStr();
 
   void OnMetadataUpdate(TimedMetadata&& aMetadata);
 
   // This should only ever be accessed from the main thread.
-  // It is set in Init and cleared in Shutdown when the element goes away.
-  // The decoder does not add a reference the element.
-  MediaDecoderOwner* const mOwner;
+  // It is set in the constructor and cleared in Shutdown when the element goes
+  // away. The decoder does not add a reference the element.
+  MediaDecoderOwner* mOwner;
 
   // Counters related to decode and presentation of frames.
   const RefPtr<FrameStatistics> mFrameStats;
 
   RefPtr<VideoFrameContainer> mVideoFrameContainer;
 
   // Data needed to estimate playback data rate. The timeline used for
   // this estimate is "decode time" (where the "current time" is the