Bug 1914191 - Part 1: Remove keepProcessesAlive.webIsolated.perOrigin, r=mccr8

Due to changes in how processes are selected when doing BFCached
navigations, the process will be re-used for the navigation meaning we
no longer need to add logic explicitly keeping it alive.

This also tweaks the code which checks this to explicitly stop checking
any keepProcessesAlive prefs for these origin-specific remote types.

Differential Revision: https://phabricator.services.mozilla.com/D220191
This commit is contained in:
Nika Layzell 2024-09-16 21:11:30 +00:00
parent 6b1d8370ec
commit 0a6112d539
3 changed files with 12 additions and 23 deletions

View File

@ -156,8 +156,7 @@ add_task(async function navigate_around() {
// Disable bfcache so that we can measure more accurately the number of // Disable bfcache so that we can measure more accurately the number of
// pref accesses in the child processes. // pref accesses in the child processes.
// If bfcache is enabled on Fission // If bfcache is enabled on Fission
// dom.ipc.keepProcessesAlive.webIsolated.perOrigin and // security.sandbox.content.force-namespace is accessed only a couple of
// security.sandbox.content.force-namespace are accessed only a couple of
// times. // times.
["browser.sessionhistory.max_total_viewers", 0], ["browser.sessionhistory.max_total_viewers", 0],
], ],
@ -183,12 +182,6 @@ add_task(async function navigate_around() {
min: 50, min: 50,
max: 51, max: 51,
}; };
// This pref is only accessed in automation to speed up tests.
knownProblematicPrefs["dom.ipc.keepProcessesAlive.webIsolated.perOrigin"] =
{
min: 50,
max: 51,
};
if (AppConstants.platform == "linux") { if (AppConstants.platform == "linux") {
// The following sandbox pref is covered by // The following sandbox pref is covered by
// https://bugzilla.mozilla.org/show_bug.cgi?id=1600189 // https://bugzilla.mozilla.org/show_bug.cgi?id=1600189

View File

@ -2134,7 +2134,7 @@ bool ContentParent::MaybeBeginShutDown(bool aIgnoreKeepAlivePref) {
// processes alive for performance reasons (e.g. test runs and privileged // processes alive for performance reasons (e.g. test runs and privileged
// content process for some about: pages). We don't want to alter behavior // content process for some about: pages). We don't want to alter behavior
// if the pref is not set, so default to 0. // if the pref is not set, so default to 0.
if (!aIgnoreKeepAlivePref && mIsInPool && if (!aIgnoreKeepAlivePref && mIsInPool && !mRemoteType.Contains('=') &&
!AppShutdown::IsInOrBeyond(ShutdownPhase::AppShutdownConfirmed)) { !AppShutdown::IsInOrBeyond(ShutdownPhase::AppShutdownConfirmed)) {
auto* contentParents = sBrowserContentParents->Get(mRemoteType); auto* contentParents = sBrowserContentParents->Get(mRemoteType);
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
@ -2142,13 +2142,7 @@ bool ContentParent::MaybeBeginShutDown(bool aIgnoreKeepAlivePref) {
"mIsInPool, yet no entry for mRemoteType in sBrowserContentParents?"); "mIsInPool, yet no entry for mRemoteType in sBrowserContentParents?");
nsAutoCString keepAlivePref("dom.ipc.keepProcessesAlive."); nsAutoCString keepAlivePref("dom.ipc.keepProcessesAlive.");
if (StringBeginsWith(mRemoteType, FISSION_WEB_REMOTE_TYPE) && keepAlivePref.Append(mRemoteType);
xpc::IsInAutomation()) {
keepAlivePref.Append(FISSION_WEB_REMOTE_TYPE);
keepAlivePref.AppendLiteral(".perOrigin");
} else {
keepAlivePref.Append(mRemoteType);
}
int32_t processesToKeepAlive = 0; int32_t processesToKeepAlive = 0;
if (NS_SUCCEEDED(Preferences::GetInt(keepAlivePref.get(), if (NS_SUCCEEDED(Preferences::GetInt(keepAlivePref.get(),

View File

@ -8,16 +8,11 @@
// turned off once it is closed. // turned off once it is closed.
add_task(async function test() { add_task(async function test() {
// We need to reuse the content process when we navigate so the entire process
// with the possible-leaking window doesn't get torn down.
await SpecialPowers.pushPrefEnv({
set: [["dom.ipc.keepProcessesAlive.webIsolated.perOrigin", 1]],
});
const url = const url =
"http://mochi.test:8888/browser/dom/xhr/tests/browser_xhr_onchange_leak.html"; "http://mochi.test:8888/browser/dom/xhr/tests/browser_xhr_onchange_leak.html";
let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url); let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url);
let browser = gBrowser.selectedBrowser; let browser = gBrowser.selectedBrowser;
let origContentProcessId = browser.frameLoader.remoteTab.contentProcessId;
let pageShowPromise = BrowserTestUtils.waitForContentEvent( let pageShowPromise = BrowserTestUtils.waitForContentEvent(
browser, browser,
"pageshow", "pageshow",
@ -26,6 +21,13 @@ add_task(async function test() {
BrowserTestUtils.startLoadingURIString(browser, "http://mochi.test:8888/"); BrowserTestUtils.startLoadingURIString(browser, "http://mochi.test:8888/");
await pageShowPromise; await pageShowPromise;
ok(pageShowPromise, "need to check something"); is(
browser.frameLoader.remoteTab.contentProcessId,
origContentProcessId,
"we must still be in the same process after we navigate " +
"so the entire process with the possibly-leaking window " +
"doesn't get torn down"
);
BrowserTestUtils.removeTab(newTab); BrowserTestUtils.removeTab(newTab);
}); });