Bug 1238707 - Release the window immediately in TabParent::Destroy() to avoid leaks. r=smaug, a=ritu
authorBen Kelly <ben@wanderview.com>
Mon, 04 Apr 2016 14:08:17 -0700
changeset 323866 949a0468e0d4a282a3e344ab5fa21be0634e9456
parent 323865 54b32c56b38f3567068740f27dd06f0161ca62a8
child 323867 35106b95b2d5fb10e1233112a088d0e5d0a5faa4
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, ritu
bugs1238707
milestone47.0a2
Bug 1238707 - Release the window immediately in TabParent::Destroy() to avoid leaks. r=smaug, a=ritu
dom/ipc/ContentParent.cpp
dom/ipc/TabParent.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -5419,17 +5419,17 @@ ContentParent::RecvCreateWindow(PBrowser
                                            aPositionSpecified, aSizeSpecified);
 
   MOZ_ASSERT(openLocation == nsIBrowserDOMWindow::OPEN_NEWTAB ||
              openLocation == nsIBrowserDOMWindow::OPEN_NEWWINDOW);
 
   // Opening new tabs is the easy case...
   if (openLocation == nsIBrowserDOMWindow::OPEN_NEWTAB) {
     if (NS_WARN_IF(!browserDOMWin)) {
-      *aResult = NS_ERROR_FAILURE;
+      *aResult = NS_ERROR_ABORT;
       return true;
     }
 
     bool isPrivate = false;
     if (thisTabParent) {
       nsCOMPtr<nsILoadContext> loadContext = thisTabParent->GetLoadContext();
       loadContext->GetUsePrivateBrowsing(&isPrivate);
     }
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -593,16 +593,20 @@ TabParent::DestroyInternal()
     static_cast<mozilla::plugins::PluginWidgetParent*>(
        iter.Get()->GetKey())->ParentDestroy();
   }
 }
 
 void
 TabParent::Destroy()
 {
+  // Aggressively release the window to avoid leaking the world in shutdown
+  // corner cases.
+  mBrowserDOMWindow = nullptr;
+
   if (mIsDestroyed) {
     return;
   }
 
   DestroyInternal();
 
   mIsDestroyed = true;