diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index 5c4632c8a..ef8e362dc 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -3110,11 +3110,13 @@ public: { NS_ASSERTION(NS_IsMainThread(), "Should be on main thread."); + if (MOZ_UNLIKELY(!mElement)) return; // bug 1419363 + mElement->NotifyMediaStreamTracksAvailable(aStream); } private: - HTMLMediaElement* mElement; + WeakPtr mElement; }; class HTMLMediaElement::MediaStreamTrackListener : diff --git a/dom/html/HTMLMediaElement.h b/dom/html/HTMLMediaElement.h index ed95ad6b4..c18628f79 100644 --- a/dom/html/HTMLMediaElement.h +++ b/dom/html/HTMLMediaElement.h @@ -18,6 +18,7 @@ #include "mozilla/Attributes.h" #include "mozilla/dom/Promise.h" #include "mozilla/dom/TextTrackManager.h" +#include "mozilla/WeakPtr.h" #include "MediaDecoder.h" #ifdef MOZ_EME #include "mozilla/dom/MediaKeys.h" @@ -76,7 +77,8 @@ class HTMLMediaElement : public nsGenericHTMLElement, public nsIDOMHTMLMediaElement, public nsIObserver, public MediaDecoderOwner, - public nsIAudioChannelAgentCallback + public nsIAudioChannelAgentCallback, + public SupportsWeakPtr { friend AutoNotifyAudioChannelAgent; @@ -89,6 +91,8 @@ public: typedef mozilla::MediaDecoderOwner MediaDecoderOwner; typedef mozilla::MetadataTags MetadataTags; + MOZ_DECLARE_WEAKREFERENCE_TYPENAME(HTMLMediaElement) + CORSMode GetCORSMode() { return mCORSMode; }