Bug 1634596 - Avoid switching into a new process if an ancestor is discarded, r=farre

This is a temporary workaround for the crashes this can cause. A more thorough
fix to discarded ancestor issues will be implemented in bug 1634759.

Differential Revision: https://phabricator.services.mozilla.com/D74101
This commit is contained in:
Nika Layzell 2020-05-08 18:04:51 +00:00
Родитель 9f954bebdb
Коммит 5b5f1a77c5
1 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -37,6 +37,23 @@ nsresult BrowserBridgeParent::InitWithProcess(
RefPtr<CanonicalBrowsingContext> browsingContext =
aWindowInit.browsingContext().get_canonical();
// Unfortunately, due to the current racy destruction of BrowsingContext
// instances when Fission is enabled, while `browsingContext` may not be
// discarded, an ancestor might be.
//
// A discarded ancestor will cause us issues when creating our `BrowserParent`
// in the new content process, so abort the attempt if we have one.
//
// FIXME: We should never have a non-discarded BrowsingContext with discarded
// ancestors. (bug 1634759)
CanonicalBrowsingContext* ancestor = browsingContext->GetParent();
while (ancestor) {
if (NS_WARN_IF(ancestor->IsDiscarded())) {
return NS_ERROR_UNEXPECTED;
}
ancestor = ancestor->GetParent();
}
MutableTabContext tabContext;
tabContext.SetTabContext(Manager()->ChromeOuterWindowID(),
Manager()->ShowFocusRings(), aPresentationURL,