Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

browser(webkit): flag to disable accelerated compositing on win (#10024)

Yury Semikhatskybf515205b6df
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: [email protected] Wed 03 Nov 2021 08:42:54 AM PDT
+1572
+Changed: [email protected] 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 <WebKit/WKPreferencesRefPrivate.h>
#include <sstream>
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());