diff --git a/dom/media/MediaDecoder.cpp b/dom/media/MediaDecoder.cpp index bb21795ced71..2a96be23d12b 100644 --- a/dom/media/MediaDecoder.cpp +++ b/dom/media/MediaDecoder.cpp @@ -416,6 +416,8 @@ MediaDecoder::MediaDecoder(MediaDecoderOwner* aOwner) , INIT_CANONICAL(mDecoderPosition, 0) , INIT_CANONICAL(mIsVisible, !aOwner->IsHidden()) , mTelemetryReported(false) + , mIsMediaElement(!!aOwner->GetMediaElement()) + , mElement(aOwner->GetMediaElement()) { MOZ_ASSERT(NS_IsMainThread()); MediaMemoryTracker::AddMediaDecoder(this); @@ -1650,6 +1652,8 @@ MediaDecoderOwner* MediaDecoder::GetOwner() const { MOZ_ASSERT(NS_IsMainThread()); + // Check object lifetime when mOwner points to a media element. + MOZ_DIAGNOSTIC_ASSERT(!mOwner || !mIsMediaElement || mElement); // mOwner is valid until shutdown. return mOwner; } diff --git a/dom/media/MediaDecoder.h b/dom/media/MediaDecoder.h index 487b96687d7d..16d3e1138120 100644 --- a/dom/media/MediaDecoder.h +++ b/dom/media/MediaDecoder.h @@ -42,6 +42,7 @@ namespace mozilla { namespace dom { class Promise; +class HTMLMediaElement; } class VideoFrameContainer; @@ -845,6 +846,10 @@ private: void NotifyDownloadEnded(nsresult aStatus); bool mTelemetryReported; + + // Used to debug how mOwner becomes a dangling pointer in bug 1326294. + bool mIsMediaElement; + WeakPtr mElement; }; } // namespace mozilla