Bug 1382649 - Unset dom.ipc.processCount pref value should be taken as a user opt-in value if browser.preferences.defaultPerformanceSettings.enabled is false. r=mrbkap draft
authorTimothy Guan-tin Chien <timdream@gmail.com>
Fri, 21 Jul 2017 11:48:07 +0800
changeset 613609 2b033328830e4f5d5293b204b1613c90f9d00e58
parent 613568 057d626fc5e1afbf4086eb9400ebb3718a4cabca
child 613610 5182a511e38e9fcdb6b4b5db719fd8b88f6cbcc3
child 613693 f7ba19ed2712b900f2cc3c584efef3ff1895d1c3
push id69824
push usertimdream@gmail.com
push dateSat, 22 Jul 2017 04:32:53 +0000
reviewersmrbkap
bugs1382649
milestone56.0a1
Bug 1382649 - Unset dom.ipc.processCount pref value should be taken as a user opt-in value if browser.preferences.defaultPerformanceSettings.enabled is false. r=mrbkap MozReview-Commit-ID: 5zSix0koTc4
browser/extensions/e10srollout/bootstrap.js
toolkit/xre/nsAppRunner.cpp
--- a/browser/extensions/e10srollout/bootstrap.js
+++ b/browser/extensions/e10srollout/bootstrap.js
@@ -69,16 +69,17 @@ const PREF_E10S_OPTED_IN       = "browse
 const PREF_E10S_FORCE_ENABLED  = "browser.tabs.remote.force-enable";
 const PREF_E10S_FORCE_DISABLED = "browser.tabs.remote.force-disable";
 const PREF_TOGGLE_E10S         = "browser.tabs.remote.autostart.2";
 const PREF_E10S_ADDON_POLICY   = "extensions.e10s.rollout.policy";
 const PREF_E10S_ADDON_BLOCKLIST = "extensions.e10s.rollout.blocklist";
 const PREF_E10S_HAS_NONEXEMPT_ADDON = "extensions.e10s.rollout.hasAddon";
 const PREF_E10S_MULTI_OPTOUT   = "dom.ipc.multiOptOut";
 const PREF_E10S_PROCESSCOUNT   = "dom.ipc.processCount";
+const PREF_USE_DEFAULT_PERF_SETTINGS = "browser.preferences.defaultPerformanceSettings.enabled";
 const PREF_E10S_MULTI_ADDON_BLOCKS = "extensions.e10sMultiBlocksEnabling";
 const PREF_E10S_MULTI_BLOCKED_BY_ADDONS = "extensions.e10sMultiBlockedByAddons";
 
 function startup() {
   // In theory we only need to run this once (on install()), but
   // it's better to also run it on every startup. If the user has
   // made manual changes to the prefs, this will keep the data
   // reported more accurate.
@@ -254,17 +255,18 @@ function setCohort(cohortName) {
       Services.appinfo.QueryInterface(Ci.nsICrashReporter).annotateCrashReport("E10SCohort", cohortName);
     }
   } catch (e) {}
 }
 
 function optedIn() {
   let e10s = Preferences.get(PREF_E10S_OPTED_IN, false) ||
              Preferences.get(PREF_E10S_FORCE_ENABLED, false);
-  let multi = Preferences.isSet(PREF_E10S_PROCESSCOUNT);
+  let multi = Preferences.isSet(PREF_E10S_PROCESSCOUNT) ||
+             !Preferences.get(PREF_USE_DEFAULT_PERF_SETTINGS, true);
   return { e10s, multi };
 }
 
 function optedOut() {
   // Users can also opt-out by toggling back the pref to false.
   // If they reset the pref instead they might be re-enabled if
   // they are still part of the threshold.
   let e10s = Preferences.get(PREF_E10S_FORCE_DISABLED, false) ||
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -5177,21 +5177,26 @@ GetMaxWebProcessCount()
   // introducing multiple prefs a la the autostart.N prefs.
   if (Preferences::GetInt("dom.ipc.multiOptOut", 0) >=
           nsIXULRuntime::E10S_MULTI_EXPERIMENT) {
     return 1;
   }
 
   const char* optInPref = "dom.ipc.processCount";
   uint32_t optInPrefValue = Preferences::GetInt(optInPref, 1);
-
-  // If the user has set dom.ipc.processCount, respect their decision
-  // regardless of add-ons that might affect their experience or experiment
-  // cohort.
-  if (Preferences::HasUserValue(optInPref)) {
+  const char* useDefaultPerformanceSettings =
+    "browser.preferences.defaultPerformanceSettings.enabled";
+  bool useDefaultPerformanceSettingsValue =
+    Preferences::GetBool(useDefaultPerformanceSettings, true);
+
+  // If the user has set dom.ipc.processCount, or if they have opt out of
+  // default performances settings from about:preferences, respect their
+  // decision regardless of add-ons that might affect their experience or
+  // experiment cohort.
+  if (Preferences::HasUserValue(optInPref) || !useDefaultPerformanceSettingsValue) {
     return std::max(1u, optInPrefValue);
   }
 
 #ifdef RELEASE_OR_BETA
   // For our rollout on Release and Beta, we set this pref from the
   // e10srollout extension. On Nightly, we don't touch the pref at all,
   // allowing stale values to disable e10s-multi for certain users.
   if (Preferences::HasUserValue("dom.ipc.processCount.web")) {