Skip to content

Commit

Permalink
linux: workaround for wailsapp#2977
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
db47h committed Nov 3, 2023
1 parent ae688aa commit 50f0b24
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions v2/internal/frontend/desktop/linux/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -90,6 +91,8 @@ func NewWindow(appoptions *options.App, debug bool, devtoolsEnabled bool) *Windo
var webviewGpuPolicy int
if appoptions.Linux != nil {
webviewGpuPolicy = int(appoptions.Linux.WebviewGpuPolicy)
} else {
webviewGpuPolicy = int(linux.WebviewGpuPolicyNever)
}

webview := C.SetupWebview(
Expand Down
5 changes: 5 additions & 0 deletions v2/pkg/options/linux/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down

0 comments on commit 50f0b24

Please sign in to comment.