From bf515205b6dfd02abbcb145984438223342da459 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Wed, 3 Nov 2021 15:24:34 -0700 Subject: [PATCH] browser(webkit): flag to disable accelerated compositing on win (#10024) --- browser_patches/webkit/BUILD_NUMBER | 4 ++-- browser_patches/webkit/embedder/Playwright/win/Common.cpp | 2 ++ browser_patches/webkit/embedder/Playwright/win/Common.h | 1 + .../webkit/embedder/Playwright/win/MainWindow.cpp | 7 ++++++- .../webkit/embedder/Playwright/win/MainWindow.h | 3 ++- browser_patches/webkit/embedder/Playwright/win/WinMain.cpp | 2 +- 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/browser_patches/webkit/BUILD_NUMBER b/browser_patches/webkit/BUILD_NUMBER index 057660cb45..96bab08b58 100644 --- a/browser_patches/webkit/BUILD_NUMBER +++ b/browser_patches/webkit/BUILD_NUMBER @@ -1,2 +1,2 @@ -1571 -Changed: yurys@chromium.org Wed 03 Nov 2021 08:42:54 AM PDT +1572 +Changed: yurys@chromium.org Wed, Nov 3, 2021 10:07:22 PM diff --git a/browser_patches/webkit/embedder/Playwright/win/Common.cpp b/browser_patches/webkit/embedder/Playwright/win/Common.cpp index 1f7781acf0..692028186c 100644 --- a/browser_patches/webkit/embedder/Playwright/win/Common.cpp +++ b/browser_patches/webkit/embedder/Playwright/win/Common.cpp @@ -197,6 +197,8 @@ CommandLineOptions parseCommandLine() options.headless = true; else if (!wcsicmp(argv[i], L"--no-startup-window")) options.noStartupWindow = true; + else if (!wcsicmp(argv[i], L"--disable-accelerated-compositing")) + options.disableAcceleratedCompositing = true; else if (!options.requestedURL) options.requestedURL = argv[i]; } diff --git a/browser_patches/webkit/embedder/Playwright/win/Common.h b/browser_patches/webkit/embedder/Playwright/win/Common.h index 2bc1b8fb19..3c534fd370 100644 --- a/browser_patches/webkit/embedder/Playwright/win/Common.h +++ b/browser_patches/webkit/embedder/Playwright/win/Common.h @@ -36,6 +36,7 @@ struct CommandLineOptions { bool inspectorPipe { }; bool headless { }; bool noStartupWindow { }; + bool disableAcceleratedCompositing { }; _bstr_t requestedURL; _bstr_t userDataDir; _bstr_t curloptProxy; diff --git a/browser_patches/webkit/embedder/Playwright/win/MainWindow.cpp b/browser_patches/webkit/embedder/Playwright/win/MainWindow.cpp index 371822d8a0..e74590c491 100644 --- a/browser_patches/webkit/embedder/Playwright/win/MainWindow.cpp +++ b/browser_patches/webkit/embedder/Playwright/win/MainWindow.cpp @@ -28,6 +28,7 @@ #include "MainWindow.h" #include "PlaywrightLibResource.h" #include "WebKitBrowserWindow.h" +#include #include namespace WebCore { @@ -49,10 +50,12 @@ size_t MainWindow::s_numInstances; bool MainWindow::s_headless = false; bool MainWindow::s_controlledRemotely = false; +bool MainWindow::s_disableAcceleratedCompositing = false; -void MainWindow::configure(bool headless, bool controlledRemotely) { +void MainWindow::configure(bool headless, bool controlledRemotely, bool disableAcceleratedCompositing) { s_headless = headless; s_controlledRemotely = controlledRemotely; + s_disableAcceleratedCompositing = disableAcceleratedCompositing; } static std::wstring loadString(int id) @@ -180,6 +183,8 @@ bool MainWindow::init(HINSTANCE hInstance, WKPageConfigurationRef conf) WKPageConfigurationSetPreferences(conf, prefs.get()); WKPreferencesSetMediaCapabilitiesEnabled(prefs.get(), false); WKPreferencesSetDeveloperExtrasEnabled(prefs.get(), true); + if (s_disableAcceleratedCompositing) + WKPreferencesSetAcceleratedCompositingEnabled(prefs.get(), false); m_configuration = conf; diff --git a/browser_patches/webkit/embedder/Playwright/win/MainWindow.h b/browser_patches/webkit/embedder/Playwright/win/MainWindow.h index 0ccbe2c97b..c34241fb1d 100644 --- a/browser_patches/webkit/embedder/Playwright/win/MainWindow.h +++ b/browser_patches/webkit/embedder/Playwright/win/MainWindow.h @@ -35,7 +35,7 @@ class MainWindow : public BrowserWindowClient { public: - static void configure(bool headless, bool controlledRemotely); + static void configure(bool headless, bool controlledRemotely, bool disableAcceleratedCompositing); MainWindow(); @@ -57,6 +57,7 @@ private: static size_t s_numInstances; static bool s_headless; static bool s_controlledRemotely; + static bool s_disableAcceleratedCompositing; bool toggleMenuItem(UINT menuID); void onURLBarEnter(); diff --git a/browser_patches/webkit/embedder/Playwright/win/WinMain.cpp b/browser_patches/webkit/embedder/Playwright/win/WinMain.cpp index a3d66da1ba..4f6cbbbca9 100644 --- a/browser_patches/webkit/embedder/Playwright/win/WinMain.cpp +++ b/browser_patches/webkit/embedder/Playwright/win/WinMain.cpp @@ -101,7 +101,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, if (SetProcessDpiAwarenessContextPtr()) SetProcessDpiAwarenessContextPtr()(DPI_AWARENESS_CONTEXT_UNAWARE); - MainWindow::configure(g_options.headless, g_options.inspectorPipe); + MainWindow::configure(g_options.headless, g_options.inspectorPipe, g_options.disableAcceleratedCompositing); if (!g_options.noStartupWindow) { auto configuration = adoptWK(WKWebsiteDataStoreConfigurationCreate());