Bug 1401366. P2 - bail out Observe() if not subcribed per comment 2. r=kaku
authorJW Wang <jwwang@mozilla.com>
Wed, 20 Sep 2017 17:51:10 +0800
changeset 381917 f9e527aa4ba5d497880de2a677c51b8ee6e27e63
parent 381916 0848279b2b72c10e8ae6b3cfcdff2e97355dc593
child 381918 ff6c67a5c98680051727e4e9aac42fd28ca59119
push id32542
push userkwierso@gmail.com
push dateWed, 20 Sep 2017 21:07:55 +0000
treeherdermozilla-central@319a34bea9e4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskaku
bugs1401366
milestone57.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 1401366. P2 - bail out Observe() if not subcribed per comment 2. r=kaku MozReview-Commit-ID: 4LEBD3g0OwX
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -3768,17 +3768,21 @@ class HTMLMediaElement::ShutdownObserver
     Unsubscribed
   };
 
 public:
   NS_DECL_ISUPPORTS
 
   NS_IMETHOD Observe(nsISupports*, const char* aTopic, const char16_t*) override
   {
-    MOZ_DIAGNOSTIC_ASSERT(mPhase == Phase::Subscribed);
+    if (mPhase != Phase::Subscribed) {
+      // Bail out if we are not subscribed for this might be called even after
+      // |nsContentUtils::UnregisterShutdownObserver(this)|.
+      return NS_OK;
+    }
     MOZ_DIAGNOSTIC_ASSERT(mWeak);
     if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
       mWeak->NotifyShutdownEvent();
     }
     return NS_OK;
   }
   void Subscribe(HTMLMediaElement* aPtr)
   {