Bug 1450293 - Avoid starting the GPU process for the initial navigator:blank window, r=jimm.
authorFlorian Quèze <florian@queze.net>
Mon, 16 Apr 2018 23:15:05 +0200
changeset 467524 50091ebf491862711c143ae5dfbbd26000103eb9
parent 467523 f46b5589e6039eb12f9b750bb1f6fd4cd5699c22
child 467525 515bfde909c6b8345709b55d467ea9c18d145847
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1450293
milestone61.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 1450293 - Avoid starting the GPU process for the initial navigator:blank window, r=jimm.
browser/components/nsBrowserGlue.js
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
widget/windows/nsWindowGfx.cpp
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -59,25 +59,26 @@ ChromeUtils.import("resource://gre/modul
     docElt.setAttribute("height", height);
     docElt.setAttribute("width", width);
   } else {
     // Setting the size of the window in the features string instead of here
     // causes the window to grow by the size of the titlebar.
     win.resizeTo(width, height);
   }
 
+  // Set this before showing the window so that graphics code can use it to
+  // decide to skip some expensive code paths (eg. starting the GPU process).
+  docElt.setAttribute("windowtype", "navigator:blank");
+
   // The window becomes visible after OnStopRequest, so make this happen now.
   win.stop();
 
   let { TelemetryTimestamps } =
     ChromeUtils.import("resource://gre/modules/TelemetryTimestamps.jsm", {});
   TelemetryTimestamps.add("blankWindowShown");
-
-  // Used in nsBrowserContentHandler.js to close unwanted blank windows.
-  docElt.setAttribute("windowtype", "navigator:blank");
 })();
 
 Cu.importGlobalProperties(["fetch"]);
 
 XPCOMUtils.defineLazyServiceGetter(this, "WindowsUIUtils", "@mozilla.org/windows-ui-utils;1", "nsIWindowsUIUtils");
 XPCOMUtils.defineLazyGetter(this, "WeaveService", () =>
   Cc["@mozilla.org/weave/service;1"].getService().wrappedJSObject
 );
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -606,16 +606,17 @@ nsWindow::nsWindow(bool aIsChildWindow)
   mDisplayPanFeedback   = false;
   mTouchWindow          = false;
   mFutureMarginsToUse   = false;
   mCustomNonClient      = false;
   mHideChrome           = false;
   mFullscreenMode       = false;
   mMousePresent         = false;
   mDestroyCalled        = false;
+  mIsEarlyBlankWindow   = false;
   mHasTaskbarIconBeenCreated = false;
   mMouseTransparent     = false;
   mPickerDisplayCount   = 0;
   mWindowType           = eWindowType_child;
   mBorderStyle          = eBorderStyle_default;
   mOldSizeMode          = nsSizeMode_Normal;
   mLastSizeMode         = nsSizeMode_Normal;
   mLastSize.width       = 0;
@@ -4097,16 +4098,22 @@ nsWindow::AddWindowOverlayWebRenderComma
 }
 
 uint32_t
 nsWindow::GetMaxTouchPoints() const
 {
   return WinUtils::GetMaxTouchPoints();
 }
 
+void
+nsWindow::SetWindowClass(const nsAString& xulWinType)
+{
+  mIsEarlyBlankWindow = xulWinType.EqualsLiteral("navigator:blank");
+}
+
 /**************************************************************
  **************************************************************
  **
  ** BLOCK: Moz Events
  **
  ** Moz GUI event management. 
  **
  **************************************************************
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -218,16 +218,17 @@ public:
   virtual void            UpdateOpaqueRegion(const LayoutDeviceIntRegion& aOpaqueRegion) override;
 #endif // MOZ_XUL
   virtual nsresult        SetNonClientMargins(LayoutDeviceIntMargin& aMargins) override;
   void                    SetDrawsInTitlebar(bool aState) override;
   virtual void            UpdateWindowDraggingRegion(const LayoutDeviceIntRegion& aRegion) override;
 
   virtual void            UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) override;
   virtual uint32_t        GetMaxTouchPoints() const override;
+  virtual void            SetWindowClass(const nsAString& xulWinType) override;
 
   /**
    * Event helpers
    */
   virtual bool            DispatchMouseEvent(
                             mozilla::EventMessage aEventMessage,
                             WPARAM wParam,
                             LPARAM lParam,
@@ -543,16 +544,17 @@ protected:
   bool                  mTouchWindow;
   bool                  mDisplayPanFeedback;
   bool                  mHideChrome;
   bool                  mIsRTL;
   bool                  mFullscreenMode;
   bool                  mMousePresent;
   bool                  mDestroyCalled;
   bool                  mOpeningAnimationSuppressed;
+  bool                  mIsEarlyBlankWindow;
   uint32_t              mBlurSuppressLevel;
   DWORD_PTR             mOldStyle;
   DWORD_PTR             mOldExStyle;
   nsNativeDragTarget*   mNativeDragTarget;
   HKL                   mLastKeyboardLayout;
   nsSizeMode            mOldSizeMode;
   nsSizeMode            mLastSizeMode;
   WindowHook            mWindowHook;
--- a/widget/windows/nsWindowGfx.cpp
+++ b/widget/windows/nsWindowGfx.cpp
@@ -216,16 +216,21 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t
       // could fail. Return without asserting since it's not our fault.
       NS_WARNING("Plugin failed to subclass our window");
     }
 
     ValidateRect(mWnd, nullptr);
     return true;
   }
 
+  // Avoid starting the GPU process for the initial navigator:blank window.
+  if (mIsEarlyBlankWindow) {
+    return true;
+  }
+
   if (GetLayerManager()->AsKnowsCompositor() && !mBounds.IsEqualEdges(mLastPaintBounds)) {
     // Do an early async composite so that we at least have something on the
     // screen in the right place, even if the content is out of date.
     GetLayerManager()->ScheduleComposite();
   }
   mLastPaintBounds = mBounds;
 
   PAINTSTRUCT ps;