Bug 974007 - Change OMTC behavior when browser.tabs.remote is set (r=mattwoodrow,felipe)
authorBill McCloskey <wmccloskey@mozilla.com>
Thu, 20 Feb 2014 17:26:41 -0800
changeset 169783 59a30471542b3ab88418b487972d78f093d34565
parent 169782 673a7e313372f3bf247e76199cbec5a0cf383fe0
child 169784 9b14f95eac89c4ee0ef38057a1c142f6ef46a148
push id40066
push userwmccloskey@mozilla.com
push dateFri, 21 Feb 2014 01:26:52 +0000
treeherdermozilla-inbound@59a30471542b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow, felipe
bugs974007
milestone30.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 974007 - Change OMTC behavior when browser.tabs.remote is set (r=mattwoodrow,felipe)
browser/app/profile/firefox.js
browser/base/content/browser.js
gfx/thebes/gfxPlatform.cpp
widget/nsWidgetInitData.h
widget/xpwidgets/nsBaseWidget.cpp
widget/xpwidgets/nsBaseWidget.h
xpfe/appshell/src/nsAppShellService.cpp
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -972,21 +972,21 @@ pref("toolbar.customization.usesheet", f
 #ifdef XP_MACOSX
 // On mac, the default pref is per-architecture
 pref("dom.ipc.plugins.enabled.i386", true);
 pref("dom.ipc.plugins.enabled.x86_64", true);
 #else
 pref("dom.ipc.plugins.enabled", true);
 #endif
 
-#if defined(NIGHTLY_BUILD) && defined(XP_MACOSX)
-// In Nightly, browser.tabs.remote is enabled on platforms that
-// support OMTC. However, users won't actually get remote tabs unless
-// they enable browser.tabs.remote.autostart or they use the "New OOP
-// Window" menu option.
+#if defined(NIGHTLY_BUILD)
+// browser.tabs.remote is enabled on nightly. However, users won't
+// actually get remote tabs unless they enable
+// browser.tabs.remote.autostart or they use the "New OOP Window" menu
+// option.
 pref("browser.tabs.remote", true);
 #else
 pref("browser.tabs.remote", false);
 #endif
 pref("browser.tabs.remote.autostart", false);
 
 // This pref governs whether we attempt to work around problems caused by
 // plugins using OS calls to manipulate the cursor while running out-of-
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -3192,17 +3192,22 @@ function OpenBrowserWindow(options)
       // Force the new window to load about:privatebrowsing instead of the default home page
       defaultArgs = "about:privatebrowsing";
     }
   } else {
     extraFeatures = ",non-private";
   }
 
   if (options && options.remote) {
-    extraFeatures += ",remote";
+    let omtcEnabled = gPrefService.getBoolPref("layers.offmainthreadcomposition.enabled");
+    if (!omtcEnabled) {
+      alert("To use out-of-process tabs, you must set the layers.offmainthreadcomposition.enabled preference and restart. Opening a normal window instead.");
+    } else {
+      extraFeatures += ",remote";
+    }
   } else if (options && options.remote === false) {
     extraFeatures += ",non-remote";
   }
 
   // if and only if the current window is a browser window and it has a document with a character
   // set, then extract the current charset menu setting from the current document and use it to
   // initialize the new browser window...
   var win;
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -2076,17 +2076,17 @@ static bool sPrefLayersDrawFPS = false;
 static bool sPrefLayersDump = false;
 static bool sPrefLayersScrollGraph = false;
 static bool sPrefLayersEnableTiles = false;
 static bool sLayersSupportsD3D9 = false;
 static int  sPrefLayoutFrameRate = -1;
 static int  sPrefLayersCompositionFrameRate = -1;
 static bool sBufferRotationEnabled = false;
 static bool sComponentAlphaEnabled = true;
-static bool sPrefBrowserTabsRemote = false;
+static bool sPrefBrowserTabsRemoteAutostart = false;
 
 static bool sLayersAccelerationPrefsInitialized = false;
 
 void
 InitLayersAccelerationPrefs()
 {
   if (!sLayersAccelerationPrefsInitialized)
   {
@@ -2106,17 +2106,17 @@ InitLayersAccelerationPrefs()
     sPrefLayersDrawFPS = Preferences::GetBool("layers.acceleration.draw-fps", false);
     sPrefLayersDump = Preferences::GetBool("layers.dump", false);
     sPrefLayersScrollGraph = Preferences::GetBool("layers.scroll-graph", false);
     sPrefLayersEnableTiles = Preferences::GetBool("layers.enable-tiles", false);
     sPrefLayoutFrameRate = Preferences::GetInt("layout.frame_rate", -1);
     sPrefLayersCompositionFrameRate = Preferences::GetInt("layers.offmainthreadcomposition.frame-rate", -1);
     sBufferRotationEnabled = Preferences::GetBool("layers.bufferrotation.enabled", true);
     sComponentAlphaEnabled = Preferences::GetBool("layers.componentalpha.enabled", true);
-    sPrefBrowserTabsRemote = BrowserTabsRemote();
+    sPrefBrowserTabsRemoteAutostart = Preferences::GetBool("browser.tabs.remote.autostart", false);
 
 #ifdef XP_WIN
     if (sPrefLayersAccelerationForceEnabled) {
       sLayersSupportsD3D9 = true;
     } else {
       nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
       if (gfxInfo) {
         int32_t status;
@@ -2156,20 +2156,20 @@ gfxPlatform::GetPrefLayersAccelerationFo
   return sPrefLayersAccelerationForceEnabled;
 }
 
 bool gfxPlatform::OffMainThreadCompositionRequired()
 {
   InitLayersAccelerationPrefs();
 #if defined(MOZ_WIDGET_GTK) && defined(NIGHTLY_BUILD)
   // Linux users who chose OpenGL are being grandfathered in to OMTC
-  return sPrefBrowserTabsRemote ||
+  return sPrefBrowserTabsRemoteAutostart ||
          sPrefLayersAccelerationForceEnabled;
 #else
-  return sPrefBrowserTabsRemote;
+  return sPrefBrowserTabsRemoteAutostart;
 #endif
 }
 
 bool
 gfxPlatform::GetPrefLayersAccelerationDisabled()
 {
   InitLayersAccelerationPrefs();
   return sPrefLayersAccelerationDisabled;
--- a/widget/nsWidgetInitData.h
+++ b/widget/nsWidgetInitData.h
@@ -97,17 +97,18 @@ struct nsWidgetInitData {
       mDropShadow(false),
       mListenForResizes(false),
       mUnicode(true),
       mRTL(false),
       mNoAutoHide(false),
       mIsDragPopup(false),
       mIsAnimationSuppressed(false),
       mSupportTranslucency(false),
-      mMouseTransparent(false)
+      mMouseTransparent(false),
+      mRequireOffMainThreadCompositing(false)
   {
   }
 
   nsWindowType  mWindowType;
   nsBorderStyle mBorderStyle;
   nsPopupType   mPopupHint;
   nsPopupLevel  mPopupLevel;
   // when painting exclude area occupied by child windows and sibling windows
@@ -119,11 +120,14 @@ struct nsWidgetInitData {
   bool          mIsDragPopup;  // true for drag feedback panels
   // true if window creation animation is suppressed, e.g. for session restore
   bool          mIsAnimationSuppressed;
   // true if the window should support an alpha channel, if available.
   bool          mSupportTranslucency;
   // true if the window should be transparent to mouse events. Currently this is
   // only valid for eWindowType_popup widgets
   bool          mMouseTransparent;
+  // Windows with out-of-process tabs always require OMTC. This flag designates
+  // such windows.
+  bool          mRequireOffMainThreadCompositing;
 };
 
 #endif // nsWidgetInitData_h__
--- a/widget/xpwidgets/nsBaseWidget.cpp
+++ b/widget/xpwidgets/nsBaseWidget.cpp
@@ -261,16 +261,17 @@ void nsBaseWidget::BaseCreate(nsIWidget 
     mContext->Init(nullptr);
   }
 
   if (nullptr != aInitData) {
     mWindowType = aInitData->mWindowType;
     mBorderStyle = aInitData->mBorderStyle;
     mPopupLevel = aInitData->mPopupLevel;
     mPopupType = aInitData->mPopupHint;
+    mRequireOffMainThreadCompositing = aInitData->mRequireOffMainThreadCompositing;
   }
 
   if (aParent) {
     aParent->AddChild(this);
   }
 }
 
 NS_IMETHODIMP nsBaseWidget::CaptureMouse(bool aCapture)
@@ -937,18 +938,17 @@ nsBaseWidget::GetPreferredCompositorBack
   aHints.AppendElement(LayersBackend::LAYERS_BASIC);
 }
 
 static void
 CheckForBasicBackends(nsTArray<LayersBackend>& aHints)
 {
   for (size_t i = 0; i < aHints.Length(); ++i) {
     if (aHints[i] == LayersBackend::LAYERS_BASIC &&
-        !Preferences::GetBool("layers.offmainthreadcomposition.force-basic", false) &&
-        !BrowserTabsRemote()) {
+        !Preferences::GetBool("layers.offmainthreadcomposition.force-basic", false)) {
       // basic compositor is not stable enough for regular use
       aHints[i] = LayersBackend::LAYERS_NONE;
     }
   }
 }
 
 void nsBaseWidget::CreateCompositor(int aWidth, int aHeight)
 {
@@ -971,17 +971,19 @@ void nsBaseWidget::CreateCompositor(int 
   mCompositorChild = new CompositorChild(lm);
   mCompositorChild->Open(parentChannel, childMessageLoop, ipc::ChildSide);
 
   TextureFactoryIdentifier textureFactoryIdentifier;
   PLayerTransactionChild* shadowManager;
   nsTArray<LayersBackend> backendHints;
   GetPreferredCompositorBackends(backendHints);
 
-  CheckForBasicBackends(backendHints);
+  if (!mRequireOffMainThreadCompositing) {
+    CheckForBasicBackends(backendHints);
+  }
 
   bool success = false;
   if (!backendHints.IsEmpty()) {
     shadowManager = mCompositorChild->SendPLayerTransactionConstructor(
       backendHints, 0, &textureFactoryIdentifier, &success);
   }
 
   if (success) {
--- a/widget/xpwidgets/nsBaseWidget.h
+++ b/widget/xpwidgets/nsBaseWidget.h
@@ -404,16 +404,19 @@ protected:
   nscolor           mBackground;
   nscolor           mForeground;
   nsCursor          mCursor;
   nsWindowType      mWindowType;
   nsBorderStyle     mBorderStyle;
   bool              mUseLayersAcceleration;
   bool              mForceLayersAcceleration;
   bool              mTemporarilyUseBasicLayerManager;
+  // Windows with out-of-process tabs always require OMTC. This flag designates
+  // such windows.
+  bool              mRequireOffMainThreadCompositing;
   bool              mUseAttachedEvents;
   bool              mContextInitialized;
   nsIntRect         mBounds;
   nsIntRect*        mOriginalBounds;
   // When this pointer is null, the widget is not clipped
   nsAutoArrayPtr<nsIntRect> mClipRects;
   uint32_t          mClipRectCount;
   int32_t           mZIndex;
--- a/xpfe/appshell/src/nsAppShellService.cpp
+++ b/xpfe/appshell/src/nsAppShellService.cpp
@@ -516,16 +516,19 @@ nsAppShellService::JustCreateTopWindow(n
       eWindowType_dialog : eWindowType_toplevel;
 
   if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_POPUP)
     widgetInitData.mWindowType = eWindowType_popup;
 
   if (aChromeMask & nsIWebBrowserChrome::CHROME_MAC_SUPPRESS_ANIMATION)
     widgetInitData.mIsAnimationSuppressed = true;
 
+  if (aChromeMask & nsIWebBrowserChrome::CHROME_REMOTE_WINDOW)
+    widgetInitData.mRequireOffMainThreadCompositing = true;
+
 #ifdef XP_MACOSX
   // Mac OS X sheet support
   // Adding CHROME_OPENAS_CHROME to sheetMask makes modal windows opened from
   // nsGlobalWindow::ShowModalDialog() be dialogs (not sheets), while modal
   // windows opened from nsPromptService::DoDialog() still are sheets.  This
   // fixes bmo bug 395465 (see nsCocoaWindow::StandardCreate() and
   // nsCocoaWindow::SetModal()).
   uint32_t sheetMask = nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |