Bug 1522773 - Reject any outstanding DOMMediaStream::TrackPort::BlockSourceTrackId() promise on teardown to avoid recent debug assert permafail. r=bwc
authorJan-Ivar Bruaroey <jib@mozilla.com>
Tue, 05 Feb 2019 20:59:52 +0000
changeset 518186 8853735bc243fc79b68eaadbbebd29a8f14f5ed4
parent 518185 60b3669e48a31c9a73c8b51302103cceb2f44817
child 518187 dfefd2d4d63f8f2cdeb57e6ee16a8c31c4f54447
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc
bugs1522773
milestone67.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 1522773 - Reject any outstanding DOMMediaStream::TrackPort::BlockSourceTrackId() promise on teardown to avoid recent debug assert permafail. r=bwc Differential Revision: https://phabricator.services.mozilla.com/D18590
dom/media/MediaStreamGraph.cpp
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -3057,22 +3057,37 @@ RefPtr<GenericPromise> MediaInputPort::B
     BlockingMode mBlockingMode;
     nsCOMPtr<nsIRunnable> mRunnable;
   };
 
   MOZ_ASSERT(IsTrackIDExplicit(aTrackId), "Only explicit TrackID is allowed");
 
   MozPromiseHolder<GenericPromise> holder;
   RefPtr<GenericPromise> p = holder.Ensure(__func__);
-  nsCOMPtr<nsIRunnable> runnable =
-      NewRunnableFrom([h = std::move(holder)]() mutable {
-        MOZ_ASSERT(NS_IsMainThread());
-        h.Resolve(true, __func__);
-        return NS_OK;
-      });
+
+  class HolderRunnable : public Runnable {
+   public:
+    explicit HolderRunnable(MozPromiseHolder<GenericPromise>&& aHolder)
+        : Runnable("MediaInputPort::HolderRunnable"),
+          mHolder(std::move(aHolder)) {}
+
+    NS_IMETHOD Run() override {
+      MOZ_ASSERT(NS_IsMainThread());
+      mHolder.Resolve(true, __func__);
+      return NS_OK;
+    }
+
+   private:
+    ~HolderRunnable() {
+      mHolder.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__);
+    }
+    MozPromiseHolder<GenericPromise> mHolder;
+  };
+
+  auto runnable = MakeRefPtr<HolderRunnable>(std::move(holder));
   GraphImpl()->AppendMessage(
       MakeUnique<Message>(this, aTrackId, aBlockingMode, runnable.forget()));
   return p;
 }
 
 already_AddRefed<MediaInputPort> ProcessedMediaStream::AllocateInputPort(
     MediaStream* aStream, TrackID aTrackID, TrackID aDestTrackID,
     uint16_t aInputNumber, uint16_t aOutputNumber,