Skip to content
This repository was archived by the owner on Sep 2, 2021. It is now read-only.

Commit 651b74b

Browse files
nethipvickramdhawal
authored andcommitted
Forcefully disabling renderer accesibility (#660)
* Forcefully disabling renderer accesibility as this is leading to performance issues with Windows update KB4343909 * Conditionally adding disable-renderer-accessibility flag based on wheter the user has passed on --force-renderer-accessibility or --enable-renderer-accessibility * Code cleanup and fixed documentation. * Restricting the accessibility option only to Windows.
1 parent 5c2124c commit 651b74b

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

appshell/cefclient.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020

2121
CefRefPtr<ClientHandler> g_handler;
2222

23+
#ifdef OS_WIN
24+
bool g_force_enable_acc = false;
25+
#endif
26+
2327
CefRefPtr<CefBrowser> AppGetBrowser() {
2428
if (!g_handler.get())
2529
return NULL;
@@ -32,6 +36,20 @@ CefWindowHandle AppGetMainHwnd() {
3236
return g_handler->GetMainHwnd();
3337
}
3438

39+
// CefCommandLine::HasSwitch is unable to report the presense of switches,
40+
// in the command line properly. This is a generic function that could be
41+
// used to check for any particular switch, passed as a command line argument.
42+
bool HasSwitch(CefRefPtr<CefCommandLine> command_line , CefString& switch_name)
43+
{
44+
if (command_line) {
45+
ExtensionString cmdLine = command_line->GetCommandLineString();
46+
size_t idx = cmdLine.find(switch_name);
47+
return idx > 0 && idx < cmdLine.length();
48+
} else {
49+
return false;
50+
}
51+
}
52+
3553
// Returns the application settings based on command line arguments.
3654
void AppGetSettings(CefSettings& settings, CefRefPtr<CefCommandLine> command_line) {
3755
DCHECK(command_line.get());
@@ -91,4 +109,16 @@ void AppGetSettings(CefSettings& settings, CefRefPtr<CefCommandLine> command_lin
91109
// Set product version, which gets added to the User Agent string
92110
CefString(&settings.product_version) = versionStr;
93111
}
112+
113+
#ifdef OS_WIN
114+
// We disable renderer accessibility by default as it is known to cause performance
115+
// issues. But if any one wants to enable it back, then we need to honor the flag.
116+
117+
CefString force_acc_switch_name("--force-renderer-accessibility");
118+
CefString enable_acc_switch_name("--enable-renderer-accessibility");
119+
120+
if (HasSwitch(command_line, force_acc_switch_name) || HasSwitch(command_line, enable_acc_switch_name))
121+
g_force_enable_acc = true;
122+
#endif
123+
94124
}

appshell/client_app.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
#include "appshell/appshell_extension_handler.h"
1717
#include "appshell/appshell_helpers.h"
1818

19+
#ifdef OS_WIN
20+
extern bool g_force_enable_acc;
21+
#endif
22+
1923
ClientApp::ClientApp() {
2024
CreateRenderDelegates(render_delegates_);
2125
}
@@ -42,6 +46,27 @@ void ClientApp::OnContextCreated(CefRefPtr<CefBrowser> browser,
4246
(*it)->OnContextCreated(this, browser, frame, context);
4347
}
4448

49+
void ClientApp::OnBeforeCommandLineProcessing(
50+
const CefString& process_type,
51+
CefRefPtr<CefCommandLine> command_line)
52+
{
53+
#ifdef OS_WIN
54+
// Check if the user wants to enable renderer accessibility
55+
// and if not, then disable renderer accessibility.
56+
if (!g_force_enable_acc)
57+
command_line->AppendSwitch("disable-renderer-accessibility");
58+
#endif
59+
}
60+
61+
void ClientApp::OnBeforeChildProcessLaunch(
62+
CefRefPtr<CefCommandLine> command_line)
63+
{
64+
#ifdef OS_WIN
65+
if (!g_force_enable_acc)
66+
command_line->AppendSwitch("disable-renderer-accessibility");
67+
#endif
68+
}
69+
4570
void ClientApp::OnContextReleased(CefRefPtr<CefBrowser> browser,
4671
CefRefPtr<CefFrame> frame,
4772
CefRefPtr<CefV8Context> context) {

appshell/client_app.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ class ClientApp : public CefApp,
102102
}
103103
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler()
104104
OVERRIDE { return this; }
105+
106+
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler()
107+
OVERRIDE { return this; }
108+
virtual void OnBeforeCommandLineProcessing(
109+
const CefString& process_type,
110+
CefRefPtr<CefCommandLine> command_line);
111+
112+
virtual void OnBeforeChildProcessLaunch(
113+
CefRefPtr<CefCommandLine> command_line);
105114

106115
// CefRenderProcessHandler methods.
107116
virtual void OnWebKitInitialized() OVERRIDE;

0 commit comments

Comments
 (0)