Bug 1547911 - Only restore non-empty browsing context children. r=peterv
authorAndreas Farre <farre@mozilla.com>
Tue, 30 Apr 2019 16:11:03 +0000
changeset 530798 11b4d70a2b5d6373f5ec8fa01ca48a1c7bc1829e
parent 530797 0f5b654fe33f69c20f3c4fe3d18a5511813a79b7
child 530799 f844160f4144e693bc080b276a6aa2b35908f439
child 530918 4755a19e0826d2e3beee0559440387e84bc60444
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1547911
milestone68.0a1
first release with
nightly linux32
11b4d70a2b5d / 68.0a1 / 20190430215337 / files
nightly linux64
11b4d70a2b5d / 68.0a1 / 20190430215337 / files
nightly mac
11b4d70a2b5d / 68.0a1 / 20190430215337 / files
nightly win32
11b4d70a2b5d / 68.0a1 / 20190430215337 / files
nightly win64
11b4d70a2b5d / 68.0a1 / 20190430215337 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1547911 - Only restore non-empty browsing context children. r=peterv Also, make sure to evict the right browsing contexts from the cache. Differential Revision: https://phabricator.services.mozilla.com/D29349
docshell/base/BrowsingContext.cpp
docshell/base/nsDocShell.cpp
--- a/docshell/base/BrowsingContext.cpp
+++ b/docshell/base/BrowsingContext.cpp
@@ -332,17 +332,17 @@ void BrowsingContext::CacheChildren(bool
 
 void BrowsingContext::RestoreChildren(Children&& aChildren, bool aFromIPC) {
   MOZ_LOG(GetLog(), LogLevel::Debug,
           ("%s: Restoring children of 0x%08" PRIx64 "",
            XRE_IsParentProcess() ? "Parent" : "Child", Id()));
 
   MOZ_DIAGNOSTIC_ASSERT(mChildren.IsEmpty());
 
-  for (BrowsingContext* child : mChildren) {
+  for (BrowsingContext* child : aChildren) {
     MOZ_DIAGNOSTIC_ASSERT(child->GetParent() == this);
     Unused << Group()->EvictCachedContext(child);
   }
 
   mChildren.SwapElements(aChildren);
 
   if (!aFromIPC && XRE_IsContentProcess()) {
     auto cc = ContentChild::GetSingleton();
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -7863,17 +7863,19 @@ nsresult nsDocShell::RestoreFromHistory(
     childShell->SetAllowContentRetargetingOnChildren(
         allowContentRetargetingOnChildren);
     childShell->SetDefaultLoadFlags(defaultLoadFlags);
 
     rv = childShell->BeginRestore(nullptr, false);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  GetBrowsingContext()->RestoreChildren(std::move(contexts));
+  if (!contexts.IsEmpty()) {
+    GetBrowsingContext()->RestoreChildren(std::move(contexts));
+  }
 
   // Make sure to restore the window state after adding the child shells back
   // to the tree.  This is necessary for Thaw() and Resume() to propagate
   // properly.
   rv = privWin->RestoreWindowState(windowState);
   NS_ENSURE_SUCCESS(rv, rv);
 
   RefPtr<PresShell> presShell = GetPresShell();