Bug 1301339 - Annotate content shutdown hang due to nested event loop in RecvShutdown. r=billm
authorKan-Ru Chen <kanru@kanru.info>
Thu, 08 Sep 2016 17:23:57 +0800
changeset 313297 399174fe175afe9d112d5c4e115a5b92395f3b1b
parent 313296 37577db303680328e0e0293ed4d9e156cb5b2fa9
child 313298 1abd03e07bf53c976a10a7bad3caf2f94029c57e
push id32162
push userkchen@mozilla.com
push dateFri, 09 Sep 2016 07:08:02 +0000
treeherderautoland@399174fe175a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1301339
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1301339 - Annotate content shutdown hang due to nested event loop in RecvShutdown. r=billm We currently allow nested event loop to delay ContentChild::RecvShutdown which in turn might cause content process shutdown hang. This patch attempts to annotate the crash report that a shutdown hang was after we have received RecvShutdown but never reach SendFinishShutdown or the hang happened before or after RecvShutdown. MozReview-Commit-ID: 8pGqwzLlYpK
dom/ipc/ContentChild.cpp
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -2978,16 +2978,20 @@ ContentChild::ForceKillTimerCallback(nsI
 
 bool
 ContentChild::RecvShutdown()
 {
   // If we receive the shutdown message from within a nested event loop, we want
   // to wait for that event loop to finish. Otherwise we could prematurely
   // terminate an "unload" or "pagehide" event handler (which might be doing a
   // sync XHR, for example).
+#if defined(MOZ_CRASHREPORTER)
+  CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCShutdownState"),
+                                     NS_LITERAL_CSTRING("RecvShutdown"));
+#endif
   nsCOMPtr<nsIThread> thread;
   nsresult rv = NS_GetMainThread(getter_AddRefs(thread));
   if (NS_SUCCEEDED(rv) && thread) {
     RefPtr<nsThread> mainThread(thread.forget().downcast<nsThread>());
     if (mainThread->RecursionDepth() > 1) {
       // We're in a nested event loop. Let's delay for an arbitrary period of
       // time (100ms) in the hopes that the event loop will have finished by
       // then.
@@ -3025,16 +3029,20 @@ ContentChild::RecvShutdown()
   }
 #endif
 
   // Start a timer that will insure we quickly exit after a reasonable
   // period of time. Prevents shutdown hangs after our connection to the
   // parent closes.
   StartForceKillTimer();
 
+#if defined(MOZ_CRASHREPORTER)
+  CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCShutdownState"),
+                                     NS_LITERAL_CSTRING("SendFinishShutdown"));
+#endif
   // Ignore errors here. If this fails, the parent will kill us after a
   // timeout.
   Unused << SendFinishShutdown();
   return true;
 }
 
 PBrowserOrId
 ContentChild::GetBrowserOrId(TabChild* aTabChild)