Bug 1241959 - Add a description of e10s blocked status to about:support. r?jimm draft
authorFelipe Gomes <felipc@gmail.com>
Fri, 22 Jan 2016 17:24:20 -0200
changeset 324413 9914bde2d700a468563a2fb7181ca046ae57d504
parent 324322 7104d650a97d895cbbc64d53462bf86a04658abe
child 513380 e62aa55914dff74c9a46f2dd25e5a4e0bf329ad6
push id9905
push userfelipc@gmail.com
push dateFri, 22 Jan 2016 19:24:43 +0000
reviewersjimm
bugs1241959
milestone46.0a1
Bug 1241959 - Add a description of e10s blocked status to about:support. r?jimm
browser/components/preferences/in-content/main.js
browser/components/preferences/in-content/main.xul
toolkit/content/aboutSupport.js
toolkit/locales/en-US/chrome/global/aboutSupport.properties
toolkit/modules/Troubleshoot.jsm
toolkit/xre/nsAppRunner.cpp
--- a/browser/components/preferences/in-content/main.js
+++ b/browser/components/preferences/in-content/main.js
@@ -78,48 +78,31 @@ var gMainPane = {
                      gMainPane.restoreDefaultHomePage);
     setEventListener("chooseFolder", "command",
                      gMainPane.chooseFolder);
 
 #ifdef E10S_TESTING_ONLY
     setEventListener("e10sAutoStart", "command",
                      gMainPane.enableE10SChange);
     let e10sCheckbox = document.getElementById("e10sAutoStart");
-    e10sCheckbox.checked = Services.appinfo.browserTabsRemoteAutostart;
+
+    let e10sPref = document.getElementById("browser.tabs.remote.autostart");
+    let e10sTempPref = document.getElementById("e10sTempPref");
+    let e10sForceEnable = document.getElementById("e10sForceEnable");
+
+    let preffedOn = e10sPref.value || e10sTempPref.value || e10sForceEnable.value;
 
-    // If e10s is blocked for some reason unrelated to prefs, we want to disable
-    // the checkbox.
-    if (!Services.appinfo.browserTabsRemoteAutostart) {
-      let e10sBlockedReason = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
-      let appinfo = Services.appinfo.QueryInterface(Ci.nsIObserver);
-      appinfo.observe(e10sBlockedReason, "getE10SBlocked", "")
-      if (e10sBlockedReason.data) {
-        if (e10sBlockedReason.data == "Safe mode") {
-          // If the only reason we're disabled is because of safe mode, then
-          // we want to allow the user to un-toggle the pref.
-          // We're relying on the nsAppRunner code only specifying "Safe mode"
-          // as the reason if the pref is otherwise enabled, and there are no
-          // other reasons to block e10s.
-          // Update the checkbox to reflect the pref state.
-          e10sCheckbox.checked = true;
-        } else {
-          e10sCheckbox.disabled = true;
-          let updateChannel = UpdateUtils.UpdateChannel;
-          // only add this label on developer channels
-          if (updateChannel == "default" ||
-              updateChannel == "nightly" ||
-              updateChannel == "aurora") {
-            e10sCheckbox.label += " (disabled: " + e10sBlockedReason.data + ")";
-          }
-        }
-      }
+    if (preffedOn) {
+      // The checkbox is checked if e10s is preffed on.
+      e10sCheckbox.checked = true;
+
+      // but if it's force disabled, then the checkbox is disabled.
+      e10sCheckbox.disabled = !Services.appinfo.browserTabsRemoteAutostart;
     }
 
-    // If E10S is blocked because of safe mode, we want the checkbox to be
-    // enabled
 #endif
 
 #ifdef MOZ_DEV_EDITION
     Cu.import("resource://gre/modules/osfile.jsm");
     let uAppData = OS.Constants.Path.userApplicationDataDir;
     let ignoreSeparateProfile = OS.Path.join(uAppData, "ignore-dev-edition-profile");
 
     setEventListener("separateProfileMode", "command", gMainPane.separateProfileModeChange);
--- a/browser/components/preferences/in-content/main.xul
+++ b/browser/components/preferences/in-content/main.xul
@@ -11,16 +11,19 @@
 
 #ifdef E10S_TESTING_ONLY
     <preference id="browser.tabs.remote.autostart"
                 name="browser.tabs.remote.autostart"
                 type="bool"/>
     <preference id="e10sTempPref"
                 name="browser.tabs.remote.autostart.2"
                 type="bool"/>
+    <preference id="e10sForceEnable"
+                name="browser.tabs.remote.force-enable"
+                type="bool"/>
 #endif
 
     <!-- Startup -->
     <preference id="browser.startup.page"
                 name="browser.startup.page"
                 type="int"/>
     <preference id="browser.startup.homepage"
                 name="browser.startup.homepage"
--- a/toolkit/content/aboutSupport.js
+++ b/toolkit/content/aboutSupport.js
@@ -41,18 +41,33 @@ var snapshotFormatters = {
     let version = AppConstants.MOZ_APP_VERSION_DISPLAY;
     if (data.vendor)
       version += " (" + data.vendor + ")";
     $("version-box").textContent = version;
     $("buildid-box").textContent = data.buildID;
     if (data.updateChannel)
       $("updatechannel-box").textContent = data.updateChannel;
 
-    $("multiprocess-box").textContent = stringBundle().formatStringFromName("multiProcessStatus",
-      [data.numRemoteWindows, data.numTotalWindows, data.remoteAutoStart], 3);
+    let statusStrName = ".unknown";
+
+    // Whitelist of known values with string descriptions:
+    switch (data.autoStartStatus) {
+      case 0:
+      case 1:
+      case 2:
+      case 4:
+      case 5:
+      case 6:
+      case 7:
+        statusStrName = "." + data.autoStartStatus;
+    }
+
+    let statusText = stringBundle().GetStringFromName("multiProcessStatus" + statusStrName);
+    $("multiprocess-box").textContent = stringBundle().formatStringFromName("multiProcessWindows",
+      [data.numRemoteWindows, data.numTotalWindows, statusText], 3);
 
     $("safemode-box").textContent = data.safeMode;
   },
 
   crashes: function crashes(data) {
     if (!AppConstants.MOZ_CRASHREPORTER)
       return;
 
--- a/toolkit/locales/en-US/chrome/global/aboutSupport.properties
+++ b/toolkit/locales/en-US/chrome/global/aboutSupport.properties
@@ -91,19 +91,28 @@ loadedLibVersions = Version in use
 hasSeccompBPF = Seccomp-BPF (System Call Filtering)
 hasSeccompTSync = Seccomp Thread Synchronization
 hasUserNamespaces = User Namespaces
 hasPrivilegedUserNamespaces = User Namespaces for privileged processes
 canSandboxContent = Content Process Sandboxing
 canSandboxMedia = Media Plugin Sandboxing
 
 # LOCALIZATION NOTE %1$S and %2$S will be replaced with the number of remote and the total number
-# of windows, respectively, while %3$S will indicate whether windows are remote by default ('true'
-# or 'false')
-multiProcessStatus = %1$S/%2$S (default: %3$S)
+# of windows, respectively, while %3$S will be replaced with one of the status strings below,
+# which contains a description of the multi-process preference and status.
+# Note: multiProcessStatus.3 doesn't exist because status=3 was deprecated.
+multiProcessWindows = %1$S/%2$S (%3$S)
+multiProcessStatus.0 = Enabled by user
+multiProcessStatus.1 = Enabled by default
+multiProcessStatus.2 = Disabled
+multiProcessStatus.4 = Disabled by accessibility tools
+multiProcessStatus.5 = Disabled by lack of graphics hardware acceleration
+multiProcessStatus.6 = Disabled by unsupported text input
+multiProcessStatus.7 = Disabled by add-ons
+multiProcessStatus.unknown = Unknown status
 
 asyncPanZoom = Asynchronous Pan/Zoom
 apzNone = none
 wheelEnabled = wheel input enabled
 touchEnabled = touch input enabled
 dragEnabled = scrollbar drag enabled
 
 # LOCALIZATION NOTE %1 will be replaced with the key of a preference.
--- a/toolkit/modules/Troubleshoot.jsm
+++ b/toolkit/modules/Troubleshoot.jsm
@@ -214,16 +214,26 @@ var dataProviders = {
                    useRemoteTabs;
       if (remote) {
         data.numRemoteWindows++;
       }
     }
 
     data.remoteAutoStart = Services.appinfo.browserTabsRemoteAutostart;
 
+    try {
+      let e10sStatus = Cc["@mozilla.org/supports-PRUint64;1"]
+                         .createInstance(Ci.nsISupportsPRUint64);
+      let appinfo = Services.appinfo.QueryInterface(Ci.nsIObserver);
+      appinfo.observe(e10sStatus, "getE10SBlocked", "");
+      data.autoStartStatus = e10sStatus.data;
+    } catch (e) {
+      data.autoStartStatus = -1;
+    }
+
     done(data);
   },
 
   extensions: function extensions(done) {
     AddonManager.getAddonsByTypes(["extension"], function (extensions) {
       extensions.sort(function (a, b) {
         if (a.isActive != b.isActive)
           return b.isActive ? 1 : -1;
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -990,27 +990,27 @@ nsXULAppInfo::GetProcessID(uint32_t* aRe
   *aResult = GetCurrentProcessId();
 #else
   *aResult = getpid();
 #endif
   return NS_OK;
 }
 
 static bool gBrowserTabsRemoteAutostart = false;
-static nsString gBrowserTabsRemoteDisabledReason;
+static uint64_t gBrowserTabsRemoteStatus = 0;
 static bool gBrowserTabsRemoteAutostartInitialized = false;
 
 NS_IMETHODIMP
 nsXULAppInfo::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *aData) {
   if (!nsCRT::strcmp(aTopic, "getE10SBlocked")) {
-    nsCOMPtr<nsISupportsString> ret = do_QueryInterface(aSubject);
+    nsCOMPtr<nsISupportsPRUint64> ret = do_QueryInterface(aSubject);
     if (!ret)
       return NS_ERROR_FAILURE;
 
-    ret->SetData(gBrowserTabsRemoteDisabledReason);
+    ret->SetData(gBrowserTabsRemoteStatus);
 
     return NS_OK;
   }
   return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 nsXULAppInfo::GetBrowserTabsRemoteAutostart(bool* aResult)
@@ -4626,29 +4626,16 @@ XRE_IsParentProcess()
 }
 
 bool
 XRE_IsContentProcess()
 {
   return XRE_GetProcessType() == GeckoProcessType_Content;
 }
 
-static void
-LogE10sBlockedReason(const char *reason) {
-  gBrowserTabsRemoteDisabledReason.Assign(NS_ConvertASCIItoUTF16(reason));
-
-  nsAutoString msg(NS_LITERAL_STRING("==================\nE10s has been blocked from running because:\n"));
-  msg.Append(gBrowserTabsRemoteDisabledReason);
-  msg.AppendLiteral("\n==================\n");
-  nsCOMPtr<nsIConsoleService> console(do_GetService("@mozilla.org/consoleservice;1"));
-  if (console) {
-    console->LogStringMessage(msg.get());
-  }
-}
-
 enum {
   kE10sEnabledByUser = 0,
   kE10sEnabledByDefault = 1,
   kE10sDisabledByUser = 2,
   // kE10sDisabledInSafeMode = 3, was removed in bug 1172491.
   kE10sDisabledForAccessibility = 4,
   kE10sDisabledForMacGfx = 5,
   kE10sDisabledForBidi = 6,
@@ -4758,20 +4745,18 @@ mozilla::BrowserTabsRemoteAutostart()
   // We are also allowing e10s to be enabled on Beta (which doesn't have E10S_TESTING_ONLY defined.
   bool e10sAllowed = !Preferences::GetDefaultCString("app.update.channel").EqualsLiteral("release") ||
                      gfxPrefs::GetSingleton().LayersOffMainThreadCompositionTestingEnabled();
 #endif
 
   if (e10sAllowed && prefEnabled) {
     if (disabledForA11y) {
       status = kE10sDisabledForAccessibility;
-      LogE10sBlockedReason("An accessibility tool is or was active. See bug 1198459.");
     } else if (disabledForBidi) {
       status = kE10sDisabledForBidi;
-      LogE10sBlockedReason("Disabled for RTL locales due to broken bidi detection.");
     } else {
       gBrowserTabsRemoteAutostart = true;
     }
   }
 
 #if defined(XP_MACOSX)
   // If for any reason we suspect acceleration will be disabled, disabled
   // e10s auto start on mac.
@@ -4799,30 +4784,30 @@ mozilla::BrowserTabsRemoteAutostart()
       const char *acceleratedEnv = PR_GetEnv("MOZ_ACCELERATED");
       if (acceleratedEnv && (*acceleratedEnv != '0')) {
         accelDisabled = false;
       }
     }
 
     if (accelDisabled) {
       gBrowserTabsRemoteAutostart = false;
-
       status = kE10sDisabledForMacGfx;
-      LogE10sBlockedReason("Hardware acceleration is disabled");
     }
   }
 #endif // defined(XP_MACOSX)
 
   // Uber override pref for manual testing purposes
   if (Preferences::GetBool(kForceEnableE10sPref, false)) {
     gBrowserTabsRemoteAutostart = true;
     prefEnabled = true;
     status = kE10sEnabledByUser;
   }
 
+  gBrowserTabsRemoteStatus = status;
+
   mozilla::Telemetry::Accumulate(mozilla::Telemetry::E10S_STATUS, status);
   if (Preferences::GetBool("browser.enabledE10SFromPrompt", false)) {
     mozilla::Telemetry::Accumulate(mozilla::Telemetry::E10S_STILL_ACCEPTED_FROM_PROMPT,
                                     gBrowserTabsRemoteAutostart);
   }
   if (prefEnabled) {
     mozilla::Telemetry::Accumulate(mozilla::Telemetry::E10S_BLOCKED_FROM_RUNNING,
                                     !gBrowserTabsRemoteAutostart);