diff --git a/dom/workers/WorkerThread.cpp b/dom/workers/WorkerThread.cpp index f7631055dc85..dd3aefb28e18 100644 --- a/dom/workers/WorkerThread.cpp +++ b/dom/workers/WorkerThread.cpp @@ -127,10 +127,12 @@ void WorkerThread::SetWorker(const WorkerThreadFriendKey& /* aKey */, MOZ_ASSERT(mWorkerPrivate); MOZ_ASSERT(!mAcceptingNonWorkerRunnables); - MOZ_ASSERT(!mOtherThreadsDispatchingViaEventTarget, - "XPCOM Dispatch hapenning at the same time our thread is " - "being unset! This should not be possible!"); - + // mOtherThreadsDispatchingViaEventTarget can still be non-zero here + // because WorkerThread::Dispatch isn't atomic so a thread initiating + // dispatch can have dispatched a runnable at this thread allowing us to + // begin shutdown before that thread gets a chance to decrement + // mOtherThreadsDispatchingViaEventTarget back to 0. So we need to wait + // for that. while (mOtherThreadsDispatchingViaEventTarget) { mWorkerPrivateCondVar.Wait(); }