mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-10 17:24:29 +00:00
Bug 1384336 - Stop using OS-level event loop in content process (r=mstange)
MozReview-Commit-ID: 1ouSlgGchWl
This commit is contained in:
parent
81720f1abb
commit
a7bc022071
@ -1452,6 +1452,11 @@ GetDirectoryPath(const char *aPath) {
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
||||
extern "C" {
|
||||
void CGSSetDenyWindowServerConnections(bool);
|
||||
void CGSShutdownServerConnections();
|
||||
};
|
||||
|
||||
static bool
|
||||
StartMacOSContentSandbox()
|
||||
{
|
||||
@ -1460,6 +1465,15 @@ StartMacOSContentSandbox()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!XRE_UseNativeEventProcessing()) {
|
||||
// If we've opened a connection to the window server, shut it down now. Forbid
|
||||
// future connections as well. We do this for sandboxing, but it also ensures
|
||||
// that the Activity Monitor will not label the content process as "Not
|
||||
// responding" because it's not running a native event loop. See bug 1384336.
|
||||
CGSSetDenyWindowServerConnections(true);
|
||||
CGSShutdownServerConnections();
|
||||
}
|
||||
|
||||
nsAutoCString appPath, appBinaryPath, appDir;
|
||||
if (!GetAppPaths(appPath, appBinaryPath, appDir)) {
|
||||
MOZ_CRASH("Error resolving child process path");
|
||||
|
@ -52,6 +52,7 @@ const char* mozilla::dom::ContentPrefs::gInitPrefs[] = {
|
||||
"dom.forms.autocomplete.formautofill",
|
||||
"dom.ipc.processPriorityManager.backgroundGracePeriodMS",
|
||||
"dom.ipc.processPriorityManager.backgroundPerceivableGracePeriodMS",
|
||||
"dom.ipc.useNativeEventProcessing.content",
|
||||
"dom.max_chrome_script_run_time",
|
||||
"dom.max_script_run_time",
|
||||
"dom.mozBrowserFramesEnabled",
|
||||
|
@ -3239,6 +3239,9 @@ pref("dom.ipc.processCount.file", 1);
|
||||
// WebExtensions only support a single extension process.
|
||||
pref("dom.ipc.processCount.extension", 1);
|
||||
|
||||
// Don't use a native event loop in the content process.
|
||||
pref("dom.ipc.useNativeEventProcessing.content", false);
|
||||
|
||||
// Disable support for SVG
|
||||
pref("svg.disabled", false);
|
||||
|
||||
|
@ -5012,6 +5012,24 @@ XRE_IsContentProcess()
|
||||
return XRE_GetProcessType() == GeckoProcessType_Content;
|
||||
}
|
||||
|
||||
bool
|
||||
XRE_UseNativeEventProcessing()
|
||||
{
|
||||
if (XRE_IsContentProcess()) {
|
||||
static bool sInited = false;
|
||||
static bool sUseNativeEventProcessing = false;
|
||||
if (!sInited) {
|
||||
Preferences::AddBoolVarCache(&sUseNativeEventProcessing,
|
||||
"dom.ipc.useNativeEventProcessing.content");
|
||||
sInited = true;
|
||||
}
|
||||
|
||||
return sUseNativeEventProcessing;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// If you add anything to this enum, please update about:support to reflect it
|
||||
enum {
|
||||
kE10sEnabledByUser = 0,
|
||||
|
@ -839,7 +839,7 @@ XRE_RunAppShell()
|
||||
nsCOMPtr<nsIAppShell> appShell(do_GetService(kAppShellCID));
|
||||
NS_ENSURE_TRUE(appShell, NS_ERROR_FAILURE);
|
||||
#if defined(XP_MACOSX)
|
||||
{
|
||||
if (XRE_UseNativeEventProcessing()) {
|
||||
// In content processes that want XPCOM (and hence want
|
||||
// AppShell), we usually run our hybrid event loop through
|
||||
// MessagePump::Run(), by way of nsBaseAppShell::Run(). The
|
||||
|
@ -682,13 +682,19 @@ nsAppShell::Run(void)
|
||||
AddScreenWakeLockListener();
|
||||
}
|
||||
|
||||
NS_OBJC_TRY_ABORT([NSApp run]);
|
||||
// We use the native Gecko event loop in content processes.
|
||||
nsresult rv = NS_OK;
|
||||
if (XRE_UseNativeEventProcessing()) {
|
||||
NS_OBJC_TRY_ABORT([NSApp run]);
|
||||
} else {
|
||||
rv = nsBaseAppShell::Run();
|
||||
}
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
RemoveScreenWakeLockListener();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -46,11 +46,13 @@ nsBaseAppShell::Init()
|
||||
{
|
||||
// Configure ourselves as an observer for the current thread:
|
||||
|
||||
nsCOMPtr<nsIThreadInternal> threadInt =
|
||||
if (XRE_UseNativeEventProcessing()) {
|
||||
nsCOMPtr<nsIThreadInternal> threadInt =
|
||||
do_QueryInterface(NS_GetCurrentThread());
|
||||
NS_ENSURE_STATE(threadInt);
|
||||
NS_ENSURE_STATE(threadInt);
|
||||
|
||||
threadInt->SetObserver(this);
|
||||
threadInt->SetObserver(this);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsSvc =
|
||||
mozilla::services::GetObserverService();
|
||||
|
@ -462,6 +462,13 @@ XRE_API(bool,
|
||||
XRE_API(bool,
|
||||
XRE_IsGPUProcess, ())
|
||||
|
||||
/**
|
||||
* Returns true if the appshell should run its own native event loop. Returns
|
||||
* false if we should rely solely on the Gecko event loop.
|
||||
*/
|
||||
XRE_API(bool,
|
||||
XRE_UseNativeEventProcessing, ())
|
||||
|
||||
typedef void (*MainFunction)(void* aData);
|
||||
|
||||
XRE_API(nsresult,
|
||||
|
Loading…
x
Reference in New Issue
Block a user