From ec082e704694ebecc0b6f5c95839de9789562bb4 Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Wed, 6 Nov 2019 23:14:27 +0000 Subject: [PATCH] Bug 1580212, part 2 - Make dom.ipc.keepProcessesAlive.webIsolated work for Fission content processes. r=kmag Also, enable it for the extensions test directory. Without this pref, it gets frequent intermittent leaks and shutdown hangs when Fission is enabled. Differential Revision: https://phabricator.services.mozilla.com/D51752 --HG-- extra : moz-landing-system : lando --- .../components/extensions/test/browser/browser.ini | 4 ++++ dom/ipc/ContentParent.cpp | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/browser/components/extensions/test/browser/browser.ini b/browser/components/extensions/test/browser/browser.ini index b9a81571977b..fc9233d61aea 100644 --- a/browser/components/extensions/test/browser/browser.ini +++ b/browser/components/extensions/test/browser/browser.ini @@ -4,6 +4,10 @@ prefs = # We don't want to reset this at the end of the test, so that we don't have # to spawn a new extension child process for each test unit. dom.ipc.keepProcessesAlive.extension=1 + # With Fission enabled, this directory spawns many child processes, which + # somehow results in frequent leaks and shutdown hangs. Reuse the content + # processes to avoid this. + dom.ipc.keepProcessesAlive.webIsolated.perOrigin=1 dom.animations-api.core.enabled=true dom.animations-api.timelines.enabled=true plugin.load_flash_only=false diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 77186574bd9c..3585ff0671a0 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -232,6 +232,7 @@ #include "MMPrinter.h" #include "nsStreamUtils.h" #include "nsIAsyncInputStream.h" +#include "xpcpublic.h" #include "mozilla/Sprintf.h" @@ -1809,7 +1810,15 @@ bool ContentParent::ShouldKeepProcessAlive() { int32_t processesToKeepAlive = 0; nsAutoCString keepAlivePref("dom.ipc.keepProcessesAlive."); - keepAlivePref.Append(NS_ConvertUTF16toUTF8(mRemoteType)); + + if (StringBeginsWith(mRemoteType, + NS_LITERAL_STRING(FISSION_WEB_REMOTE_TYPE)) && + xpc::IsInAutomation()) { + keepAlivePref.Append(FISSION_WEB_REMOTE_TYPE); + keepAlivePref.AppendLiteral(".perOrigin"); + } else { + keepAlivePref.Append(NS_ConvertUTF16toUTF8(mRemoteType)); + } if (NS_FAILED( Preferences::GetInt(keepAlivePref.get(), &processesToKeepAlive))) { return false;