Bug 1232520 - dont' invoke AbstractThread::MainThread()->Dispatch() to avoid reentrant of AutoTaskDispatcher during tail dispatching phase. draft
authorJW Wang <jwwang@mozilla.com>
Fri, 18 Dec 2015 11:29:10 +0800
changeset 316235 8e685a2bbcdc5f04b679845fa4091f7298c20289
parent 316234 66fb852962c0d5f6f5fe0604204da4f5d17763c9
child 512135 1e27ac718c1661f5f888b4b02e263586622cf9b8
push id8518
push userjwwang@mozilla.com
push dateFri, 18 Dec 2015 03:29:19 +0000
bugs1232520
milestone46.0a1
Bug 1232520 - dont' invoke AbstractThread::MainThread()->Dispatch() to avoid reentrant of AutoTaskDispatcher during tail dispatching phase.
dom/media/mediasink/DecodedStream.cpp
--- a/dom/media/mediasink/DecodedStream.cpp
+++ b/dom/media/mediasink/DecodedStream.cpp
@@ -475,17 +475,20 @@ DecodedStream::CreateData(MozPromiseHold
       // properly on the main thread.
       if (mData) {
         DecodedStreamData* data = mData.release();
         RefPtr<DecodedStream> self = mThis.forget();
         nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([=] () {
           self->mOutputStreamManager.Disconnect();
           delete data;
         });
-        AbstractThread::MainThread()->Dispatch(r.forget());
+        // We are in tail dispatching phase. Don't call
+        // AbstractThread::MainThread()->Dispatch() to avoid reentrant
+        // AutoTaskDispatcher.
+        NS_DispatchToMainThread(r.forget());
       }
     }
     RefPtr<DecodedStream> mThis;
     Method mMethod;
     UniquePtr<DecodedStreamData> mData;
   };
 
   // Post a message to ensure |mData| is only updated on the worker thread.