Bug 1211337 - Added crash report annotations tracking sync shutdown process. r=cpearce, a=lizzard
authorGerald Squelart <gsquelart@mozilla.com>
Mon, 05 Oct 2015 04:14:00 +0200
changeset 606979 3fb257ea7183c55c314267357fd3473bbc0d948f
parent 606978 9872ab4aa51149d870ee97be5c090d7b12d279fe
child 606980 970363447576e9a9ebe811a7aeecc37a0566065c
push id93006
push userjyavenard@mozilla.com
push dateThu, 15 Oct 2015 05:15:33 +0000
treeherdertry@45ea2a01301e [default view] [failures only]
reviewerscpearce, lizzard
bugs1211337
milestone43.0a2
Bug 1211337 - Added crash report annotations tracking sync shutdown process. r=cpearce, a=lizzard
dom/media/gmp/GMPServiceParent.cpp
--- a/dom/media/gmp/GMPServiceParent.cpp
+++ b/dom/media/gmp/GMPServiceParent.cpp
@@ -262,26 +262,38 @@ GeckoMediaPluginServiceParent::Observe(n
       MOZ_ASSERT(!mShuttingDown);
       mShuttingDown = true;
       gmpThread = mGMPThread;
     }
 
     if (gmpThread) {
       LOGD(("%s::%s Starting to unload plugins, waiting for first sync shutdown..."
             , __CLASS__, __FUNCTION__));
+#ifdef MOZ_CRASHREPORTER
+      SetAsyncShutdownPluginState(nullptr, '0',
+        NS_LITERAL_CSTRING("Dispatching UnloadPlugins"));
+#endif
       gmpThread->Dispatch(
         NS_NewRunnableMethod(this,
                              &GeckoMediaPluginServiceParent::UnloadPlugins),
         NS_DISPATCH_NORMAL);
 
+#ifdef MOZ_CRASHREPORTER
+      SetAsyncShutdownPluginState(nullptr, '1',
+        NS_LITERAL_CSTRING("Waiting for sync shutdown"));
+#endif
       // Wait for UnloadPlugins() to do initial sync shutdown...
       while (mWaitingForPluginsSyncShutdown) {
         NS_ProcessNextEvent(NS_GetCurrentThread(), true);
       }
 
+#ifdef MOZ_CRASHREPORTER
+      SetAsyncShutdownPluginState(nullptr, '4',
+        NS_LITERAL_CSTRING("Waiting for async shutdown"));
+#endif
       // Wait for other plugins (if any) to do async shutdown...
       auto syncShutdownPluginsRemaining =
         std::numeric_limits<decltype(mAsyncShutdownPlugins.Length())>::max();
       for (;;) {
         {
           MutexAutoLock lock(mMutex);
           if (mAsyncShutdownPlugins.IsEmpty()) {
             LOGD(("%s::%s Finished unloading all plugins"
@@ -306,16 +318,20 @@ GeckoMediaPluginServiceParent::Observe(n
             CrashReporter::AnnotateCrashReport(
               NS_LITERAL_CSTRING("AsyncPluginShutdown"),
               names);
 #endif
           }
         }
         NS_ProcessNextEvent(NS_GetCurrentThread(), true);
       }
+#ifdef MOZ_CRASHREPORTER
+      SetAsyncShutdownPluginState(nullptr, '5',
+        NS_LITERAL_CSTRING("Async shutdown complete"));
+#endif
     } else {
       // GMP thread has already shutdown.
       MOZ_ASSERT(mPlugins.IsEmpty());
       mWaitingForPluginsSyncShutdown = false;
     }
 
   } else if (!strcmp(NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID, aTopic)) {
     MOZ_ASSERT(mShuttingDown);
@@ -408,16 +424,23 @@ GeckoMediaPluginServiceParent::AsyncShut
 
 #ifdef MOZ_CRASHREPORTER
 void
 GeckoMediaPluginServiceParent::SetAsyncShutdownPluginState(GMPParent* aGMPParent,
                                                            char aId,
                                                            const nsCString& aState)
 {
   MutexAutoLock lock(mAsyncShutdownPluginStatesMutex);
+  if (!aGMPParent) {
+    mAsyncShutdownPluginStates.Update(NS_LITERAL_CSTRING("-"),
+                                      NS_LITERAL_CSTRING("-"),
+                                      aId,
+                                      aState);
+    return;
+  }
   mAsyncShutdownPluginStates.Update(aGMPParent->GetDisplayName(),
                                     nsPrintfCString("%p", aGMPParent),
                                     aId,
                                     aState);
 }
 
 void
 GeckoMediaPluginServiceParent::AsyncShutdownPluginStates::Update(const nsCString& aPlugin,
@@ -474,16 +497,20 @@ GeckoMediaPluginServiceParent::NotifySyn
 }
 
 void
 GeckoMediaPluginServiceParent::UnloadPlugins()
 {
   MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
   MOZ_ASSERT(!mShuttingDownOnGMPThread);
   mShuttingDownOnGMPThread = true;
+#ifdef MOZ_CRASHREPORTER
+      SetAsyncShutdownPluginState(nullptr, '2',
+        NS_LITERAL_CSTRING("Starting to unload plugins"));
+#endif
 
   {
     MutexAutoLock lock(mMutex);
     LOGD(("%s::%s plugins:%u including async:%u", __CLASS__, __FUNCTION__,
           mPlugins.Length(), mAsyncShutdownPlugins.Length()));
 #ifdef DEBUG
     for (const auto& plugin : mPlugins) {
       LOGD(("%s::%s plugin: '%s'", __CLASS__, __FUNCTION__,
@@ -492,21 +519,29 @@ GeckoMediaPluginServiceParent::UnloadPlu
     for (const auto& plugin : mAsyncShutdownPlugins) {
       LOGD(("%s::%s async plugin: '%s'", __CLASS__, __FUNCTION__,
             plugin->GetDisplayName().get()));
     }
 #endif
     // Note: CloseActive may be async; it could actually finish
     // shutting down when all the plugins have unloaded.
     for (size_t i = 0; i < mPlugins.Length(); i++) {
+#ifdef MOZ_CRASHREPORTER
+      SetAsyncShutdownPluginState(mPlugins[i], 'S',
+          NS_LITERAL_CSTRING("CloseActive"));
+#endif
       mPlugins[i]->CloseActive(true);
     }
     mPlugins.Clear();
   }
 
+#ifdef MOZ_CRASHREPORTER
+      SetAsyncShutdownPluginState(nullptr, '3',
+        NS_LITERAL_CSTRING("Dispatching sync-shutdown-complete"));
+#endif
   nsCOMPtr<nsIRunnable> task(NS_NewRunnableMethod(
     this, &GeckoMediaPluginServiceParent::NotifySyncShutdownComplete));
   NS_DispatchToMainThread(task);
 }
 
 void
 GeckoMediaPluginServiceParent::CrashPlugins()
 {