Bug 1595831 - use StaticPrefs for dom.ipc prefs for ContentParent and the hang monitor code, r=kmag
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 12 Nov 2019 21:30:11 +0000
changeset 501732 710f988369e5588af9b35bf07ac6051083a3407a
parent 501731 0a3045be7a72a15be26196a4401d0b695931387c
child 501733 9473f8de212155dedc4eb74165211636324262bc
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1595831
milestone72.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 1595831 - use StaticPrefs for dom.ipc prefs for ContentParent and the hang monitor code, r=kmag This additionally turns on dom.ipc.processHangMonitor on non-m-c consumers of gecko, as well as turning off dom.ipc.reportProcessHangs on debug geckoview. Differential Revision: https://phabricator.services.mozilla.com/D52699
browser/app/profile/firefox.js
dom/ipc/ContentParent.cpp
dom/ipc/ProcessHangMonitor.cpp
mobile/android/app/geckoview-prefs.js
modules/libpref/init/StaticPrefList.yaml
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1714,40 +1714,24 @@ pref("browser.tabs.remote.warmup.unloadD
 pref("browser.tabs.crashReporting.sendReport", true);
 pref("browser.tabs.crashReporting.includeURL", false);
 pref("browser.tabs.crashReporting.requestEmail", false);
 pref("browser.tabs.crashReporting.emailMe", false);
 pref("browser.tabs.crashReporting.email", "");
 
 pref("extensions.legacy.enabled", false);
 
-// How often to check for CPOW timeouts. CPOWs are only timed out by
-// the hang monitor.
-pref("dom.ipc.cpow.timeout", 500);
-
 // Causes access on unsafe CPOWs from browser code to throw by default.
 pref("dom.ipc.cpows.forbid-unsafe-from-browser", true);
 
-// Enable e10s hang monitoring (slow script checking and plugin hang
-// detection).
-pref("dom.ipc.processHangMonitor", true);
-
 #if defined(XP_WIN)
   // Allows us to deprioritize the processes of background tabs at an OS level
   pref("dom.ipc.processPriorityManager.enabled", true);
 #endif
 
-#ifdef DEBUG
-  // Don't report hangs in DEBUG builds. They're too slow and often a
-  // debugger is attached.
-  pref("dom.ipc.reportProcessHangs", false);
-#else
-  pref("dom.ipc.reportProcessHangs", true);
-#endif
-
 // Don't limit how many nodes we care about on desktop:
 pref("reader.parse-node-limit", 0);
 
 // On desktop, we want the URLs to be included here for ease of debugging,
 // and because (normally) these errors are not persisted anywhere.
 pref("reader.errors.includeURLs", true);
 
 pref("view_source.tab", true);
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -2235,17 +2235,17 @@ void ContentParent::LaunchSubprocessInte
       return LaunchPromise::CreateAndReject(LaunchError{}, __func__);
     }
 
     ContentProcessManager::GetSingleton()->AddContentProcess(this);
 
     mHangMonitorActor = ProcessHangMonitor::AddProcess(this);
 
     // Set a reply timeout for CPOWs.
-    SetReplyTimeoutMs(Preferences::GetInt("dom.ipc.cpow.timeout", 0));
+    SetReplyTimeoutMs(StaticPrefs::dom_ipc_cpow_timeout());
 
     nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
     if (obs) {
       nsAutoString cpId;
       cpId.AppendInt(static_cast<uint64_t>(this->ChildID()));
       obs->NotifyObservers(static_cast<nsIObserver*>(this),
                            "ipc:content-initializing", cpId.get());
     }
--- a/dom/ipc/ProcessHangMonitor.cpp
+++ b/dom/ipc/ProcessHangMonitor.cpp
@@ -18,16 +18,17 @@
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/BrowserChild.h"
 #include "mozilla/dom/BrowserParent.h"
 #include "mozilla/ipc/TaskFactory.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/plugins/PluginBridge.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/StaticPrefs_browser.h"
+#include "mozilla/StaticPrefs_dom.h"
 #include "mozilla/Unused.h"
 #include "mozilla/WeakPtr.h"
 
 #include "nsExceptionHandler.h"
 #include "nsFrameLoader.h"
 #include "nsIHangReport.h"
 #include "nsIRemoteTab.h"
 #include "nsNetUtil.h"
@@ -282,19 +283,16 @@ class HangMonitorParent : public PProces
   void CancelContentJSExecutionIfRunningOnThread(
       TabId aTabId, nsIRemoteTab::NavigationType aNavigationType,
       int32_t aNavigationIndex, nsIURI* aNavigationURI, int32_t aEpoch);
 
   void ShutdownOnThread();
 
   const RefPtr<ProcessHangMonitor> mHangMonitor;
 
-  // This field is read-only after construction.
-  bool mReportHangs;
-
   // This field is only accessed on the hang thread.
   bool mIPCOpen;
 
   Monitor mMonitor;
 
   // Must be accessed with mMonitor held.
   RefPtr<HangMonitoredProcess> mProcess;
   bool mShutdownDone;
@@ -698,18 +696,16 @@ void HangMonitorChild::ClearHangAsync() 
 HangMonitorParent::HangMonitorParent(ProcessHangMonitor* aMonitor)
     : mHangMonitor(aMonitor),
       mIPCOpen(true),
       mMonitor("HangMonitorParent lock"),
       mShutdownDone(false),
       mBrowserCrashDumpHashLock("mBrowserCrashDumpIds lock"),
       mMainThreadTaskFactory(this) {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
-  mReportHangs =
-      mozilla::Preferences::GetBool("dom.ipc.reportProcessHangs", false);
 }
 
 HangMonitorParent::~HangMonitorParent() {
   MutexAutoLock lock(mBrowserCrashDumpHashLock);
 
   for (auto iter = mBrowserCrashDumpIds.Iter(); !iter.Done(); iter.Next()) {
     nsString crashId = iter.UserData();
     if (!crashId.IsEmpty()) {
@@ -881,17 +877,17 @@ bool HangMonitorParent::TakeBrowserMinid
   return false;
 }
 
 mozilla::ipc::IPCResult HangMonitorParent::RecvHangEvidence(
     const HangData& aHangData) {
   // chrome process, background thread
   MOZ_RELEASE_ASSERT(IsOnThread());
 
-  if (!mReportHangs) {
+  if (!StaticPrefs::dom_ipc_reportProcessHangs()) {
     return IPC_OK();
   }
 
 #ifdef XP_WIN
   // Don't report hangs if we're debugging the process. You can comment this
   // line out for testing purposes.
   if (IsDebuggerPresent()) {
     return IPC_OK();
@@ -916,17 +912,17 @@ mozilla::ipc::IPCResult HangMonitorParen
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult HangMonitorParent::RecvClearHang() {
   // chrome process, background thread
   MOZ_RELEASE_ASSERT(IsOnThread());
 
-  if (!mReportHangs) {
+  if (!StaticPrefs::dom_ipc_reportProcessHangs()) {
     return IPC_OK();
   }
 
   mHangMonitor->InitiateCPOWTimeout();
 
   MonitorAutoLock lock(mMonitor);
 
   NS_DispatchToMainThread(mMainThreadTaskFactory.NewRunnableMethod(
@@ -1335,17 +1331,17 @@ bool ProcessHangMonitor::IsOnThread() {
   return NS_SUCCEEDED(mThread->IsOnCurrentThread(&on)) && on;
 }
 
 /* static */
 PProcessHangMonitorParent* ProcessHangMonitor::AddProcess(
     ContentParent* aContentParent) {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
 
-  if (!mozilla::Preferences::GetBool("dom.ipc.processHangMonitor", false)) {
+  if (!StaticPrefs::dom_ipc_processHangMonitor_AtStartup()) {
     return nullptr;
   }
 
   Endpoint<PProcessHangMonitorParent> parent;
   Endpoint<PProcessHangMonitorChild> child;
   nsresult rv;
   rv = PProcessHangMonitor::CreateEndpoints(
       base::GetCurrentProcId(), aContentParent->OtherPid(), &parent, &child);
--- a/mobile/android/app/geckoview-prefs.js
+++ b/mobile/android/app/geckoview-prefs.js
@@ -14,22 +14,18 @@
 #filter substitution
 
 #include mobile.js
 
 pref("privacy.trackingprotection.pbmode.enabled", false);
 
 pref("dom.ipc.keepProcessesAlive.web", 1);
 pref("dom.ipc.processCount", 1);
-pref("dom.ipc.processHangMonitor", true);
 pref("dom.ipc.processPrelaunch.enabled", false);
 
-// Enable hang reports
-pref("dom.ipc.reportProcessHangs", true);
-
 // Tell Telemetry that we're in GeckoView mode.
 pref("toolkit.telemetry.isGeckoViewMode", true);
 // Disable the Telemetry Event Ping
 pref("toolkit.telemetry.eventping.enabled", false);
 
 pref("geckoview.console.enabled", false);
 
 #ifdef RELEASE_OR_BETA
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -1593,28 +1593,53 @@
   value: true
   mirror: always
 
 - name: dom.ipc.cancel_content_js_when_navigating
   type: bool
   value: true
   mirror: always
 
+# How often to check for CPOW timeouts (ms). CPOWs are only timed
+# out by the hang monitor.
+- name: dom.ipc.cpow.timeout
+  type: uint32_t
+  value: 500
+  mirror: always
+
 # Allow Flash async drawing mode in 64-bit release builds.
 - name: dom.ipc.plugins.asyncdrawing.enabled
   type: RelaxedAtomicBool
   value: true
   mirror: always
 
 # How long we wait before unloading an idle plugin process.
 - name: dom.ipc.plugins.unloadTimeoutSecs
   type: RelaxedAtomicUint32
   value: 30
   mirror: always
 
+# Enable e10s hang monitoring (slow script checking and plugin hang detection).
+- name: dom.ipc.processHangMonitor
+  type: bool
+  value: true
+  mirror: once
+
+# Whether we report such process hangs
+- name: dom.ipc.reportProcessHangs
+  type: RelaxedAtomicBool
+# Don't report hangs in DEBUG builds. They're too slow and often a
+# debugger is attached.
+#ifdef DEBUG
+  value: false
+#else
+  value: true
+#endif
+  mirror: always
+
 - name: dom.ipc.tabs.disabled
   type: bool
   value: false
   mirror: always
 
 # Process launch delay (im milliseconds).
 - name: dom.ipc.processPrelaunch.delayMs
   type: uint32_t