From 92baa0f0e7af622d146cd5fb3ec82c5ab749c906 Mon Sep 17 00:00:00 2001 From: Vladan Djeric Date: Sat, 26 Dec 2015 19:34:11 -0500 Subject: [PATCH] Bug 1228437 - Add BHR stats from e10s child process. B2G fix by Ting-Yu Chou. r=nchen --- xpcom/build/XPCOMInit.cpp | 6 +++++- xpcom/threads/HangMonitor.cpp | 27 ++++++++++++++++++++------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/xpcom/build/XPCOMInit.cpp b/xpcom/build/XPCOMInit.cpp index 8545b699b34..625b8385f1d 100644 --- a/xpcom/build/XPCOMInit.cpp +++ b/xpcom/build/XPCOMInit.cpp @@ -521,12 +521,16 @@ NS_InitXPCOM2(nsIServiceManager** aResult, sExitManager = new AtExitManager(); } - if (!MessageLoop::current()) { + MessageLoop* messageLoop = MessageLoop::current(); + if (!messageLoop) { sMessageLoop = new MessageLoopForUI(MessageLoop::TYPE_MOZILLA_UI); sMessageLoop->set_thread_name("Gecko"); // Set experimental values for main thread hangs: // 128ms for transient hangs and 8192ms for permanent hangs sMessageLoop->set_hang_timeouts(128, 8192); + } else if (messageLoop->type() == MessageLoop::TYPE_MOZILLA_CHILD) { + messageLoop->set_thread_name("Gecko_Child"); + messageLoop->set_hang_timeouts(128, 8192); } if (XRE_IsParentProcess() && diff --git a/xpcom/threads/HangMonitor.cpp b/xpcom/threads/HangMonitor.cpp index 7b0a82f5010..911bccbd7d9 100644 --- a/xpcom/threads/HangMonitor.cpp +++ b/xpcom/threads/HangMonitor.cpp @@ -23,6 +23,10 @@ #include "nsExceptionHandler.h" #endif +#ifdef MOZ_NUWA_PROCESS +#include "ipc/Nuwa.h" +#endif + #ifdef XP_WIN #include #endif @@ -109,8 +113,12 @@ Crash() #endif #ifdef MOZ_CRASHREPORTER - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Hang"), - NS_LITERAL_CSTRING("1")); + // If you change this, you must also deal with the threadsafety of AnnotateCrashReport in + // non-chrome processes! + if (GeckoProcessType_Default == XRE_GetProcessType()) { + CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Hang"), + NS_LITERAL_CSTRING("1")); + } #endif NS_RUNTIMEABORT("HangMonitor triggered"); @@ -176,6 +184,12 @@ ThreadMain(void*) { PR_SetCurrentThreadName("Hang Monitor"); +#ifdef MOZ_NUWA_PROCESS + if (IsNuwaProcess()) { + NuwaMarkCurrentThread(nullptr, nullptr); + } +#endif + MonitorAutoLock lock(*gMonitor); // In order to avoid issues with the hang monitor incorrectly triggering @@ -256,10 +270,8 @@ ThreadMain(void*) void Startup() { - // The hang detector only runs in chrome processes. If you change this, - // you must also deal with the threadsafety of AnnotateCrashReport in - // non-chrome processes! - if (GeckoProcessType_Default != XRE_GetProcessType()) { + if (GeckoProcessType_Default != XRE_GetProcessType() && + GeckoProcessType_Content != XRE_GetProcessType()) { return; } @@ -293,7 +305,8 @@ Startup() void Shutdown() { - if (GeckoProcessType_Default != XRE_GetProcessType()) { + if (GeckoProcessType_Default != XRE_GetProcessType() && + GeckoProcessType_Content != XRE_GetProcessType()) { return; }