Bug 1551241 - Add a check for the case where the embedder element is nullptr. r=jwatt
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Wed, 15 May 2019 10:55:34 +0000
changeset 532739 f6ae1491321623380e67115dc649d6b22ff84c6d
parent 532738 f613e818e43507bc9f900f3756a6921890427775
child 532740 d865d7a290f8c93bfca4ad532878fbc0e4403b62
push id11272
push userapavel@mozilla.com
push dateThu, 16 May 2019 15:28:22 +0000
treeherdermozilla-beta@2265bfc5920d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs1551241
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 1551241 - Add a check for the case where the embedder element is nullptr. r=jwatt Differential Revision: https://phabricator.services.mozilla.com/D30982
layout/base/PresShell.cpp
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -10916,17 +10916,25 @@ void PresShell::SetIsUnderHiddenEmbedder
   mUnderHiddenEmbedderElement = aUnderHiddenEmbedderElement;
 
   if (nsCOMPtr<nsIDocShell> docShell = mPresContext->GetDocShell()) {
     BrowsingContext* bc = nsDocShell::Cast(docShell)->GetBrowsingContext();
 
     // Propagate to children.
     for (BrowsingContext* child : bc->GetChildren()) {
       Element* embedderElement = child->GetEmbedderElement();
-      MOZ_ASSERT(embedderElement);
+      if (!embedderElement) {
+        // TODO: We shouldn't need to null check here since `child` and the
+        // element returned by `child->GetEmbedderElement()` are in our
+        // process (the actual browsing context represented by `child` may not
+        // be, but that doesn't matter).  However, there are currently a very
+        // small number of crashes due to `embedderElement` being null, somehow
+        // - see bug 1551241.  For now we wallpaper the crash.
+        continue;
+      }
 
       bool embedderFrameIsHidden = true;
       if (auto embedderFrame = embedderElement->GetPrimaryFrame()) {
         embedderFrameIsHidden =
             !embedderFrame->StyleVisibility()->IsVisible();
       }
 
       if (nsIDocShell* childDocShell = child->GetDocShell()) {