Bug 1317501 - Don't notify dom objects synchronously from MSG runnables in DOMMediaStream. r=padenot
authorAndreas Pehrson <pehrsons@gmail.com>
Wed, 07 Dec 2016 08:56:14 +0100
changeset 325375 3bb432e68db4e89ce6b5e11f022cfe3ca04fd751
parent 325374 eef062272d1951b7c2e650b69cace6ba6f1023d0
child 325376 1e325da15c787fffcddeeba92ea24b99e0d8d097
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerspadenot
bugs1317501
milestone53.0a1
Bug 1317501 - Don't notify dom objects synchronously from MSG runnables in DOMMediaStream. r=padenot
dom/media/DOMMediaStream.cpp
--- a/dom/media/DOMMediaStream.cpp
+++ b/dom/media/DOMMediaStream.cpp
@@ -195,17 +195,18 @@ public:
     }
 
     RefPtr<MediaStreamTrack> track =
       mStream->FindOwnedDOMTrack(aInputStream, aInputTrackID, aTrackID);
     NS_ASSERTION(track, "Owned MediaStreamTracks must be known by the DOMMediaStream");
     if (track) {
       LOG(LogLevel::Debug, ("DOMMediaStream %p MediaStreamTrack %p ended at the source. Marking it ended.",
                             mStream, track.get()));
-      track->OverrideEnded();
+      NS_DispatchToMainThread(NewRunnableMethod(
+        track, &MediaStreamTrack::OverrideEnded));
     }
   }
 
   void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID,
                                 StreamTime aTrackOffset, TrackEventCommand aTrackEvents,
                                 const MediaSegment& aQueuedMedia,
                                 MediaStream* aInputStream,
                                 TrackID aInputTrackID) override
@@ -265,17 +266,18 @@ public:
   void DoNotifyFinished()
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     if (!mStream) {
       return;
     }
 
-    mStream->NotifyFinished();
+    NS_DispatchToMainThread(NewRunnableMethod(
+      mStream, &DOMMediaStream::NotifyFinished));
   }
 
   // The methods below are called on the MediaStreamGraph thread.
 
   void NotifyFinishedTrackCreation(MediaStreamGraph* aGraph) override
   {
     nsCOMPtr<nsIRunnable> runnable =
       NewRunnableMethod(this, &PlaybackStreamListener::DoNotifyFinishedTrackCreation);