Bug 1519546, part 2 - Make BrowserBridgeParent more robust. r=farre
authorRyan Hunt <rhunt@eqrion.net>
Thu, 16 May 2019 09:32:34 -0500
changeset 476551 1ba5519d5970dde2c36c17ef15475cd043212885
parent 476550 2ced46502b550e82b1d3e8a5abc3580b9954c2bc
child 476552 b186cb12283e5293e98e21b1cb0d4ca6fcdb0776
push id113291
push userrhunt@eqrion.net
push dateSun, 02 Jun 2019 16:51:17 +0000
treeherdermozilla-inbound@ac0ad5d8e9a5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfarre
bugs1519546
milestone69.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 1519546, part 2 - Make BrowserBridgeParent more robust. r=farre This commit adds two small fixes to make the OOP-iframe code more robust. The first fixes a crash during shutdown for a tab that has OOP-iframes. It's possible for the BrowserBridgeParent's to be shutdown before the root BrowserParent. In this case, SetOwnerElement will run for the root BrowserParent, but the child BrowserBridgeParent's will not have BrowserParent actors. The second hooks up the BrowserBridgeParent constructor to actually use the result code of BrowserBridgeParent::Init. Differential Revision: https://phabricator.services.mozilla.com/D31477
dom/ipc/BrowserParent.cpp
--- a/dom/ipc/BrowserParent.cpp
+++ b/dom/ipc/BrowserParent.cpp
@@ -528,17 +528,19 @@ void BrowserParent::SetOwnerElement(Elem
 
   // Set our BrowsingContext's embedder if we're not embedded within a
   // BrowserBridgeParent.
   if (!GetBrowserBridgeParent() && mBrowsingContext && mFrameElement) {
     mBrowsingContext->SetEmbedderElement(mFrameElement);
   }
 
   VisitChildren([aElement](BrowserBridgeParent* aBrowser) {
-    aBrowser->GetBrowserParent()->SetOwnerElement(aElement);
+    if (auto* browserParent = aBrowser->GetBrowserParent()) {
+      browserParent->SetOwnerElement(aElement);
+    }
   });
 }
 
 void BrowserParent::CacheFrameLoader(nsFrameLoader* aFrameLoader) {
   mFrameLoader = aFrameLoader;
 }
 
 void BrowserParent::AddWindowListeners() {
@@ -1221,19 +1223,22 @@ bool BrowserParent::DeallocPWindowGlobal
   static_cast<WindowGlobalParent*>(aActor)->Release();
   return true;
 }
 
 IPCResult BrowserParent::RecvPBrowserBridgeConstructor(
     PBrowserBridgeParent* aActor, const nsString& aName,
     const nsString& aRemoteType, BrowsingContext* aBrowsingContext,
     const uint32_t& aChromeFlags) {
-  static_cast<BrowserBridgeParent*>(aActor)->Init(
+  nsresult rv = static_cast<BrowserBridgeParent*>(aActor)->Init(
       aName, aRemoteType, CanonicalBrowsingContext::Cast(aBrowsingContext),
       aChromeFlags);
+  if (NS_FAILED(rv)) {
+    return IPC_FAIL(this, "Failed to construct BrowserBridgeParent");
+  }
   return IPC_OK();
 }
 
 PBrowserBridgeParent* BrowserParent::AllocPBrowserBridgeParent(
     const nsString& aName, const nsString& aRemoteType,
     BrowsingContext* aBrowsingContext, const uint32_t& aChromeFlags) {
   // Reference freed in DeallocPBrowserBridgeParent.
   return do_AddRef(new BrowserBridgeParent()).take();