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
--- 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)