Bug 1157803 - Don't auto-disconnect mirrors when the holder is destroyed off-owner-thread. r=jww
authorBobby Holley <bobbyholley@gmail.com>
Fri, 24 Apr 2015 22:57:43 -0700
changeset 241506 4a072723d1d9bc0862ff7e832be5a0d86a6cbbda
parent 241505 219435f463d2ea6d74b3ae57f04de23010c301f9
child 241507 cd9eec88aa05c33f7f4d18fdc4206a5cff188d14
push id59139
push userbobbyholley@gmail.com
push dateWed, 29 Apr 2015 04:56:35 +0000
treeherdermozilla-inbound@5b8e33d6ad71 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjww
bugs1157803
milestone40.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 1157803 - Don't auto-disconnect mirrors when the holder is destroyed off-owner-thread. r=jww Another consequence of the MDSM's thread model.
dom/media/StateMirroring.h
--- a/dom/media/StateMirroring.h
+++ b/dom/media/StateMirroring.h
@@ -340,17 +340,24 @@ public:
 
   class Holder
   {
   public:
     Holder() {}
     ~Holder()
     {
       MOZ_DIAGNOSTIC_ASSERT(mMirror, "Should have initialized me");
-      mMirror->DisconnectIfConnected();
+      if (mMirror->OwnerThread()->IsCurrentThreadIn()) {
+        mMirror->DisconnectIfConnected();
+      } else {
+        // If holder destruction happens on a thread other than the mirror's
+        // owner thread, manual disconnection is mandatory. We should make this
+        // more automatic by hooking it up to task queue shutdown.
+        MOZ_DIAGNOSTIC_ASSERT(!mMirror->IsConnected());
+      }
     }
 
     // NB: Because mirror-initiated disconnection can race with canonical-
     // initiated disconnection, a mirror should never be reinitialized.
     void Init(AbstractThread* aThread, const T& aInitialValue, const char* aName,
               AbstractCanonical<T>* aCanonical = nullptr)
     {
       mMirror = new Mirror<T>(aThread, aInitialValue, aName, aCanonical);