Bug 1503655 part 4 - Don't call TabChild::InitRenderingState from DoFakeShow. r=kats
authorRyan Hunt <rhunt@eqrion.net>
Mon, 05 Nov 2018 13:21:35 -0600
changeset 504002 354f7613146718d11546ceb27c6e8552f15f3b5b
parent 504001 2ab481124e1aef887083b5076029974db8294f59
child 504003 0f2975053d03d889b28e699e6160f57e3c8eb624
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1503655
milestone65.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 1503655 part 4 - Don't call TabChild::InitRenderingState from DoFakeShow. r=kats We should just have the parent handle initialization here. This lets us cut down on the information we have to pipe around and simplifies our amount of code paths. Differential Revision: https://phabricator.services.mozilla.com/D11060
dom/browser-element/BrowserElementParent.cpp
dom/browser-element/BrowserElementParent.h
dom/ipc/ContentChild.cpp
dom/ipc/ContentParent.cpp
dom/ipc/DOMTypes.ipdlh
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
dom/ipc/TabParent.cpp
--- a/dom/browser-element/BrowserElementParent.cpp
+++ b/dom/browser-element/BrowserElementParent.cpp
@@ -174,20 +174,17 @@ BrowserElementParent::DispatchOpenWindow
 }
 
 /*static*/
 BrowserElementParent::OpenWindowResult
 BrowserElementParent::OpenWindowOOP(TabParent* aOpenerTabParent,
                                     TabParent* aPopupTabParent,
                                     const nsAString& aURL,
                                     const nsAString& aName,
-                                    const nsAString& aFeatures,
-                                    TextureFactoryIdentifier* aTextureFactoryIdentifier,
-                                    layers::LayersId* aLayersId,
-                                    layers::CompositorOptions* aCompositorOptions)
+                                    const nsAString& aFeatures)
 {
   // Create an iframe owned by the same document which owns openerFrameElement.
   nsCOMPtr<Element> openerFrameElement = aOpenerTabParent->GetOwnerElement();
   NS_ENSURE_TRUE(openerFrameElement,
                  BrowserElementParent::OPEN_WINDOW_IGNORED);
   RefPtr<HTMLIFrameElement> popupFrameElement =
     CreateIframe(openerFrameElement, aName, /* aRemote = */ true);
 
@@ -212,18 +209,17 @@ BrowserElementParent::OpenWindowOOP(TabP
   }
 
   // The popup was not blocked, so hook up the frame element and the popup tab
   // parent, and return success.
   aPopupTabParent->SetOwnerElement(popupFrameElement);
   popupFrameElement->AllowCreateFrameLoader();
   popupFrameElement->CreateRemoteFrameLoader(aPopupTabParent);
 
-  if (!aPopupTabParent->SetRenderFrame() ||
-      !aPopupTabParent->GetRenderFrameInfo(aTextureFactoryIdentifier, aLayersId, aCompositorOptions)) {
+  if (!aPopupTabParent->SetRenderFrame()) {
     return BrowserElementParent::OPEN_WINDOW_IGNORED;
   }
 
   return opened;
 }
 
 /* static */
 BrowserElementParent::OpenWindowResult
--- a/dom/browser-element/BrowserElementParent.h
+++ b/dom/browser-element/BrowserElementParent.h
@@ -17,21 +17,16 @@ class nsIDOMWindow;
 class nsIURI;
 
 namespace mozilla {
 
 namespace dom {
 class TabParent;
 } // namespace dom
 
-namespace layers {
-class CompositorOptions;
-struct TextureFactoryIdentifier;
-} // namespace layers
-
 /**
  * BrowserElementParent implements a portion of the parent-process side of
  * <iframe mozbrowser>.
  *
  * Most of the parent-process side of <iframe mozbrowser> is implemented in
  * BrowserElementParent.js.  This file implements the few parts of this
  * functionality which must be written in C++.
  *
@@ -89,20 +84,17 @@ public:
    *         frame to a document and whether it called preventDefault to prevent
    *         the platform from handling the open request.
    */
   static OpenWindowResult
   OpenWindowOOP(dom::TabParent* aOpenerTabParent,
                 dom::TabParent* aPopupTabParent,
                 const nsAString& aURL,
                 const nsAString& aName,
-                const nsAString& aFeatures,
-                layers::TextureFactoryIdentifier* aTextureFactoryIdentifier,
-                layers::LayersId* aLayersId,
-                layers::CompositorOptions* aCompositorOptions);
+                const nsAString& aFeatures);
 
   /**
    * Handle a window.open call from an in-process <iframe mozbrowser>.
    *
    * (These parameter types are silly, but they match what our caller has in
    * hand.  Feel free to add an override, if they are inconvenient to you.)
    *
    * @param aURI the URI the new window should load.  May be null.
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -967,17 +967,16 @@ ContentChild::ProvideWindowCommon(TabChi
 
   Unused << SendPBrowserConstructor(
     // We release this ref in DeallocPBrowserChild
     RefPtr<TabChild>(newChild).forget().take(),
     tabId, TabId(0), *ipcContext, aChromeFlags,
     GetID(), IsForBrowser());
 
   newChild->SendCreatePRenderFrame();
-  bool hasRenderFrame = true;
 
   nsCOMPtr<nsPIDOMWindowInner> parentTopInnerWindow;
   if (aParent) {
     nsCOMPtr<nsPIDOMWindowOuter> parentTopWindow =
       nsPIDOMWindowOuter::From(aParent)->GetTop();
     if (parentTopWindow) {
       parentTopInnerWindow = parentTopWindow->GetCurrentInnerWindow();
     }
@@ -989,19 +988,16 @@ ContentChild::ProvideWindowCommon(TabChi
   // NOTE: Capturing by reference here is safe, as this function won't return
   // until one of these callbacks is called.
   auto resolve = [&] (const CreatedWindowInfo& info) {
     MOZ_RELEASE_ASSERT(NS_IsMainThread());
     rv = info.rv();
     *aWindowIsNew = info.windowOpened();
     nsTArray<FrameScriptInfo> frameScripts(info.frameScripts());
     nsCString urlToLoad = info.urlToLoad();
-    TextureFactoryIdentifier textureFactoryIdentifier = info.textureFactoryIdentifier();
-    layers::LayersId layersId = info.layersId();
-    CompositorOptions compositorOptions = info.compositorOptions();
     uint32_t maxTouchPoints = info.maxTouchPoints();
     DimensionInfo dimensionInfo = info.dimensions();
     bool hasSiblings = info.hasSiblings();
 
     // Once this function exits, we should try to exit the nested event loop.
     ready = true;
 
     // NOTE: We have to handle this immediately in the resolve callback in order
@@ -1020,20 +1016,16 @@ ContentChild::ProvideWindowCommon(TabChi
     }
 
     // If the TabChild has been torn down, we don't need to do this anymore.
     if (NS_WARN_IF(!newChild->IPCOpen() || newChild->IsDestroyed())) {
       rv = NS_ERROR_ABORT;
       return;
     }
 
-    if (!layersId.IsValid()) {
-      hasRenderFrame = false;
-    }
-
     ShowInfo showInfo(EmptyString(), false, false, true, false, 0, 0, 0);
     auto* opener = nsPIDOMWindowOuter::From(aParent);
     nsIDocShell* openerShell;
     if (opener && (openerShell = opener->GetDocShell())) {
       nsCOMPtr<nsILoadContext> context = do_QueryInterface(openerShell);
       showInfo = ShowInfo(EmptyString(), false,
                           context->UsePrivateBrowsing(), true, false,
                           aTabOpener->WebWidget()->GetDPI(),
@@ -1052,18 +1044,17 @@ ContentChild::ProvideWindowCommon(TabChi
     if (!aForceNoOpener && windowProxy && aParent) {
       nsPIDOMWindowOuter* outer = nsPIDOMWindowOuter::From(windowProxy);
       nsPIDOMWindowOuter* parent = nsPIDOMWindowOuter::From(aParent);
       outer->SetOpenerWindow(parent, *aWindowIsNew);
     }
 
     // Unfortunately we don't get a window unless we've shown the frame.  That's
     // pretty bogus; see bug 763602.
-    newChild->DoFakeShow(textureFactoryIdentifier, layersId, compositorOptions,
-                        hasRenderFrame, showInfo);
+    newChild->DoFakeShow(showInfo);
 
     newChild->RecvUpdateDimensions(dimensionInfo);
 
     for (size_t i = 0; i < frameScripts.Length(); i++) {
       FrameScriptInfo& info = frameScripts[i];
       if (!newChild->RecvLoadRemoteScript(info.url(), info.runInGlobalScope())) {
         MOZ_CRASH();
       }
@@ -1082,17 +1073,16 @@ ContentChild::ProvideWindowCommon(TabChi
   auto reject = [&] (ResponseRejectReason) {
     MOZ_RELEASE_ASSERT(NS_IsMainThread());
     NS_WARNING("windowCreated promise rejected");
     rv = NS_ERROR_NOT_AVAILABLE;
     ready = true;
   };
 
   // Send down the request to open the window.
-  MOZ_ASSERT(hasRenderFrame);
   if (aIframeMoz) {
     MOZ_ASSERT(aTabOpener);
     nsAutoCString url;
     if (aURI) {
       aURI->GetSpec(url);
     } else {
       // We can't actually send a nullptr up as the URI, since IPDL doesn't let us
       // send nullptr's for primitives. We indicate that the nsString for the URI
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -5098,17 +5098,16 @@ ContentParent::RecvCreateWindow(PBrowser
                                 const uint32_t& aReferrerPolicy,
                                 CreateWindowResolver&& aResolve)
 {
   nsresult rv = NS_OK;
   CreatedWindowInfo cwi;
 
   // We always expect to open a new window here. If we don't, it's an error.
   cwi.windowOpened() = true;
-  cwi.layersId() = LayersId{0};
   cwi.maxTouchPoints() = 0;
   cwi.hasSiblings() = false;
 
   // Make sure to resolve the resolver when this function exits, even if we
   // failed to generate a valid response.
   auto resolveOnExit = MakeScopeExit([&] {
     // Copy over the nsresult, and then resolve.
     cwi.rv() = rv;
@@ -5157,18 +5156,17 @@ ContentParent::RecvCreateWindow(PBrowser
 
   if (sNextTabParents.GetAndRemove(nextTabParentId).valueOr(nullptr)) {
     cwi.windowOpened() = false;
   }
   MOZ_ASSERT(TabParent::GetFrom(newRemoteTab) == newTab);
 
   newTab->SwapFrameScriptsFrom(cwi.frameScripts());
 
-  if (!newTab->SetRenderFrame() ||
-      !newTab->GetRenderFrameInfo(&cwi.textureFactoryIdentifier(), &cwi.layersId(), &cwi.compositorOptions())) {
+  if (!newTab->SetRenderFrame()) {
     rv = NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsIWidget> widget = newTab->GetWidget();
   if (widget) {
     cwi.maxTouchPoints() = widget->GetMaxTouchPoints();
     cwi.dimensions() = newTab->GetDimensionInfo();
   }
--- a/dom/ipc/DOMTypes.ipdlh
+++ b/dom/ipc/DOMTypes.ipdlh
@@ -20,19 +20,16 @@ using struct mozilla::SerializedStructur
 using LayoutDeviceIntRect from "Units.h";
 using DesktopIntRect from "Units.h";
 using DesktopToLayoutDeviceScale from "Units.h";
 using CSSToLayoutDeviceScale from "Units.h";
 using CSSRect from "Units.h";
 using CSSSize from "Units.h";
 using mozilla::LayoutDeviceIntPoint from "Units.h";
 using hal::ScreenOrientation from "mozilla/HalScreenConfiguration.h";
-using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h";
-using mozilla::layers::CompositorOptions from "mozilla/layers/CompositorOptions.h";
-using mozilla::layers::LayersId from "mozilla/layers/LayersTypes.h";
 using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h";
 
 
 namespace mozilla {
 namespace dom {
 
 struct MessagePortIdentifier
 {
@@ -115,19 +112,16 @@ struct FrameScriptInfo
  * The information required to complete a window creation request.
  */
 struct CreatedWindowInfo
 {
   nsresult rv;
   bool windowOpened;
   FrameScriptInfo[] frameScripts;
   nsCString urlToLoad;
-  TextureFactoryIdentifier textureFactoryIdentifier;
-  LayersId layersId;
-  CompositorOptions compositorOptions;
   uint32_t maxTouchPoints;
   DimensionInfo dimensions;
   bool hasSiblings;
 };
 
 
 /**
  * PerformanceInfo is used to pass performance info stored
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -1120,24 +1120,18 @@ TabChild::RecvLoadURL(const nsCString& a
   }
 
   CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::URL, aURI);
 
   return IPC_OK();
 }
 
 void
-TabChild::DoFakeShow(const TextureFactoryIdentifier& aTextureFactoryIdentifier,
-                     const layers::LayersId& aLayersId,
-                     const CompositorOptions& aCompositorOptions,
-                     const bool aHasRenderFrame,
-                     const ShowInfo& aShowInfo)
+TabChild::DoFakeShow(const ShowInfo& aShowInfo)
 {
-  mLayersConnected = aHasRenderFrame ? Some(true) : Some(false);
-  InitRenderingState(aTextureFactoryIdentifier, aLayersId, aCompositorOptions, aHasRenderFrame);
   RecvShow(ScreenIntSize(0, 0), aShowInfo, mParentIsActive, nsSizeMode_Normal);
   mDidFakeShow = true;
 }
 
 void
 TabChild::ApplyShowInfo(const ShowInfo& aInfo)
 {
   // Even if we already set real show info, the dpi / rounding & scale may still
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -597,21 +597,17 @@ public:
   }
 
   const mozilla::layers::CompositorOptions& GetCompositorOptions() const;
   bool AsyncPanZoomEnabled() const;
 
   virtual ScreenIntSize GetInnerSize() override;
 
   // Call RecvShow(nsIntSize(0, 0)) and block future calls to RecvShow().
-  void DoFakeShow(const TextureFactoryIdentifier& aTextureFactoryIdentifier,
-                  const layers::LayersId& aLayersId,
-                  const mozilla::layers::CompositorOptions& aCompositorOptions,
-                  const bool aHasRenderFrame,
-                  const ShowInfo& aShowInfo);
+  void DoFakeShow(const ShowInfo& aShowInfo);
 
   void ContentReceivedInputBlock(const ScrollableLayerGuid& aGuid,
                                  uint64_t aInputBlockId,
                                  bool aPreventDefault) const;
   void SetTargetAPZC(uint64_t aInputBlockId,
                     const nsTArray<ScrollableLayerGuid>& aTargets) const;
   MOZ_CAN_RUN_SCRIPT
   mozilla::ipc::IPCResult RecvHandleTap(const layers::GeckoContentController::TapType& aType,
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -2646,16 +2646,23 @@ TabParent::SetRenderFrame()
     return false;
   }
 
   frameLoader->MaybeShowFrame();
 
   layers::LayersId layersId = mRenderFrame->GetLayersId();
   AddTabParentToTable(layersId, this);
 
+  TextureFactoryIdentifier textureFactoryIdentifier;
+  mRenderFrame->GetTextureFactoryIdentifier(&textureFactoryIdentifier);
+  Unused << SendInitRendering(textureFactoryIdentifier, layersId,
+    mRenderFrame->GetCompositorOptions(),
+    mRenderFrame->IsLayersConnected(),
+    true);
+
   return true;
 }
 
 bool
 TabParent::GetRenderFrameInfo(TextureFactoryIdentifier* aTextureFactoryIdentifier,
                               layers::LayersId* aLayersId,
                               layers::CompositorOptions* aCompositorOptions)
 {
@@ -2768,25 +2775,21 @@ mozilla::ipc::IPCResult
 TabParent::RecvBrowserFrameOpenWindow(PBrowserParent* aOpener,
                                       const nsString& aURL,
                                       const nsString& aName,
                                       const nsString& aFeatures,
                                       BrowserFrameOpenWindowResolver&& aResolve)
 {
   CreatedWindowInfo cwi;
   cwi.rv() = NS_OK;
-  cwi.layersId() = LayersId{0};
   cwi.maxTouchPoints() = 0;
 
   BrowserElementParent::OpenWindowResult opened =
     BrowserElementParent::OpenWindowOOP(TabParent::GetFrom(aOpener),
-                                        this, aURL, aName, aFeatures,
-                                        &cwi.textureFactoryIdentifier(),
-                                        &cwi.layersId(),
-                                        &cwi.compositorOptions());
+                                        this, aURL, aName, aFeatures);
   cwi.windowOpened() = (opened == BrowserElementParent::OPEN_WINDOW_ADDED);
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (widget) {
     cwi.maxTouchPoints() = widget->GetMaxTouchPoints();
     cwi.dimensions() = GetDimensionInfo();
   }
 
   // Resolve the request with the information we collected.