Bug 1458999 - Nullcheck for release, assert elsewhere. r=enn, a=RyanVM
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 22 May 2018 21:37:29 +0200
changeset 473527 96eeb9f7e318718bbd01ce04ee019931c354fe57
parent 473526 dbd8df4584c4df1bf4858568918d461aad8b1396
child 473528 7aa58e74173962f26e61191567091afc35202abf
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenn, RyanVM
bugs1458999
milestone61.0
Bug 1458999 - Nullcheck for release, assert elsewhere. r=enn, a=RyanVM This should allow us to figure out what's killing the window mid-flight, in case there's something to fix in the chrome JS code. MozReview-Commit-ID: 1xx1AVdspB2
xpfe/appshell/nsXULWindow.cpp
xpfe/appshell/nsXULWindow.h
--- a/xpfe/appshell/nsXULWindow.cpp
+++ b/xpfe/appshell/nsXULWindow.cpp
@@ -446,16 +446,19 @@ NS_IMETHODIMP nsXULWindow::Create()
 {
   //XXX First Check In
   NS_ASSERTION(false, "Not Yet Implemented");
   return NS_OK;
 }
 
 NS_IMETHODIMP nsXULWindow::Destroy()
 {
+  MOZ_DIAGNOSTIC_ASSERT(!mSyncingAttributesToWidget,
+                        "Destroying the window from SyncAttributesToWidget?");
+
   if (!mWindow)
      return NS_OK;
 
   // Ensure we don't reenter this code
   if (mDestroying)
     return NS_OK;
 
   mozilla::AutoRestore<bool> guard(mDestroying);
@@ -1545,57 +1548,76 @@ void nsXULWindow::StaggerPosition(int32_
 }
 
 void nsXULWindow::SyncAttributesToWidget()
 {
   nsCOMPtr<dom::Element> windowElement = GetWindowDOMElement();
   if (!windowElement)
     return;
 
+  AutoRestore<bool> scope { mSyncingAttributesToWidget };
+  mSyncingAttributesToWidget = true;
+
+  MOZ_DIAGNOSTIC_ASSERT(mWindow, "No widget on SyncAttributesToWidget?");
+
   nsAutoString attr;
 
   // "hidechrome" attribute
   if (windowElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidechrome,
                                  nsGkAtoms::_true, eCaseMatters)) {
     mWindow->HideWindowChrome(true);
   }
 
+  NS_ENSURE_TRUE_VOID(mWindow);
+
   // "chromemargin" attribute
   nsIntMargin margins;
   windowElement->GetAttribute(NS_LITERAL_STRING("chromemargin"), attr);
   if (nsContentUtils::ParseIntMarginValue(attr, margins)) {
     LayoutDeviceIntMargin tmp = LayoutDeviceIntMargin::FromUnknownMargin(margins);
     mWindow->SetNonClientMargins(tmp);
   }
 
+  NS_ENSURE_TRUE_VOID(mWindow);
+
   // "windowtype" attribute
   windowElement->GetAttribute(WINDOWTYPE_ATTRIBUTE, attr);
   if (!attr.IsEmpty()) {
     mWindow->SetWindowClass(attr);
   }
 
+  NS_ENSURE_TRUE_VOID(mWindow);
+
   // "id" attribute for icon
   windowElement->GetAttribute(NS_LITERAL_STRING("id"), attr);
   if (attr.IsEmpty()) {
     attr.AssignLiteral("default");
   }
   mWindow->SetIcon(attr);
 
+  NS_ENSURE_TRUE_VOID(mWindow);
+
   // "drawtitle" attribute
   windowElement->GetAttribute(NS_LITERAL_STRING("drawtitle"), attr);
   mWindow->SetDrawsTitle(attr.LowerCaseEqualsLiteral("true"));
 
+  NS_ENSURE_TRUE_VOID(mWindow);
+
   // "toggletoolbar" attribute
   windowElement->GetAttribute(NS_LITERAL_STRING("toggletoolbar"), attr);
   mWindow->SetShowsToolbarButton(attr.LowerCaseEqualsLiteral("true"));
 
+  NS_ENSURE_TRUE_VOID(mWindow);
+
   // "fullscreenbutton" attribute
   windowElement->GetAttribute(NS_LITERAL_STRING("fullscreenbutton"), attr);
   mWindow->SetShowsFullScreenButton(attr.LowerCaseEqualsLiteral("true"));
 
+  NS_ENSURE_TRUE_VOID(mWindow);
+
   // "macanimationtype" attribute
   windowElement->GetAttribute(NS_LITERAL_STRING("macanimationtype"), attr);
   if (attr.EqualsLiteral("document")) {
     mWindow->SetWindowAnimationType(nsIWidget::eDocumentWindowAnimation);
   }
 }
 
 NS_IMETHODIMP nsXULWindow::SavePersistentAttributes()
--- a/xpfe/appshell/nsXULWindow.h
+++ b/xpfe/appshell/nsXULWindow.h
@@ -165,16 +165,17 @@ protected:
    bool                    mLockedUntilChromeLoad;
    bool                    mIgnoreXULSize;
    bool                    mIgnoreXULPosition;
    bool                    mChromeFlagsFrozen;
    bool                    mIgnoreXULSizeMode;
    // mDestroying is used to prevent reentry into into Destroy(), which can
    // otherwise happen due to script running as we tear down various things.
    bool                    mDestroying;
+   bool                    mSyncingAttributesToWidget = false;
    bool                    mRegistered;
    uint32_t                mPersistentAttributesDirty; // persistentAttributes
    uint32_t                mPersistentAttributesMask;
    uint32_t                mChromeFlags;
    uint64_t                mNextTabParentId;
    nsString                mTitle;
    nsIntRect               mOpenerScreenRect; // the screen rect of the opener