diff --git a/ipc/glue/BackgroundImpl.cpp b/ipc/glue/BackgroundImpl.cpp index 98709c242168..8c498f1b9b52 100644 --- a/ipc/glue/BackgroundImpl.cpp +++ b/ipc/glue/BackgroundImpl.cpp @@ -980,6 +980,7 @@ ParentImpl::ShutdownBackgroundThread() AssertIsOnMainThread(); MOZ_ASSERT_IF(!sBackgroundThread, !sBackgroundThreadMessageLoop); MOZ_ASSERT_IF(!sShutdownHasStarted, !sLiveActorCount); + MOZ_ASSERT_IF(!sBackgroundThread, !sLiveActorCount); MOZ_ASSERT_IF(sBackgroundThread, sShutdownTimer); if (sPendingCallbacks) { @@ -1001,6 +1002,12 @@ ParentImpl::ShutdownBackgroundThread() } } + nsCOMPtr shutdownTimer; + if (sShutdownHasStarted) { + shutdownTimer = sShutdownTimer.get(); + sShutdownTimer = nullptr; + } + if (sBackgroundThread) { nsCOMPtr thread = sBackgroundThread.get(); nsAutoPtr> liveActors(sLiveActorsForBackgroundThread); @@ -1015,8 +1022,6 @@ ParentImpl::ShutdownBackgroundThread() // If this is final shutdown then we need to spin the event loop while we // wait for all the actors to be cleaned up. We also set a timeout to // force-kill any hanging actors. - nsCOMPtr shutdownTimer = sShutdownTimer.get(); - sShutdownTimer = nullptr; if (sLiveActorCount) { TimerCallbackClosure closure(thread, liveActors);