From fca9678be6dbcfff3d7c792ded28c98ff88e1503 Mon Sep 17 00:00:00 2001 From: Prashanth Nethi Date: Mon, 15 Oct 2018 11:07:50 +0530 Subject: [PATCH 1/4] Forcefully disabling renderer accesibility as this is leading to performance issues with Windows update KB4343909 --- appshell/client_app.cpp | 13 +++++++++++++ appshell/client_app.h | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/appshell/client_app.cpp b/appshell/client_app.cpp index 828ac8084..ce002a593 100644 --- a/appshell/client_app.cpp +++ b/appshell/client_app.cpp @@ -42,6 +42,19 @@ void ClientApp::OnContextCreated(CefRefPtr browser, (*it)->OnContextCreated(this, browser, frame, context); } +void ClientApp::OnBeforeCommandLineProcessing( + const CefString& process_type, + CefRefPtr command_line) +{ + command_line->AppendSwitch("disable-renderer-accessibility"); +} + +void ClientApp::OnBeforeChildProcessLaunch( + CefRefPtr command_line) +{ + command_line->AppendSwitch("disable-renderer-accessibility"); +} + void ClientApp::OnContextReleased(CefRefPtr browser, CefRefPtr frame, CefRefPtr context) { diff --git a/appshell/client_app.h b/appshell/client_app.h index f1a64940c..fa2da0212 100644 --- a/appshell/client_app.h +++ b/appshell/client_app.h @@ -102,6 +102,15 @@ class ClientApp : public CefApp, } virtual CefRefPtr GetRenderProcessHandler() OVERRIDE { return this; } + + virtual CefRefPtr GetBrowserProcessHandler() + OVERRIDE { return this; } + virtual void OnBeforeCommandLineProcessing( + const CefString& process_type, + CefRefPtr command_line); + + virtual void OnBeforeChildProcessLaunch( + CefRefPtr command_line); // CefRenderProcessHandler methods. virtual void OnWebKitInitialized() OVERRIDE; From 76afc0684cbe50a8552dc0b5e6c1cf9c1e544c9e Mon Sep 17 00:00:00 2001 From: Prashanth Nethi Date: Mon, 15 Oct 2018 16:04:29 +0530 Subject: [PATCH 2/4] Conditionally adding disable-renderer-accessibility flag based on wheter the user has passed on --force-renderer-accessibility or --enable-renderer-accessibility --- appshell/cefclient.cpp | 26 ++++++++++++++++++++++++++ appshell/client_app.cpp | 10 ++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/appshell/cefclient.cpp b/appshell/cefclient.cpp index 72777401b..e6284f3eb 100644 --- a/appshell/cefclient.cpp +++ b/appshell/cefclient.cpp @@ -19,6 +19,7 @@ #include "config.h" CefRefPtr g_handler; +bool g_force_enable_acc = false; CefRefPtr AppGetBrowser() { if (!g_handler.get()) @@ -32,6 +33,18 @@ CefWindowHandle AppGetMainHwnd() { return g_handler->GetMainHwnd(); } +// CefCommandLine::HasSwitch is unable to +// report these switches properly. So instead +// we will do a string search one the command +// line string to figure out presense of any +// particular flag. +bool HasSwitch(CefRefPtr command_line , CefString& switch_name) +{ + ExtensionString cmdLine = command_line->GetCommandLineString(); + size_t idx = cmdLine.find(switch_name); + return idx > 0 && idx < cmdLine.length(); +} + // Returns the application settings based on command line arguments. void AppGetSettings(CefSettings& settings, CefRefPtr command_line) { DCHECK(command_line.get()); @@ -91,4 +104,17 @@ void AppGetSettings(CefSettings& settings, CefRefPtr command_lin // Set product version, which gets added to the User Agent string CefString(&settings.product_version) = versionStr; } + + // Also see if we need to extract force enable renderer accessibility flags. + // 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. + std::vector arguments_vec; + command_line->GetArguments(arguments_vec); + + 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; + } diff --git a/appshell/client_app.cpp b/appshell/client_app.cpp index ce002a593..51a9ac07b 100644 --- a/appshell/client_app.cpp +++ b/appshell/client_app.cpp @@ -16,6 +16,8 @@ #include "appshell/appshell_extension_handler.h" #include "appshell/appshell_helpers.h" +extern bool g_force_enable_acc; + ClientApp::ClientApp() { CreateRenderDelegates(render_delegates_); } @@ -46,13 +48,17 @@ void ClientApp::OnBeforeCommandLineProcessing( const CefString& process_type, CefRefPtr command_line) { - command_line->AppendSwitch("disable-renderer-accessibility"); + // 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"); } void ClientApp::OnBeforeChildProcessLaunch( CefRefPtr command_line) { - command_line->AppendSwitch("disable-renderer-accessibility"); + if (!g_force_enable_acc) + command_line->AppendSwitch("disable-renderer-accessibility"); } void ClientApp::OnContextReleased(CefRefPtr browser, From 7fa98a0e6a152c315db9171b62a4b63bc77559a0 Mon Sep 17 00:00:00 2001 From: Prashanth Nethi Date: Mon, 15 Oct 2018 16:10:10 +0530 Subject: [PATCH 3/4] Code cleanup and fixed documentation. --- appshell/cefclient.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/appshell/cefclient.cpp b/appshell/cefclient.cpp index e6284f3eb..c3b2e7a74 100644 --- a/appshell/cefclient.cpp +++ b/appshell/cefclient.cpp @@ -33,16 +33,18 @@ CefWindowHandle AppGetMainHwnd() { return g_handler->GetMainHwnd(); } -// CefCommandLine::HasSwitch is unable to -// report these switches properly. So instead -// we will do a string search one the command -// line string to figure out presense of any -// particular flag. +// 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 command_line , CefString& switch_name) { - ExtensionString cmdLine = command_line->GetCommandLineString(); - size_t idx = cmdLine.find(switch_name); - return idx > 0 && idx < cmdLine.length(); + 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. @@ -105,11 +107,8 @@ void AppGetSettings(CefSettings& settings, CefRefPtr command_lin CefString(&settings.product_version) = versionStr; } - // Also see if we need to extract force enable renderer accessibility flags. // 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. - std::vector arguments_vec; - command_line->GetArguments(arguments_vec); CefString force_acc_switch_name("--force-renderer-accessibility"); CefString enable_acc_switch_name("--enable-renderer-accessibility"); From 349fd51da4e6212a07c50fd0cb3e56f4e66df87e Mon Sep 17 00:00:00 2001 From: Prashanth Nethi Date: Tue, 16 Oct 2018 12:05:27 +0530 Subject: [PATCH 4/4] Restricting the accessibility option only to Windows. --- appshell/cefclient.cpp | 7 ++++++- appshell/client_app.cpp | 10 ++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/appshell/cefclient.cpp b/appshell/cefclient.cpp index c3b2e7a74..a6bf5aca8 100644 --- a/appshell/cefclient.cpp +++ b/appshell/cefclient.cpp @@ -19,7 +19,10 @@ #include "config.h" CefRefPtr g_handler; -bool g_force_enable_acc = false; + +#ifdef OS_WIN +bool g_force_enable_acc = false; +#endif CefRefPtr AppGetBrowser() { if (!g_handler.get()) @@ -107,6 +110,7 @@ void AppGetSettings(CefSettings& settings, CefRefPtr command_lin 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. @@ -115,5 +119,6 @@ void AppGetSettings(CefSettings& settings, CefRefPtr command_lin if (HasSwitch(command_line, force_acc_switch_name) || HasSwitch(command_line, enable_acc_switch_name)) g_force_enable_acc = true; +#endif } diff --git a/appshell/client_app.cpp b/appshell/client_app.cpp index 51a9ac07b..82f9a3f7c 100644 --- a/appshell/client_app.cpp +++ b/appshell/client_app.cpp @@ -16,7 +16,9 @@ #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_); @@ -48,17 +50,21 @@ void ClientApp::OnBeforeCommandLineProcessing( const CefString& process_type, CefRefPtr command_line) { - // Check if the user wants to enable renderer accessibility - // and if not, then disable renderer accessibility. + #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 command_line) { +#ifdef OS_WIN if (!g_force_enable_acc) command_line->AppendSwitch("disable-renderer-accessibility"); +#endif } void ClientApp::OnContextReleased(CefRefPtr browser,