From 08e12de2a00a04b79cc98c586337c66ff359ae79 Mon Sep 17 00:00:00 2001 From: Denis Bernard Date: Sat, 4 Nov 2023 08:03:12 +0100 Subject: [PATCH] linux: workaround for #2977 (#3027) In NewWindow, set options.Linux.WebviewGpuPolicy to WebviewGpuPolicyNever if options.Linux is nil, disabling GPU acceleration by default on linux until the upstream bugs https://bugs.webkit.org/show_bug.cgi?id=228268 and https://bugs.webkit.org/show_bug.cgi?id=261874 are fixed. --- v2/internal/frontend/desktop/linux/window.go | 4 ++++ v2/pkg/options/linux/linux.go | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/v2/internal/frontend/desktop/linux/window.go b/v2/internal/frontend/desktop/linux/window.go index 82030f439cd..fbe8d7b5c76 100644 --- a/v2/internal/frontend/desktop/linux/window.go +++ b/v2/internal/frontend/desktop/linux/window.go @@ -25,6 +25,7 @@ import ( "github.com/wailsapp/wails/v2/internal/frontend" "github.com/wailsapp/wails/v2/pkg/menu" "github.com/wailsapp/wails/v2/pkg/options" + "github.com/wailsapp/wails/v2/pkg/options/linux" ) func gtkBool(input bool) C.gboolean { @@ -90,6 +91,9 @@ func NewWindow(appoptions *options.App, debug bool, devtoolsEnabled bool) *Windo var webviewGpuPolicy int if appoptions.Linux != nil { webviewGpuPolicy = int(appoptions.Linux.WebviewGpuPolicy) + } else { + // workaround for https://github.com/wailsapp/wails/issues/2977 + webviewGpuPolicy = int(linux.WebviewGpuPolicyNever) } webview := C.SetupWebview( diff --git a/v2/pkg/options/linux/linux.go b/v2/pkg/options/linux/linux.go index 062119cb714..797450c2725 100644 --- a/v2/pkg/options/linux/linux.go +++ b/v2/pkg/options/linux/linux.go @@ -28,6 +28,11 @@ type Options struct { // - WebviewGpuPolicyAlways // - WebviewGpuPolicyOnDemand // - WebviewGpuPolicyNever + // + // Due to https://github.com/wailsapp/wails/issues/2977, if options.Linux is nil + // in the call to wails.Run(), WebviewGpuPolicy is set by default to WebviewGpuPolicyNever. + // Client code may override this behavior by passing a non-nil Options and set + // WebviewGpuPolicy as needed. WebviewGpuPolicy WebviewGpuPolicy // ProgramName is used to set the program's name for the window manager via GTK's g_set_prgname().