Bug 1525427 - Part 4: Correctly tear down TabParent within BrowserBridgeParent, r=farre
authorNika Layzell <nika@thelayzells.com>
Wed, 17 Apr 2019 00:52:53 +0000
changeset 469822 6e450526cf26fa9149e5159fa83b55712c5713e6
parent 469821 de746bd4957fc9e6fe68c8ab2630bbdf95391398
child 469823 a930e5a3d8aeb5b18623e54d1ed476cc77cbdd69
push id35883
push userbtara@mozilla.com
push dateWed, 17 Apr 2019 21:47:29 +0000
treeherdermozilla-central@02b89c29412b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfarre
bugs1525427
milestone68.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 1525427 - Part 4: Correctly tear down TabParent within BrowserBridgeParent, r=farre Differential Revision: https://phabricator.services.mozilla.com/D25184
dom/ipc/BrowserBridgeParent.cpp
dom/ipc/BrowserBridgeParent.h
dom/ipc/TabParent.cpp
--- a/dom/ipc/BrowserBridgeParent.cpp
+++ b/dom/ipc/BrowserBridgeParent.cpp
@@ -14,21 +14,17 @@ using namespace mozilla::ipc;
 using namespace mozilla::layout;
 using namespace mozilla::hal;
 
 namespace mozilla {
 namespace dom {
 
 BrowserBridgeParent::BrowserBridgeParent() : mIPCOpen(false) {}
 
-BrowserBridgeParent::~BrowserBridgeParent() {
-  if (mTabParent) {
-    mTabParent->mBrowserBridgeParent = nullptr;
-  }
-}
+BrowserBridgeParent::~BrowserBridgeParent() { Destroy(); }
 
 nsresult BrowserBridgeParent::Init(const nsString& aPresentationURL,
                                    const nsString& aRemoteType,
                                    CanonicalBrowsingContext* aBrowsingContext,
                                    const uint32_t& aChromeFlags) {
   mIPCOpen = true;
 
   // FIXME: This should actually use a non-bogus TabContext, probably inherited
@@ -98,16 +94,22 @@ nsresult BrowserBridgeParent::Init(const
     return NS_ERROR_FAILURE;
   }
 
   // Send the newly created layers ID back into content.
   Unused << SendSetLayersId(rf->GetLayersId());
   return NS_OK;
 }
 
+void BrowserBridgeParent::Destroy() {
+  if (mTabParent) {
+    mTabParent->Destroy();
+  }
+}
+
 IPCResult BrowserBridgeParent::RecvShow(const ScreenIntSize& aSize,
                                         const bool& aParentIsActive,
                                         const nsSizeMode& aSizeMode) {
   RenderFrame* rf = mTabParent->GetRenderFrame();
   if (!rf->AttachLayerManager()) {
     MOZ_CRASH();
   }
 
@@ -147,12 +149,13 @@ IPCResult BrowserBridgeParent::RecvActiv
 
 IPCResult BrowserBridgeParent::RecvDeactivate() {
   mTabParent->Deactivate();
   return IPC_OK();
 }
 
 void BrowserBridgeParent::ActorDestroy(ActorDestroyReason aWhy) {
   mIPCOpen = false;
+  Destroy();
 }
 
 }  // namespace dom
 }  // namespace mozilla
--- a/dom/ipc/BrowserBridgeParent.h
+++ b/dom/ipc/BrowserBridgeParent.h
@@ -31,16 +31,19 @@ class BrowserBridgeParent : public PBrow
   }
 
   // Get our manager actor.
   TabParent* Manager() {
     MOZ_ASSERT(mIPCOpen);
     return static_cast<TabParent*>(PBrowserBridgeParent::Manager());
   }
 
+  // Tear down this BrowserBridgeParent.
+  void Destroy();
+
  protected:
   friend class PBrowserBridgeParent;
 
   mozilla::ipc::IPCResult RecvShow(const ScreenIntSize& aSize,
                                    const bool& aParentIsActive,
                                    const nsSizeMode& aSizeMode);
   mozilla::ipc::IPCResult RecvLoadURL(const nsCString& aUrl);
   mozilla::ipc::IPCResult RecvUpdateDimensions(
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -412,16 +412,18 @@ void TabParent::DestroyInternal() {
   SetIsActiveRecordReplayTab(false);
 }
 
 void TabParent::Destroy() {
   // Aggressively release the window to avoid leaking the world in shutdown
   // corner cases.
   mBrowserDOMWindow = nullptr;
 
+  mBrowserBridgeParent = nullptr;
+
   if (mIsDestroyed) {
     return;
   }
 
   DestroyInternal();
 
   mIsDestroyed = true;