Bug 1063848 - Disable e10s in safe mode. r=bsmedberg, r=ally, a=sledru, ba=jorgev
authorFelipe Gomes <felipc@gmail.com>
Wed, 10 Sep 2014 15:53:55 -0300
changeset 216858 2b061899d368
parent 216857 b57f0af03f78
child 216859 16e19b9cec72
push id3942
push userryanvm@gmail.com
push date2014-09-26 13:41 +0000
treeherdermozilla-beta@2b061899d368 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, ally, sledru
bugs1063848
milestone33.0
Bug 1063848 - Disable e10s in safe mode. r=bsmedberg, r=ally, a=sledru, ba=jorgev
browser/base/content/browser.js
browser/components/customizableui/src/CustomizableWidgets.jsm
embedding/components/windowwatcher/src/nsWindowWatcher.cpp
gfx/thebes/gfxPlatform.cpp
js/xpconnect/src/XPCWrappedNativeScope.cpp
toolkit/content/browser-child.js
toolkit/mozapps/extensions/internal/XPIProvider.jsm
toolkit/xre/nsAppRunner.cpp
toolkit/xre/nsXREDirProvider.cpp
xpcom/system/nsIXULRuntime.idl
xpfe/appshell/src/nsAppShellService.cpp
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -7034,18 +7034,18 @@ let gPrivateBrowsingUI = {
 };
 
 let gRemoteTabsUI = {
   init: function() {
     if (window.location.href != getBrowserURL()) {
       return;
     }
 
-    let remoteTabs = gPrefService.getBoolPref("browser.tabs.remote");
-    let autostart = gPrefService.getBoolPref("browser.tabs.remote.autostart");
+    let remoteTabs = Services.appinfo.browserTabsRemote;
+    let autostart = Services.appinfo.browserTabsRemoteAutostart;
 
     let newRemoteWindow = document.getElementById("menu_newRemoteWindow");
     let newNonRemoteWindow = document.getElementById("menu_newNonRemoteWindow");
 
     if (!remoteTabs) {
       newRemoteWindow.hidden = true;
       newNonRemoteWindow.hidden = true;
       return;
--- a/browser/components/customizableui/src/CustomizableWidgets.jsm
+++ b/browser/components/customizableui/src/CustomizableWidgets.jsm
@@ -936,17 +936,17 @@ if (Services.prefs.getBoolPref("browser.
     return function(aEvent) {
       let win = aEvent.view;
       if (win && typeof win.OpenBrowserWindow == "function") {
         win.OpenBrowserWindow({remote: aOpenRemote});
       }
     };
   }
 
-  let openRemote = !Services.prefs.getBoolPref("browser.tabs.remote.autostart");
+  let openRemote = !Services.appinfo.browserTabsRemoteAutostart;
   // Like the XUL menuitem counterparts, we hard-code these strings in because
   // this button should never roll into production.
   let buttonLabel = openRemote ? "New e10s Window"
                                : "New Non-e10s Window";
 
   CustomizableWidgets.push({
     id: "e10s-button",
     label: buttonLabel,
--- a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp
+++ b/embedding/components/windowwatcher/src/nsWindowWatcher.cpp
@@ -1460,17 +1460,17 @@ uint32_t nsWindowWatcher::CalculateChrom
       nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW : 0;
     chromeFlags |= WinHasOption(aFeatures, "non-private", 0, &presenceFlag) ?
       nsIWebBrowserChrome::CHROME_NON_PRIVATE_WINDOW : 0;
   }
 
   // Determine whether the window should have remote tabs.
   if (isCallerChrome || aOpenedFromRemoteTab) {
     bool remote;
-    if (Preferences::GetBool("browser.tabs.remote.autostart")) {
+    if (BrowserTabsRemoteAutostart()) {
       remote = !WinHasOption(aFeatures, "non-remote", 0, &presenceFlag);
     } else {
       remote = WinHasOption(aFeatures, "remote", 0, &presenceFlag);
     }
     if (remote) {
       chromeFlags |= nsIWebBrowserChrome::CHROME_REMOTE_WINDOW;
     }
   }
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -1938,17 +1938,17 @@ InitLayersAccelerationPrefs()
   {
     // If this is called for the first time on a non-main thread, we're screwed.
     // At the moment there's no explicit guarantee that the main thread calls
     // this before the compositor thread, but let's at least make the assumption
     // explicit.
     MOZ_ASSERT(NS_IsMainThread(), "can only initialize prefs on the main thread");
 
     gfxPrefs::GetSingleton();
-    sPrefBrowserTabsRemoteAutostart = Preferences::GetBool("browser.tabs.remote.autostart", false);
+    sPrefBrowserTabsRemoteAutostart = BrowserTabsRemoteAutostart();
 
 #ifdef XP_WIN
     if (gfxPrefs::LayersAccelerationForceEnabled()) {
       sLayersSupportsD3D9 = true;
       sLayersSupportsD3D11 = true;
     } else {
       nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
       if (gfxInfo) {
--- a/js/xpconnect/src/XPCWrappedNativeScope.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp
@@ -9,16 +9,17 @@
 #include "xpcprivate.h"
 #include "XPCWrapper.h"
 #include "nsContentUtils.h"
 #include "nsCycleCollectionNoteRootCallback.h"
 #include "nsPrincipal.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Preferences.h"
 #include "nsIAddonInterposition.h"
+#include "nsIXULRuntime.h"
 
 #include "mozilla/dom/BindingUtils.h"
 
 using namespace mozilla;
 using namespace xpc;
 using namespace JS;
 
 /***************************************************************************/
@@ -206,17 +207,17 @@ XPCWrappedNativeScope::AttachComponentsO
 static bool
 CompartmentPerAddon()
 {
     static bool initialized = false;
     static bool pref = false;
 
     if (!initialized) {
         pref = Preferences::GetBool("dom.compartment_per_addon", false) ||
-               Preferences::GetBool("browser.tabs.remote.autostart", false);
+               BrowserTabsRemoteAutostart();
         initialized = true;
     }
 
     return pref;
 }
 
 JSObject*
 XPCWrappedNativeScope::EnsureContentXBLScope(JSContext *cx)
--- a/toolkit/content/browser-child.js
+++ b/toolkit/content/browser-child.js
@@ -351,17 +351,17 @@ addEventListener("TextZoomChange", funct
   if (ZoomManager.refreshTextZoom()) {
     sendAsyncMessage("TextZoomChange", { value:  ZoomManager.textZoom});
   }
 }, false);
 
 // The AddonsChild needs to be rooted so that it stays alive as long as
 // the tab.
 let AddonsChild;
-if (Services.prefs.getBoolPref("browser.tabs.remote.autostart")) {
+if (Services.appinfo.browserTabsRemoteAutostart) {
   // Currently, the addon shims are only supported when autostarting
   // with remote tabs.
   AddonsChild = RemoteAddonsChild.init(this);
 }
 
 addMessageListener("NetworkPrioritizer:AdjustPriority", (msg) => {
   let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
   let loadGroup = webNav.QueryInterface(Ci.nsIDocumentLoader)
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -4145,17 +4145,17 @@ this.XPIProvider = {
       return;
     }
 
     logger.debug("Loading bootstrap scope from " + aFile.path);
 
     let principal = Cc["@mozilla.org/systemprincipal;1"].
                     createInstance(Ci.nsIPrincipal);
 
-    if (!aMultiprocessCompatible && Prefs.getBoolPref("browser.tabs.remote.autostart", false)) {
+    if (!aMultiprocessCompatible && Services.appinfo.browserTabsRemoteAutostart) {
       let interposition = Cc["@mozilla.org/addons/multiprocess-shims;1"].
         getService(Ci.nsIAddonInterposition);
       Cu.setAddonInterposition(aId, interposition);
     }
 
     if (!aFile.exists()) {
       this.bootstrapScopes[aId] =
         new Cu.Sandbox(principal, { sandboxName: aFile.path,
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -805,16 +805,26 @@ static bool gBrowserTabsRemoteInitialize
 
 NS_IMETHODIMP
 nsXULAppInfo::GetBrowserTabsRemote(bool* aResult)
 {
   *aResult = BrowserTabsRemote();
   return NS_OK;
 }
 
+static bool gBrowserTabsRemoteAutostart = false;
+static bool gBrowserTabsRemoteAutostartInitialized = false;
+
+NS_IMETHODIMP
+nsXULAppInfo::GetBrowserTabsRemoteAutostart(bool* aResult)
+{
+  *aResult = BrowserTabsRemoteAutostart();
+  return NS_OK;
+}
+
 NS_IMETHODIMP
 nsXULAppInfo::EnsureContentProcess()
 {
   if (XRE_GetProcessType() != GeckoProcessType_Default)
     return NS_ERROR_NOT_AVAILABLE;
 
   nsRefPtr<ContentParent> unused = ContentParent::GetNewOrUsed();
   return NS_OK;
@@ -4420,16 +4430,28 @@ mozilla::BrowserTabsRemote()
   if (!gBrowserTabsRemoteInitialized) {
     gBrowserTabsRemote = Preferences::GetBool("browser.tabs.remote", false);
     gBrowserTabsRemoteInitialized = true;
   }
 
   return gBrowserTabsRemote;
 }
 
+bool
+mozilla::BrowserTabsRemoteAutostart()
+{
+  if (!gBrowserTabsRemoteAutostartInitialized) {
+    gBrowserTabsRemoteAutostart = !gSafeMode &&
+                                  Preferences::GetBool("browser.tabs.remote.autostart", false);
+    gBrowserTabsRemoteAutostartInitialized = true;
+  }
+
+  return gBrowserTabsRemoteAutostart;
+}
+
 void
 SetupErrorHandling(const char* progname)
 {
 #ifdef XP_WIN
   /* On Windows XPSP3 and Windows Vista if DEP is configured off-by-default
      we still want DEP protection: enable it explicitly and programmatically.
      
      This function is not available on WinXPSP2 so we dynamically load it.
--- a/toolkit/xre/nsXREDirProvider.cpp
+++ b/toolkit/xre/nsXREDirProvider.cpp
@@ -14,16 +14,17 @@
 #include "nsIAddonInterposition.h"
 #include "nsIAppStartup.h"
 #include "nsIDirectoryEnumerator.h"
 #include "nsIFile.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsISimpleEnumerator.h"
 #include "nsIToolkitChromeRegistry.h"
+#include "nsIXULRuntime.h"
 
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsXULAppAPI.h"
 #include "nsCategoryManagerUtils.h"
 
 #include "nsINIParser.h"
@@ -538,17 +539,17 @@ nsXREDirProvider::GetFiles(const char* a
     return rv;
 
   return NS_SUCCESS_AGGREGATE_RESULT;
 }
 
 static void
 RegisterExtensionInterpositions(nsINIParser &parser)
 {
-  if (!mozilla::Preferences::GetBool("browser.tabs.remote.autostart", false))
+  if (!mozilla::BrowserTabsRemoteAutostart())
     return;
 
   nsCOMPtr<nsIAddonInterposition> interposition =
     do_GetService("@mozilla.org/addons/multiprocess-shims;1");
 
   nsresult rv;
   int32_t i = 0;
   do {
--- a/xpcom/system/nsIXULRuntime.idl
+++ b/xpcom/system/nsIXULRuntime.idl
@@ -4,28 +4,33 @@
 
 #include "nsISupports.idl"
 
 %{C++
 
 namespace mozilla {
 // Simple C++ getter for nsIXULRuntime::browserTabsRemote
 bool BrowserTabsRemote();
+// Simple C++ getter for nsIXULRuntime::browserTabsRemoteAutostart
+// This getter is a temporary function that checks for special
+// conditions in which e10s support is not great yet, and should
+// therefore be disabled. Bug 1065561 tracks its removal.
+bool BrowserTabsRemoteAutostart();
 }
 
 %}
 
 /**
  * Provides information about the XUL runtime.
  * @status UNSTABLE - This interface is not frozen and will probably change in
  *                    future releases. If you need this functionality to be
  *                    stable/frozen, please contact Benjamin Smedberg.
  */
 
-[scriptable, uuid(e080b1f6-8452-4bde-9368-c795808b86d1)]
+[scriptable, uuid(e652d3b8-c77c-4601-a84d-b0716d2b32c0)]
 interface nsIXULRuntime : nsISupports
 {
   /**
    * Whether the application was launched in safe mode.
    */
   readonly attribute boolean inSafeMode;
 
   /**
@@ -84,16 +89,22 @@ interface nsIXULRuntime : nsISupports
 
   /**
    * If true, browser tabs may be opened in a different process from the main
    * browser UI.
    */
   readonly attribute boolean browserTabsRemote;
 
   /**
+   * If true, browser tabs may be opened by default in a different process
+   * from the main browser UI.
+   */
+  readonly attribute boolean browserTabsRemoteAutostart;
+
+  /**
    * Signal the apprunner to invalidate caches on the next restart.
    * This will cause components to be autoregistered and all
    * fastload data to be re-created.
    */
   void invalidateCachesOnRestart();
 
   /**
    * Starts a child process. This method is intented to pre-start a
--- a/xpfe/appshell/src/nsAppShellService.cpp
+++ b/xpfe/appshell/src/nsAppShellService.cpp
@@ -7,16 +7,17 @@
 #include "nsIAppShellService.h"
 #include "nsIComponentManager.h"
 #include "nsIURL.h"
 #include "nsNetUtil.h"
 #include "nsIServiceManager.h"
 #include "nsIObserverService.h"
 #include "nsIObserver.h"
 #include "nsIXPConnect.h"
+#include "nsIXULRuntime.h"
 
 #include "nsIWindowMediator.h"
 #include "nsIWindowWatcher.h"
 #include "nsPIWindowWatcher.h"
 #include "nsIDOMWindow.h"
 #include "nsPIDOMWindow.h"
 #include "nsWebShellWindow.h"
 
@@ -602,18 +603,17 @@ nsAppShellService::JustCreateTopWindow(n
                                    aUrl, aInitialWidth, aInitialHeight,
                                    aIsHiddenWindow, aOpeningTab, widgetInitData);
 
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Enforce the Private Browsing autoStart pref first.
   bool isPrivateBrowsingWindow =
     Preferences::GetBool("browser.privatebrowsing.autostart");
-  bool isUsingRemoteTabs =
-    Preferences::GetBool("browser.tabs.remote.autostart");
+  bool isUsingRemoteTabs = mozilla::BrowserTabsRemoteAutostart();
 
   if (aChromeMask & nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW) {
     // Caller requested a private window
     isPrivateBrowsingWindow = true;
   }
   if (aChromeMask & nsIWebBrowserChrome::CHROME_REMOTE_WINDOW) {
     isUsingRemoteTabs = true;
   }