Bug 1232520 - dont' invoke AbstractThread::MainThread()->Dispatch() to avoid reentrant of AutoTaskDispatcher during tail dispatching phase.
--- 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.