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

Commit

Permalink
Forcefully disabling renderer accesibility (#660)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
nethip authored and vickramdhawal committed Oct 16, 2018
1 parent 5c2124c commit 651b74b
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
30 changes: 30 additions & 0 deletions appshell/cefclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

CefRefPtr<ClientHandler> g_handler;

#ifdef OS_WIN
bool g_force_enable_acc = false;
#endif

CefRefPtr<CefBrowser> AppGetBrowser() {
if (!g_handler.get())
return NULL;
Expand All @@ -32,6 +36,20 @@ CefWindowHandle AppGetMainHwnd() {
return g_handler->GetMainHwnd();
}

// CefCommandLine::HasSwitch is unable to report the presense of switches,
// in the command line properly. This is a generic function that could be
// used to check for any particular switch, passed as a command line argument.
bool HasSwitch(CefRefPtr<CefCommandLine> command_line , CefString& switch_name)
{
if (command_line) {
ExtensionString cmdLine = command_line->GetCommandLineString();
size_t idx = cmdLine.find(switch_name);
return idx > 0 && idx < cmdLine.length();
} else {
return false;
}
}

// Returns the application settings based on command line arguments.
void AppGetSettings(CefSettings& settings, CefRefPtr<CefCommandLine> command_line) {
DCHECK(command_line.get());
Expand Down Expand Up @@ -91,4 +109,16 @@ void AppGetSettings(CefSettings& settings, CefRefPtr<CefCommandLine> command_lin
// Set product version, which gets added to the User Agent string
CefString(&settings.product_version) = versionStr;
}

#ifdef OS_WIN
// We disable renderer accessibility by default as it is known to cause performance
// issues. But if any one wants to enable it back, then we need to honor the flag.

CefString force_acc_switch_name("--force-renderer-accessibility");
CefString enable_acc_switch_name("--enable-renderer-accessibility");

if (HasSwitch(command_line, force_acc_switch_name) || HasSwitch(command_line, enable_acc_switch_name))
g_force_enable_acc = true;
#endif

}
25 changes: 25 additions & 0 deletions appshell/client_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#include "appshell/appshell_extension_handler.h"
#include "appshell/appshell_helpers.h"

#ifdef OS_WIN
extern bool g_force_enable_acc;
#endif

ClientApp::ClientApp() {
CreateRenderDelegates(render_delegates_);
}
Expand All @@ -42,6 +46,27 @@ void ClientApp::OnContextCreated(CefRefPtr<CefBrowser> browser,
(*it)->OnContextCreated(this, browser, frame, context);
}

void ClientApp::OnBeforeCommandLineProcessing(
const CefString& process_type,
CefRefPtr<CefCommandLine> command_line)
{
#ifdef OS_WIN
// Check if the user wants to enable renderer accessibility
// and if not, then disable renderer accessibility.
if (!g_force_enable_acc)
command_line->AppendSwitch("disable-renderer-accessibility");
#endif
}

void ClientApp::OnBeforeChildProcessLaunch(
CefRefPtr<CefCommandLine> command_line)
{
#ifdef OS_WIN
if (!g_force_enable_acc)
command_line->AppendSwitch("disable-renderer-accessibility");
#endif
}

void ClientApp::OnContextReleased(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context) {
Expand Down
9 changes: 9 additions & 0 deletions appshell/client_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ class ClientApp : public CefApp,
}
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler()
OVERRIDE { return this; }

virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler()
OVERRIDE { return this; }
virtual void OnBeforeCommandLineProcessing(
const CefString& process_type,
CefRefPtr<CefCommandLine> command_line);

virtual void OnBeforeChildProcessLaunch(
CefRefPtr<CefCommandLine> command_line);

// CefRenderProcessHandler methods.
virtual void OnWebKitInitialized() OVERRIDE;
Expand Down

0 comments on commit 651b74b

Please sign in to comment.