Bug 1546500: Avoid dispatching synchronous thread shutdown runnables. r=froydnj a=pascalc
authorKris Maglione <maglione.k@gmail.com>
Tue, 23 Apr 2019 13:16:15 -0700
changeset 523325 81b2e6c7139d2ace9b70332269e02f8633317c98
parent 523324 70f93db9a0817fc666e5551ef0085bad133725f6
child 523326 5e0fd434e5beaab719a82588712916f60b563b43
push id11147
push usernerli@mozilla.com
push dateWed, 24 Apr 2019 13:33:15 +0000
treeherdermozilla-beta@a08cdd143e57 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj, pascalc
bugs1546500
milestone67.0
Bug 1546500: Avoid dispatching synchronous thread shutdown runnables. r=froydnj a=pascalc Differential Revision: https://phabricator.services.mozilla.com/D28555
dom/cache/Manager.cpp
dom/indexedDB/ActorsParent.cpp
gfx/layers/ProfilerScreenshots.cpp
image/DecodePool.cpp
js/xpconnect/loader/URLPreloader.cpp
netwerk/sctp/datachannel/DataChannel.cpp
--- a/dom/cache/Manager.cpp
+++ b/dom/cache/Manager.cpp
@@ -1857,17 +1857,17 @@ Manager::~Manager() {
   MOZ_DIAGNOSTIC_ASSERT(!mContext);
 
   nsCOMPtr<nsIThread> ioThread;
   mIOThread.swap(ioThread);
 
   // Don't spin the event loop in the destructor waiting for the thread to
   // shutdown.  Defer this to the main thread, instead.
   MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(NewRunnableMethod(
-      "nsIThread::Shutdown", ioThread, &nsIThread::Shutdown)));
+      "nsIThread::AsyncShutdown", ioThread, &nsIThread::AsyncShutdown)));
 }
 
 void Manager::Init(Manager* aOldManager) {
   NS_ASSERT_OWNINGTHREAD(Manager);
 
   RefPtr<Context> oldContext;
   if (aOldManager) {
     oldContext = aOldManager->mContext;
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -11092,18 +11092,18 @@ void ConnectionPool::ShutdownThread(Thre
   aThreadInfo.mThread.swap(thread);
 
   IDB_DEBUG_LOG(("ConnectionPool shutting down thread %" PRIu32,
                  runnable->SerialNumber()));
 
   // This should clean up the thread with the profiler.
   MOZ_ALWAYS_SUCCEEDS(thread->Dispatch(runnable.forget(), NS_DISPATCH_NORMAL));
 
-  MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(
-      NewRunnableMethod("nsIThread::Shutdown", thread, &nsIThread::Shutdown)));
+  MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(NewRunnableMethod(
+      "nsIThread::AsyncShutdown", thread, &nsIThread::AsyncShutdown)));
 
   mTotalThreadCount--;
 }
 
 void ConnectionPool::CloseIdleDatabases() {
   AssertIsOnOwningThread();
   MOZ_ASSERT(mShutdownRequested);
 
--- a/gfx/layers/ProfilerScreenshots.cpp
+++ b/gfx/layers/ProfilerScreenshots.cpp
@@ -25,17 +25,17 @@ ProfilerScreenshots::~ProfilerScreenshot
   if (mThread) {
     // Shut down mThread. Do the actual shutdown on the main thread, because it
     // has to happen on an XPCOM thread, and ~ProfilerScreenshots() may not be
     // running on an XPCOM thread - it usually runs on the Compositor thread
     // which is a chromium thread.
     SystemGroup::Dispatch(
         TaskCategory::Other,
         NewRunnableMethod("ProfilerScreenshots::~ProfilerScreenshots", mThread,
-                          &nsIThread::Shutdown));
+                          &nsIThread::AsyncShutdown));
     mThread = nullptr;
   }
 }
 
 /* static */
 bool ProfilerScreenshots::IsEnabled() {
 #ifdef MOZ_GECKO_PROFILER
   return profiler_feature_active(ProfilerFeature::Screenshots);
--- a/image/DecodePool.cpp
+++ b/image/DecodePool.cpp
@@ -80,19 +80,20 @@ class DecodePoolImpl {
         MOZ_ASSERT(aShutdownIdle);
         MOZ_ASSERT(mAvailableThreads < mThreads.Capacity());
         MOZ_ASSERT(removed);
       }
     }
 
     // Threads have to be shut down from another thread, so we'll ask the
     // main thread to do it for us.
-    SystemGroup::Dispatch(TaskCategory::Other,
-                          NewRunnableMethod("DecodePoolImpl::ShutdownThread",
-                                            aThisThread, &nsIThread::Shutdown));
+    SystemGroup::Dispatch(
+        TaskCategory::Other,
+        NewRunnableMethod("DecodePoolImpl::ShutdownThread", aThisThread,
+                          &nsIThread::AsyncShutdown));
   }
 
   /**
    * Requests shutdown. New work items will be dropped on the floor, and all
    * decode pool threads will be shut down once existing work items have been
    * processed.
    */
   void Shutdown() {
--- a/js/xpconnect/loader/URLPreloader.cpp
+++ b/js/xpconnect/loader/URLPreloader.cpp
@@ -314,17 +314,17 @@ Result<Ok, nsresult> URLPreloader::ReadC
   }
 
   return Ok();
 }
 
 void URLPreloader::BackgroundReadFiles() {
   auto cleanup = MakeScopeExit([&]() {
     NS_DispatchToMainThread(NewRunnableMethod(
-        "nsIThread::Shutdown", mReaderThread, &nsIThread::Shutdown));
+        "nsIThread::AsyncShutdown", mReaderThread, &nsIThread::AsyncShutdown));
     mReaderThread = nullptr;
   });
 
   Vector<nsZipCursor> cursors;
   LinkedList<URLEntry> pendingURLs;
   {
     MonitorAutoLock mal(mMonitor);
 
--- a/netwerk/sctp/datachannel/DataChannel.cpp
+++ b/netwerk/sctp/datachannel/DataChannel.cpp
@@ -325,17 +325,17 @@ DataChannelConnection::~DataChannelConne
 
   if (!IsSTSThread()) {
     ASSERT_WEBRTC(NS_IsMainThread());
 
     if (mInternalIOThread) {
       // Avoid spinning the event thread from here (which if we're mainthread
       // is in the event loop already)
       nsCOMPtr<nsIRunnable> r = WrapRunnable(
-          nsCOMPtr<nsIThread>(mInternalIOThread), &nsIThread::Shutdown);
+          nsCOMPtr<nsIThread>(mInternalIOThread), &nsIThread::AsyncShutdown);
       Dispatch(r.forget());
     }
   } else {
     // on STS, safe to call shutdown
     if (mInternalIOThread) {
       mInternalIOThread->Shutdown();
     }
   }