Bug 1341008 - Use the preallocated process manager by default. r=billm, r=kmag

To mitigate the delay that a new content process startup might cause, when the
browser reaches a non-busy state we attempt to prelaunch an empty content process
in the background that can be grabbed and used the next time we need one. This patch
enables the preallocated process manager by default and attempts to fix all the
issues that prevented us doing this sooner.
This commit is contained in:
Gabor Krizsanits 2017-05-03 12:00:20 +02:00
parent 6469b8fbc1
commit eb829f971b
9 changed files with 35 additions and 11 deletions

View File

@ -1573,6 +1573,8 @@ pref("browser.esedbreader.loglevel", "Error");
pref("browser.laterrun.enabled", false);
pref("dom.ipc.processPrelaunch.enabled", true);
#ifdef EARLY_BETA_OR_EARLIER
pref("browser.migrate.automigrate.enabled", true);
#else

View File

@ -82,7 +82,7 @@ function test() {
info(testCase.desc);
// Create a tab to run the test.
let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser);
// Add an event handler to modify the snippets map once it's ready.
let snippetsPromise = promiseSetupSnippetsMap(tab, testCase.snippet);
@ -221,6 +221,6 @@ function activateProvider(tab, expectPanel, aCallback) {
function waitForProviderLoad(cb) {
return Promise.all([
promiseObserverNotified("social:provider-enabled"),
ensureFrameLoaded(gBrowser, "https://example.com/browser/browser/base/content/test/social/social_postActivation.html"),
BrowserTestUtils.waitForNewTab(gBrowser, "https://example.com/browser/browser/base/content/test/social/social_postActivation.html"),
]);
}

View File

@ -60,6 +60,9 @@ function startup() {
Services.wm.addListener(windowListener);
parent.init();
Services.ppmm.loadProcessScript("data:,new " + function() {
Components.utils.import("resource://formautofill/FormAutofillContent.jsm");
}, true);
Services.mm.loadFrameScript("chrome://formautofill/content/FormAutofillFrameScript.js", true);
}

View File

@ -49,6 +49,13 @@ function promiseMessage(messageManager, message) {
})
}
add_task(function*(){
// We want to count processes in this test, so let's disable the pre-allocated process manager.
yield SpecialPowers.pushPrefEnv({"set": [
["dom.ipc.processPrelaunch.enabled", false],
]});
})
add_task(function*(){
// This test is only relevant in e10s.
if (!gMultiProcessBrowser)

View File

@ -622,9 +622,6 @@ ContentParent::StartUp()
BackgroundChild::Startup();
// Try to preallocate a process that we can use later.
PreallocatedProcessManager::AllocateAfterDelay();
sDisableUnsafeCPOWWarnings = PR_GetEnv("DISABLE_UNSAFE_CPOW_WARNINGS");
#if defined(XP_LINUX) && defined(MOZ_CONTENT_SANDBOX)

View File

@ -110,6 +110,8 @@ PreallocatedProcessManagerImpl::Init()
/* weakRef = */ false);
os->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID,
/* weakRef = */ false);
os->AddObserver(this, "profile-change-teardown",
/* weakRef = */ false);
}
RereadPrefs();
}
@ -124,14 +126,18 @@ PreallocatedProcessManagerImpl::Observe(nsISupports* aSubject,
} else if (!strcmp("nsPref:changed", aTopic)) {
// The only other observer we registered was for our prefs.
RereadPrefs();
} else if (!strcmp(NS_XPCOM_SHUTDOWN_OBSERVER_ID, aTopic)) {
} else if (!strcmp(NS_XPCOM_SHUTDOWN_OBSERVER_ID, aTopic) ||
!strcmp("profile-change-teardown", aTopic)) {
Preferences::RemoveObserver(this, "dom.ipc.processPrelaunch.enabled");
Preferences::RemoveObserver(this, "dom.ipc.processCount");
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
if (os) {
os->RemoveObserver(this, "ipc:content-shutdown");
os->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
os->RemoveObserver(this, "profile-change-teardown");
}
mShutdown = true;
CloseProcess();
} else {
MOZ_ASSERT(false);
}
@ -142,7 +148,8 @@ PreallocatedProcessManagerImpl::Observe(nsISupports* aSubject,
void
PreallocatedProcessManagerImpl::RereadPrefs()
{
if (Preferences::GetBool("dom.ipc.processPrelaunch.enabled")) {
if (mozilla::BrowserTabsRemoteAutostart() &&
Preferences::GetBool("dom.ipc.processPrelaunch.enabled")) {
Enable();
} else {
Disable();
@ -173,7 +180,7 @@ PreallocatedProcessManagerImpl::Enable()
void
PreallocatedProcessManagerImpl::AllocateAfterDelay()
{
if (!mEnabled || mPreallocatedProcess) {
if (!mEnabled || mPreallocatedProcess || mShutdown) {
return;
}
@ -189,7 +196,7 @@ PreallocatedProcessManagerImpl::AllocateAfterDelay()
void
PreallocatedProcessManagerImpl::AllocateOnIdle()
{
if (!mEnabled || mPreallocatedProcess) {
if (!mEnabled || mPreallocatedProcess || mShutdown) {
return;
}
@ -199,7 +206,7 @@ PreallocatedProcessManagerImpl::AllocateOnIdle()
void
PreallocatedProcessManagerImpl::AllocateNow()
{
if (!mEnabled || mPreallocatedProcess ||
if (!mEnabled || mPreallocatedProcess || mShutdown ||
ContentParent::IsMaxProcessCountReached(NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE))) {
return;
}

View File

@ -258,7 +258,7 @@ nsLayoutStylesheetCache::Shutdown()
gCSSLoader_Servo = nullptr;
gStyleCache_Gecko = nullptr;
gStyleCache_Servo = nullptr;
MOZ_ASSERT(!gUserContentSheetURL, "Got the URL but never used?");
gUserContentSheetURL = nullptr;
}
void

View File

@ -1061,6 +1061,10 @@ var RemoteAddonsParent = {
Services.ppmm.initialProcessData.remoteAddonsParentInitted = true;
Services.ppmm.loadProcessScript("data:,new " + function() {
Components.utils.import("resource://gre/modules/RemoteAddonsChild.jsm");
}, true);
this.globalToBrowser = new WeakMap();
this.browserToGlobal = new WeakMap();
},

View File

@ -1113,3 +1113,7 @@ this.Extension = class extends ExtensionData {
return this._optionalOrigins;
}
};
Services.ppmm.loadProcessScript("data:,new " + function() {
Components.utils.import("resource://gre/modules/ExtensionContent.jsm");
}, true);