Skip to content

Conversation

@Sammy-T
Copy link

@Sammy-T Sammy-T commented Sep 9, 2025

Description

This adds an option to run or build an app on Linux using webkitgtk-6.0.

Depends on:

  • gtk4

Fixes #3193

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Important

Features which have been removed/deprecated from webkit or gtk4 have been marked with todos.
If they can be reimplemented, using this library option could potentially match the functionality of the current implementation.

How Has This Been Tested?

  • Windows
  • macOS
  • Linux

Ubuntu 22.04

The performance is usually noticeable on an app with scrolled content or a complex layout.

Running/Building the app with this PR's changes requires:

  • Setting the app's Linux program name option
  • Adding -tags webkit_6 to the Wails dev or build command

Warnings:

Message Reason?
New application windows must be added after the GApplication::startup signal has been emitted. It should already be added after the startup signal so I think this warning is more about how it's set up.

Test Configuration

# Wails
Version         | v2.10.2
Package Manager | apt


# System
WARNING: failed to read int from file: open /sys/devices/system/cpu/cpu0/online: no such file or directory
┌──────────────────────────────────────────────────────────┐
| OS           | Ubuntu                                    |
| Version      | 22.04                                     |
| ID           | ubuntu                                    |
| Branding     |                                           |
| Go Version   | go1.24.5                                  |
| Platform     | linux                                     |
| Architecture | amd64                                     |
| CPU          | Intel(R) Core(TM) i5-6300HQ CPU @ 2.30GHz |
| Memory       | 16GB                                      |
└──────────────────────────────────────────────────────────┘

# Dependencies
┌──────────────────────────────────────────────────────────────────────────┐
| Dependency | Package Name          | Status    | Version                 |
| *docker    | docker.io             | Installed |                         |
| gcc        | build-essential       | Installed | 11.4.0                  |
| libgtk-3   | libgtk-3-dev          | Installed | 3.24.33-1ubuntu2.2      |
| libwebkit  | libwebkit2gtk-4.0-dev | Installed | 2.48.5-0ubuntu0.22.04.1 |
| npm        | npm                   | Installed | 11.5.2                  |
| *nsis      | nsis                  | Available | 3.08-2                  |
| pkg-config | pkg-config            | Installed | 0.29.2-1ubuntu3         |
|                                                                          |
└──────────────────────── * - Optional Dependency ─────────────────────────┘

# Diagnosis
Optional package(s) installation details:
  - nsis: sudo apt install nsis

Requires webkitgtk-6 and gtk4.

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • New Features

    • Full WebKit 6 Linux frontend: modern webview, window lifecycle and controls, menus, clipboard, keyboard accelerators, screen detection, file dialogs, inspector/DevTools, and asset serving.
  • Chores

    • Platform split to support legacy WebKit and new WebKit 6 paths; build variants now select appropriate frontend and webview integrations.
  • New Features

    • Added WebKit6-backed request/response handling for the asset server and clipboard APIs.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 9, 2025

Walkthrough

This PR splits Linux frontend code into GTK3/WebKit2 and GTK4/WebKit6 paths: legacy files are gated with linux && !webkit_6, and new webkit_6-gated files add full GTK4/WebKit6 implementations (window, frontend, menu, clipboard, screen, keys, and webview assetserver plumbing).

Changes

Cohort / File(s) Summary
Build tag updates (exclude webkit_6)
v2/internal/frontend/desktop/linux/clipboard.go, v2/internal/frontend/desktop/linux/frontend.go, v2/internal/frontend/desktop/linux/gtk.go, v2/internal/frontend/desktop/linux/invoke.go, v2/internal/frontend/desktop/linux/keys.go, v2/internal/frontend/desktop/linux/menu.go, v2/internal/frontend/desktop/linux/screen.go, v2/internal/frontend/desktop/linux/webkit2.go, v2/internal/frontend/desktop/linux/window.c, v2/internal/frontend/desktop/linux/window.go, v2/internal/frontend/desktop/linux/window.h, v2/pkg/assetserver/webview/request_linux.go, v2/pkg/assetserver/webview/responsewriter_linux.go, v2/pkg/assetserver/webview/webkit2_36+.go, v2/pkg/assetserver/webview/webkit2_legacy.go
Replace broad linux build tags with linux && !webkit_6 (and matching legacy // +build) and minor cgo directive formatting changes to gate legacy GTK3/WebKit2 code when WebKit6 is enabled.
GTK4 / WebKit6 C layer (new)
v2/internal/frontend/desktop/linux/window_webkit6.c, v2/internal/frontend/desktop/linux/window_webkit6.h
New C implementation and header for GTK4/WebKit6 windowing, messaging bridge, input/drag/resize, dialogs, inspector, monitor utilities, and ExecuteOnMainThread/GTK helpers; gated by linux && webkit_6.
GTK4 / WebKit6 Go window layer (new)
v2/internal/frontend/desktop/linux/window_webkit6.go
New Go Window type and many public window lifecycle/geometry/UI methods that interoperate with the C layer; CGO activation bridge exported.
GTK4 / WebKit6 frontend core (new)
v2/internal/frontend/desktop/linux/frontend_webkit6.go
New Frontend type, main loop and message processing channels, CGO-exported bridge functions (processMessage, processBindingMessage), assetserver integration, window methods, and IPC/origin validation flow.
GTK4 / WebKit6 menu support (new + callbacks)
v2/internal/frontend/desktop/linux/menu_webkit6.go, v2/internal/frontend/desktop/linux/gtk_webkit6.go
New GTK4/WebKit6 menu construction, C-exported callbacks for menu item/check/radio events, action-to-item mappings, and async click dispatch.
GTK4 / WebKit6 clipboard (new)
v2/internal/frontend/desktop/linux/clipboard_webkit6.go
C wrappers and Frontend methods for clipboard get/set using GTK4/WebKit6, executed on main thread with proper C string handling.
GTK4 / WebKit6 screen/display (new)
v2/internal/frontend/desktop/linux/screen_webkit6.go
New GetAllScreens implementation using GTK4 display APIs returning frontend.Screen slice.
GTK4 / WebKit6 keys/accelerators (new)
v2/internal/frontend/desktop/linux/keys_webkit6.go
Accelerator parsing, named key → GTK keyval map and modifier parsing for GTK4/WebKit6.
WebKit6 assetserver & webview plumbing (new)
v2/pkg/assetserver/webview/webkit6.go, v2/pkg/assetserver/webview/request_linux_webkit6.go, v2/pkg/assetserver/webview/responsewriter_linux_webkit6.go
New WebKit6 request/response bridge with CGO bindings (GTK4/WebKitGTK-6.0), request wrapper, streaming response writer using Unix pipe + GInputStream, GError conversion, and exported Webkit2 min-version constant.
Validation helper (new)
v2/internal/frontend/desktop/linux/webkit6.go
WebKit2 version validation for WebKitGTK-6.0 builds; shows modal and exits if version requirement not met.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor WebView as C/WebKit
  participant CGO as cgo bridge
  participant Frontend as Go:frontend_webkit6
  participant Dispatcher as frontend.Dispatcher
  participant Window as Go/C Window

  WebView->>CGO: processMessage / processBindingMessage(C string)
  CGO->>Frontend: exported function call
  Frontend->>Frontend: validate origin / unmarshal
  Frontend->>Dispatcher: dispatch binding or event
  Dispatcher->>Window: perform action (show/size/exec)
  Window->>CGO: ExecuteOnMainThread / C helpers for UI ops
  note right of Frontend `#DDEBF7`: async goroutine dispatch for callbacks and menu clicks
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

  • Files/areas needing extra attention:
    • v2/internal/frontend/desktop/linux/window_webkit6.c / .h — GLib/GObject refcounting, main-thread dispatch, signal wiring, pointer casts, and C error handling.
    • v2/internal/frontend/desktop/linux/frontend_webkit6.go — CGO-exported functions, origin validation, channels/goroutine lifecycles and concurrency.
    • v2/pkg/assetserver/webview/responsewriter_linux_webkit6.go & request_linux_webkit6.go — pipe creation, FD flags, GInputStream bridging, and GError propagation.
    • menu_webkit6.go / gtk_webkit6.go — action mapping, radio/check state mutations, lifecycle/unref correctness.
    • window_webkit6.go — synchronization between Go and C, WaitGroup usage, and exported activation bridging.

Possibly related PRs

Suggested labels

Enhancement, Linux, cli, go, To Be Documented, size:XXL, lgtm

Suggested reviewers

  • leaanthony

Poem

🐇 I hopped through tags and C and Go,
New windows sprung where webviews grow,
Menus click and clipboards share,
Screens and keys all handled with care,
A tiny rabbit cheers the show.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add webkitgtk6 option' is concise and clearly describes the main change: adding WebKit GTK6 support as a build/runtime option. It accurately reflects the primary objective of the PR.
Description check ✅ Passed The PR description provides a clear summary of the change, links to issue #3193, identifies it as a new feature, specifies the dependencies (gtk4, webkitgtk-6), includes test configuration details, and documents known issues. However, several template checklist items remain unchecked (changelog, documentation, tests).
Linked Issues check ✅ Passed The PR successfully addresses the core objectives from issue #3193: it enables building with webkitgtk-6.0 via build tags, supports GTK4 integration, and provides the performance improvements mentioned. However, several features marked as TODOs in GTK4/WebKit6 remain unimplemented (window positioning, certain window controls).
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing WebKit6/GTK4 support for Linux: build tag conditional compilation, C/Go bindings, window management, menu handling, clipboard operations, screen queries, and asset server integration. No unrelated changes detected.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2af5ef4 and 1f0dcce.

📒 Files selected for processing (1)
  • v2/pkg/assetserver/webview/webkit6.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • v2/pkg/assetserver/webview/webkit6.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@COD3HUNT3R COD3HUNT3R left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sammy-T
Copy link
Author

Sammy-T commented Sep 25, 2025

@COD3HUNT3R this is intended to work similarly to when using -tags webkit2_41 which doesn't have any additional output for the doctor command to my knowledge.

@COD3HUNT3R
Copy link

@COD3HUNT3R this is intended to work similarly to when using -tags webkit2_41 which doesn't have any additional output for the doctor command to my knowledge.

Yes, you are right but this would be helpful to find required packages for gtk4, webkit2-6.0

@Sammy-T
Copy link
Author

Sammy-T commented Sep 29, 2025

Had to revert updating from master (ca1eed6) because it broke local development on linux for me.

@Sammy-T Sammy-T marked this pull request as ready for review September 29, 2025 21:33
@Sammy-T
Copy link
Author

Sammy-T commented Sep 29, 2025

Running this on X11 Linux Mint, this appears to be working nicely.

I still don't know how/if I can get the todos (window positioning, etc.) working with webkit-6 though.

@leaanthony Are you able to test this and see how it runs for you? And do you know how to address the commented todos?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c2da19c and c102d74.

📒 Files selected for processing (2)
  • v2/internal/frontend/desktop/linux/menu_webkit6.go (1 hunks)
  • v2/internal/frontend/desktop/linux/window_webkit6.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
v2/internal/frontend/desktop/linux/menu_webkit6.go (3)
v2/pkg/runtime/menu.go (2)
  • MenuSetApplicationMenu (9-12)
  • MenuUpdateApplicationMenu (14-17)
v2/internal/frontend/desktop/linux/window_webkit6.go (1)
  • Window (38-51)
v2/pkg/menu/menuitem.go (1)
  • SubMenu (319-329)
v2/internal/frontend/desktop/linux/window_webkit6.go (2)
v2/internal/frontend/desktop/linux/window.go (2)
  • NewWindow (62-149)
  • Window (40-53)
v2/internal/frontend/desktop/linux/window_webkit6.c (35)
  • SetupInvokeSignal (125-128)
  • SetupWebview (590-641)
  • ConnectButtons (359-369)
  • DevtoolsEnabled (643-653)
  • InstallF12Hotkey (951-961)
  • DisableContextMenu (308-312)
  • SetBackgroundColour (165-212)
  • SetTitle (224-230)
  • SetWindowIcon (131-147)
  • SetWindowTransparency (149-161)
  • GTKWIDGET (30-33)
  • GTKWINDOW (35-38)
  • GTKBOX (40-43)
  • Fullscreen (457-473)
  • ExecuteOnMainThread (25-28)
  • UnFullscreen (475-480)
  • Center (391-413)
  • SetMinMaxSize (260-299)
  • Show (415-420)
  • Hide (422-427)
  • Maximise (429-434)
  • UnMaximise (436-441)
  • Minimise (443-448)
  • UnMinimise (450-455)
  • IsFullscreen (371-375)
  • IsMaximised (377-381)
  • IsMinimised (383-387)
  • LoadIndex (655-658)
  • ExecuteJS (714-720)
  • StartDrag (679-685)
  • StartResize (705-712)
  • AllocFileFilterArray (792-795)
  • Opendialog (845-932)
  • MessageDialog (740-788)
  • ShowInspector (941-944)

Comment on lines +87 to +109
func (w *Window) SetApplicationMenu(inmenu *menu.Menu) {
if inmenu == nil {
return
}

// Clean up previous menu
for _, gmenu := range gtkMenuCache {
if gmenu != nil {
C.g_object_unref(C.gpointer(gmenu))
}
}

if w.menubar != nil {
C.gtk_widget_unparent(w.menubar)
w.menubar = nil
}

menuItemToId = make(map[*menu.MenuItem]int)
menuIdToItem = make(map[int]*menu.MenuItem)
gtkMenuCache = make(map[*menu.MenuItem]*C.GMenu)

processMenu(w, inmenu)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Persist the application menu before rebuilding

Line 87 returns immediately when inmenu is nil, and nowhere else do we assign to w.applicationMenu. As a result, MenuUpdateApplicationMenu() always sees a nil menu and becomes a no-op after the first call. Please store the menu pointer up front so refreshes keep working.

 func (w *Window) SetApplicationMenu(inmenu *menu.Menu) {
+	w.applicationMenu = inmenu
+
 	if inmenu == nil {
 		return
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func (w *Window) SetApplicationMenu(inmenu *menu.Menu) {
if inmenu == nil {
return
}
// Clean up previous menu
for _, gmenu := range gtkMenuCache {
if gmenu != nil {
C.g_object_unref(C.gpointer(gmenu))
}
}
if w.menubar != nil {
C.gtk_widget_unparent(w.menubar)
w.menubar = nil
}
menuItemToId = make(map[*menu.MenuItem]int)
menuIdToItem = make(map[int]*menu.MenuItem)
gtkMenuCache = make(map[*menu.MenuItem]*C.GMenu)
processMenu(w, inmenu)
}
func (w *Window) SetApplicationMenu(inmenu *menu.Menu) {
// Persist for future updates
w.applicationMenu = inmenu
if inmenu == nil {
return
}
// Clean up previous menu
for _, gmenu := range gtkMenuCache {
if gmenu != nil {
C.g_object_unref(C.gpointer(gmenu))
}
}
if w.menubar != nil {
C.gtk_widget_unparent(w.menubar)
w.menubar = nil
}
menuItemToId = make(map[*menu.MenuItem]int)
menuIdToItem = make(map[int]*menu.MenuItem)
gtkMenuCache = make(map[*menu.MenuItem]*C.GMenu)
processMenu(w, inmenu)
}
🤖 Prompt for AI Agents
v2/internal/frontend/desktop/linux/menu_webkit6.go around lines 87-109: the
function currently returns immediately when inmenu is nil and never assigns
w.applicationMenu, so future refreshes see nil; fix by persisting the incoming
menu pointer at the top (set w.applicationMenu = inmenu), and if inmenu is nil
clear any existing native menu state/caches and return; otherwise continue with
the existing cleanup and rebuild logic so MenuUpdateApplicationMenu() can find
the stored menu on subsequent calls.

@leaanthony
Copy link
Member

@Sammy-T - Thanks for your continued effort on this 🙏 Is it still a WIP? Wondering if we should convert this to draft?

@Sammy-T
Copy link
Author

Sammy-T commented Oct 2, 2025

@leaanthony Thanks. It's been a lot of work and I wasn't sure I'd even get this far. Sorry if I've been spamming you. I wasn't expecting to get hit with all those suggestions. Some of them were relevant. I can switch it back to draft.

Currently, this PR is working with the exception of missing some of the window control that was removed in gtk4 (I've marked them in the code as todo comments).

I was hoping you could test it out and also take a look at the todos to see if you know of any workarounds/updates?

@Sammy-T Sammy-T marked this pull request as draft October 2, 2025 02:28
This sets the transparency for the entire widget including the menu and the webview's contents.
@Sammy-T Sammy-T marked this pull request as ready for review October 17, 2025 21:56
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

♻️ Duplicate comments (5)
v2/internal/frontend/desktop/linux/window_webkit6.c (2)

387-411: Center/SetPosition/SetMinMaxSize are no-ops; document or feature-flag.

Calls from Go currently give the impression features exist.

  • Add explicit comments in Go calling sites noting these are no-ops on GTK4, or guard with build-tagged capabilities.

Also applies to: 235-249, 251-291


636-641: Incorrect argument type for gdk_toplevel_begin_move/resize.

Pass a GdkToplevel* from the window’s surface, not GtkWindow*.

-    gdk_toplevel_begin_move(options->mainwindow, NULL, mouseButton, xroot, yroot, dragTime);
+    GdkSurface *surface = gtk_native_get_surface(GTK_NATIVE(options->mainwindow));
+    gdk_toplevel_begin_move(GDK_TOPLEVEL(surface), NULL, mouseButton, xroot, yroot, dragTime);
@@
-    gdk_toplevel_begin_resize(options->mainwindow, options->edge, NULL, mouseButton, xroot, yroot, dragTime);
+    GdkSurface *surface = gtk_native_get_surface(GTK_NATIVE(options->mainwindow));
+    gdk_toplevel_begin_resize(GDK_TOPLEVEL(surface), options->edge, NULL, mouseButton, xroot, yroot, dragTime);

Also applies to: 663-667

v2/internal/frontend/desktop/linux/window_webkit6.go (3)

334-360: Wrap Run() GTK mutations on main thread and drop no-op Center().

GTK widget mutations must run on GTK thread. Also Center() is a no-op in GTK4 path.

- if w.menubar != nil {
-     C.gtk_box_prepend(C.GTKBOX(unsafe.Pointer(w.vbox)), w.menubar)
- }
-
- C.gtk_box_prepend(C.GTKBOX(unsafe.Pointer(w.webviewBox)), C.GTKWIDGET(w.webview))
- C.gtk_box_append(C.GTKBOX(unsafe.Pointer(w.vbox)), w.webviewBox)
-
- _url := C.CString(url)
- defer C.free(unsafe.Pointer(_url))
- C.LoadIndex(w.webview, _url)
+ _url := C.CString(url)
+ defer C.free(unsafe.Pointer(_url))
+ invokeOnMainThread(func() {
+     if w.menubar != nil {
+         C.gtk_box_prepend(C.GTKBOX(unsafe.Pointer(w.vbox)), w.menubar)
+     }
+     C.gtk_box_prepend(C.GTKBOX(unsafe.Pointer(w.webviewBox)), C.GTKWIDGET(w.webview))
+     C.gtk_box_append(C.GTKBOX(unsafe.Pointer(w.vbox)), w.webviewBox)
+     C.LoadIndex(w.webview, _url)
+     C.gtk_window_present(w.asGTKWindow())
+ })
  if w.appoptions.StartHidden {
      w.Hide()
  }
 
- C.gtk_window_present(w.asGTKWindow())
-
- w.Center()
  switch w.appoptions.WindowStartState {

501-511: GTK dialog called from goroutine; dispatch to main thread.

This is unsafe for GTK. Use invokeOnMainThread.

-    go func() {
-        data := C.MessageDialogOptions{
-            title:       C.CString(title),
-            message:     C.CString(message),
-            messageType: C.int(1),
-        }
-
-        C.MessageDialog(unsafe.Pointer(&data))
-    }()
+    go func() {
+        data := C.MessageDialogOptions{
+            title:       C.CString(title),
+            message:     C.CString(message),
+            messageType: C.int(1),
+        }
+        invokeOnMainThread(func() { C.MessageDialog(unsafe.Pointer(&data)) })
+    }()

182-184: Incorrect cast: asGTKBox must return the box widget, not the window.

Casting w.gtkWindow to GtkBox is invalid and may crash if used.

 func (w *Window) asGTKBox() *C.GtkBox {
-    return C.GTKBOX(w.gtkWindow)
+    return C.GTKBOX(unsafe.Pointer(w.vbox))
 }
🧹 Nitpick comments (6)
v2/internal/frontend/desktop/linux/window_webkit6.go (4)

133-135: Remove unused variable.

buttonPressedName is allocated and freed but never used.

- buttonPressedName := C.CString("button-press-event")
- defer C.free(unsafe.Pointer(buttonPressedName))
- C.ConnectButtons(unsafe.Pointer(webview))
+ C.ConnectButtons(unsafe.Pointer(webview))

362-365: SetKeepAbove is a stub; document or feature-flag it.

It does nothing on GTK4. Consider documenting the limitation or guarding the API to avoid misleading callers.


371-377: Prefer gtk_window_set_default_size OR provide a resize API; current SetSize duplicates SetDefaultSize.

If intentional, comment why. Otherwise, expose a Resize that changes current size.


222-232: Size() returns default size, not current size.

If the intent is current geometry, consider using a GTK4-appropriate getter (or document this).

v2/internal/frontend/desktop/linux/window_webkit6.c (2)

187-195: Do not unref the CSS provider if you reuse it later.

You store windowCssProvider globally and call load_from_data later; keep a strong ref.

-        windowCssProvider = gtk_css_provider_new();
-        gtk_style_context_add_provider(
+        windowCssProvider = gtk_css_provider_new();
+        gtk_style_context_add_provider(
             gtk_widget_get_style_context(GTK_WIDGET(options->webviewBox)),
             GTK_STYLE_PROVIDER(windowCssProvider),
             GTK_STYLE_PROVIDER_PRIORITY_USER);
-        g_object_unref(windowCssProvider);
+        // keep our reference; free when tearing down the window if needed

Also applies to: 197-204


551-552: Remove unused stub.

onDelete is defined but unused.

-static void onDelete(GtkWidget* self) {}
+// (removed unused stub)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c102d74 and e91a12c.

📒 Files selected for processing (3)
  • v2/internal/frontend/desktop/linux/window_webkit6.c (1 hunks)
  • v2/internal/frontend/desktop/linux/window_webkit6.go (1 hunks)
  • v2/internal/frontend/desktop/linux/window_webkit6.h (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
v2/internal/frontend/desktop/linux/window_webkit6.go (5)
v2/internal/frontend/desktop/linux/window.go (2)
  • NewWindow (62-149)
  • Window (40-53)
v2/internal/frontend/desktop/linux/window_webkit6.c (36)
  • SetupInvokeSignal (125-128)
  • SetupWebview (554-605)
  • ConnectButtons (351-361)
  • DevtoolsEnabled (607-617)
  • InstallF12Hotkey (915-925)
  • DisableContextMenu (300-304)
  • SetBackgroundColour (157-204)
  • SetTitle (216-222)
  • SetWindowIcon (131-147)
  • SetWindowTransparency (149-153)
  • GTKWIDGET (30-33)
  • GTKWINDOW (35-38)
  • GTKBOX (40-43)
  • Fullscreen (455-471)
  • ExecuteOnMainThread (25-28)
  • UnFullscreen (473-478)
  • Center (389-411)
  • SetPosition (237-249)
  • SetMinMaxSize (252-291)
  • Show (413-418)
  • Hide (420-425)
  • Maximise (427-432)
  • UnMaximise (434-439)
  • Minimise (441-446)
  • UnMinimise (448-453)
  • IsFullscreen (363-367)
  • IsMaximised (369-373)
  • IsMinimised (375-385)
  • LoadIndex (619-622)
  • ExecuteJS (678-684)
  • StartDrag (643-649)
  • StartResize (669-676)
  • AllocFileFilterArray (756-759)
  • Opendialog (809-896)
  • MessageDialog (704-752)
  • ShowInspector (905-908)
v2/pkg/options/linux/linux.go (2)
  • WebviewGpuPolicy (4-4)
  • WebviewGpuPolicyNever (12-12)
v2/pkg/options/options.go (5)
  • DragAndDrop (201-216)
  • RGBA (111-116)
  • WindowStartState (22-22)
  • Minimised (27-27)
  • Maximised (26-26)
v2/internal/frontend/desktop/linux/calloc.go (1)
  • NewCalloc (18-20)
v2/internal/frontend/desktop/linux/window_webkit6.c (3)
v2/internal/frontend/runtime/desktop/events.js (1)
  • data (105-105)
v2/internal/frontend/runtime/desktop/draganddrop.js (1)
  • files (136-136)
v2/internal/frontend/desktop/linux/dialog.go (1)
  • GTK_FILE_CHOOSER_ACTION_SAVE (19-19)
v2/internal/frontend/desktop/linux/window_webkit6.h (1)
v2/internal/frontend/desktop/linux/window_webkit6.c (39)
  • ExecuteOnMainThread (25-28)
  • GTKWIDGET (30-33)
  • GTKWINDOW (35-38)
  • GTKBOX (40-43)
  • SetupInvokeSignal (125-128)
  • SetWindowIcon (131-147)
  • SetWindowTransparency (149-153)
  • SetBackgroundColour (157-204)
  • SetTitle (216-222)
  • SetPosition (237-249)
  • SetMinMaxSize (252-291)
  • DisableContextMenu (300-304)
  • ConnectButtons (351-361)
  • IsFullscreen (363-367)
  • IsMaximised (369-373)
  • IsMinimised (375-385)
  • Center (389-411)
  • Show (413-418)
  • Hide (420-425)
  • Maximise (427-432)
  • UnMaximise (434-439)
  • Minimise (441-446)
  • UnMinimise (448-453)
  • Fullscreen (455-471)
  • UnFullscreen (473-478)
  • SetupWebview (554-605)
  • LoadIndex (619-622)
  • DevtoolsEnabled (607-617)
  • ExecuteJS (678-684)
  • StartDrag (643-649)
  • StartResize (669-676)
  • MessageDialog (704-752)
  • AllocFileFilterArray (756-759)
  • Opendialog (809-896)
  • sendShowInspectorMessage (910-912)
  • ShowInspector (905-908)
  • InstallF12Hotkey (915-925)
  • createApp (933-937)
  • runApp (939-942)
🪛 Clang (14.0.6)
v2/internal/frontend/desktop/linux/window_webkit6.c

[error] 4-4: 'jsc/jsc.h' file not found

(clang-diagnostic-error)

v2/internal/frontend/desktop/linux/window_webkit6.h

[error] 7-7: 'jsc/jsc.h' file not found

(clang-diagnostic-error)

🔇 Additional comments (1)
v2/internal/frontend/desktop/linux/window_webkit6.go (1)

6-12: Based on my research, the original JavaScriptCore API (e.g. JSContextRef and JSObjectRef) has been replaced by the GObject-style JavaScriptCore API (e.g. [[email protected]] and [[email protected]]) that is available since 2.22, and this is available in javascriptcoregtk-6.0. Additionally, the Ubuntu bug tracker shows that jsc/jsc.h: No such file or directory errors occur when the header is not properly included, and multiple real-world examples demonstrate that projects building with WebKit report missing javascriptcoregtk as a separate dependency requirement.

The review comment is technically sound: the code includes <jsc/jsc.h>, which requires a separate pkg-config declaration for javascriptcoregtk-6.0. The suggested diff is correct.

Add missing pkg-config for JavaScriptCore to fix 'jsc/jsc.h' include.

The JavaScriptCore 6.0 API is a separate package that must be declared in pkg-config flags. Without javascriptcoregtk-6.0, compilation will fail.

Apply:

 /*
-#cgo pkg-config: gtk4 webkitgtk-6.0
+#cgo pkg-config: gtk4 webkitgtk-6.0 javascriptcoregtk-6.0

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

♻️ Duplicate comments (9)
v2/internal/frontend/desktop/linux/window_webkit6.go (5)

350-351: Center() is a no‑op on GTK4; drop the call or annotate.

Avoid misleading no‑op calls until implemented.

Apply this diff:

-	w.Center()
+	// Center() is currently a no-op on GTK4/webkit_6.

327-331: SetWindowIcon currently calls a stub.

No icon will be set under webkit_6. Either implement in C or gate this call behind availability and log a single warning.


181-183: Fix incorrect cast in asGTKBox().

Casting GtkWindow to GtkBox is invalid; return the actual box.

Apply this diff:

 func (w *Window) asGTKBox() *C.GtkBox {
-	return C.GTKBOX(w.gtkWindow)
+	return C.GTKBOX(unsafe.Pointer(w.vbox))
 }

403-412: Quit() is a no‑op on GTK4; call GApplication quit.

When mainLoop is nil, the app never exits. Keep the guard and also quit the GApplication on the GTK thread.

Apply this diff:

 func (w *Window) Quit() {
-	if mainLoop == nil {
-		return
-	}
-
-	C.g_main_loop_quit(mainLoop)
-	C.g_main_loop_unref(mainLoop)
-
-	mainLoop = nil
+	if mainLoop != nil {
+		C.g_main_loop_quit(mainLoop)
+		C.g_main_loop_unref(mainLoop)
+		mainLoop = nil
+	}
+	invokeOnMainThread(func() {
+		C.g_application_quit((*C.GApplication)(unsafe.Pointer(w.gtkApp)))
+	})
 }

500-514: Call MessageDialog on the GTK main thread (no goroutine).

GTK APIs must run on the main thread.

Apply this diff:

 func showModalDialogAndExit(title, message string) {
-	go func() {
-		data := C.MessageDialogOptions{
-			title:       C.CString(title),
-			message:     C.CString(message),
-			messageType: C.int(1),
-		}
-
-		C.MessageDialog(unsafe.Pointer(&data))
-	}()
+	invokeOnMainThread(func() {
+		data := C.MessageDialogOptions{
+			title:       C.CString(title),
+			message:     C.CString(message),
+			messageType: C.int(1),
+		}
+		C.MessageDialog(unsafe.Pointer(&data))
+	})
 
 	<-messageDialogResult
 	log.Fatal(message)
 }
v2/internal/frontend/desktop/linux/window_webkit6.c (4)

393-416: Center() is intentionally a no‑op (GTK4 removed move).

Either implement a GTK4 alternative later or keep as documented no‑op. Ensure the Go call site doesn’t invoke it (see window_webkit6.go Lines 350‑351).


642-647: Fix type passed to gdk_toplevel_begin_move.

First arg must be GdkToplevel*. Convert from GtkWindow via GtkNative/GdkSurface.

Apply this diff:

-    gdk_toplevel_begin_move(options->mainwindow, NULL, mouseButton, xroot, yroot, dragTime);
+    GdkSurface *surface = gtk_native_get_surface(GTK_NATIVE(options->mainwindow));
+    gdk_toplevel_begin_move(GDK_TOPLEVEL(surface), NULL, mouseButton, xroot, yroot, dragTime);

669-673: Fix type passed to gdk_toplevel_begin_resize.

Same conversion needed as for move.

Apply this diff:

-    gdk_toplevel_begin_resize(options->mainwindow, options->edge, NULL, mouseButton, xroot, yroot, dragTime);
+    GdkSurface *surface = gtk_native_get_surface(GTK_NATIVE(options->mainwindow));
+    gdk_toplevel_begin_resize(GDK_TOPLEVEL(surface), options->edge, NULL, mouseButton, xroot, yroot, dragTime);

760-760: Fix invalid C prototype order (“void extern”).

C requires “extern void …”.

Apply this diff:

-void extern processOpenFileResult(void *);
+extern void processOpenFileResult(void *);
🧹 Nitpick comments (2)
v2/internal/frontend/desktop/linux/window_webkit6.go (1)

6-9: Surface required system packages in “doctor” for -tags webkit_6.

Add doctor checks to verify gtk4 and webkitgtk-6.0 dev packages and headers (e.g., jsc/jsc.h). This will preempt build failures.

v2/internal/frontend/desktop/linux/window_webkit6.h (1)

7-9: Build deps: ensure jsc/jsc.h is available.

Document that webkitgtk-6.0 (packages providing JavaScriptCore headers) must be installed; consider adding a doctor check.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e91a12c and 1b40dda.

📒 Files selected for processing (3)
  • v2/internal/frontend/desktop/linux/window_webkit6.c (1 hunks)
  • v2/internal/frontend/desktop/linux/window_webkit6.go (1 hunks)
  • v2/internal/frontend/desktop/linux/window_webkit6.h (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
v2/internal/frontend/desktop/linux/window_webkit6.go (4)
v2/internal/frontend/desktop/linux/window.go (2)
  • NewWindow (62-149)
  • Window (40-53)
v2/internal/frontend/desktop/linux/window_webkit6.c (36)
  • SetupInvokeSignal (130-133)
  • SetupWebview (560-611)
  • ConnectButtons (356-366)
  • DevtoolsEnabled (613-623)
  • InstallF12Hotkey (921-931)
  • DisableContextMenu (305-309)
  • SetBackgroundColour (162-209)
  • SetTitle (221-227)
  • SetWindowIcon (136-152)
  • SetWindowTransparency (154-158)
  • GTKWIDGET (30-33)
  • GTKWINDOW (35-38)
  • GTKBOX (40-43)
  • Fullscreen (460-476)
  • ExecuteOnMainThread (25-28)
  • UnFullscreen (478-483)
  • Center (394-416)
  • SetPosition (242-254)
  • SetMinMaxSize (257-296)
  • Show (418-423)
  • Hide (425-430)
  • Maximise (432-437)
  • UnMaximise (439-444)
  • Minimise (446-451)
  • UnMinimise (453-458)
  • IsFullscreen (368-372)
  • IsMaximised (374-378)
  • IsMinimised (380-390)
  • LoadIndex (625-628)
  • ExecuteJS (684-690)
  • StartDrag (649-655)
  • StartResize (675-682)
  • AllocFileFilterArray (762-765)
  • Opendialog (815-902)
  • MessageDialog (710-758)
  • ShowInspector (911-914)
v2/pkg/options/linux/linux.go (2)
  • WebviewGpuPolicy (4-4)
  • WebviewGpuPolicyNever (12-12)
v2/internal/frontend/desktop/linux/calloc.go (1)
  • NewCalloc (18-20)
v2/internal/frontend/desktop/linux/window_webkit6.c (2)
v2/internal/frontend/runtime/desktop/draganddrop.js (1)
  • files (136-136)
v2/internal/frontend/desktop/linux/dialog.go (1)
  • GTK_FILE_CHOOSER_ACTION_SAVE (19-19)
v2/internal/frontend/desktop/linux/window_webkit6.h (1)
v2/internal/frontend/desktop/linux/window_webkit6.c (39)
  • ExecuteOnMainThread (25-28)
  • GTKWIDGET (30-33)
  • GTKWINDOW (35-38)
  • GTKBOX (40-43)
  • SetupInvokeSignal (130-133)
  • SetWindowIcon (136-152)
  • SetWindowTransparency (154-158)
  • SetBackgroundColour (162-209)
  • SetTitle (221-227)
  • SetPosition (242-254)
  • SetMinMaxSize (257-296)
  • DisableContextMenu (305-309)
  • ConnectButtons (356-366)
  • IsFullscreen (368-372)
  • IsMaximised (374-378)
  • IsMinimised (380-390)
  • Center (394-416)
  • Show (418-423)
  • Hide (425-430)
  • Maximise (432-437)
  • UnMaximise (439-444)
  • Minimise (446-451)
  • UnMinimise (453-458)
  • Fullscreen (460-476)
  • UnFullscreen (478-483)
  • SetupWebview (560-611)
  • LoadIndex (625-628)
  • DevtoolsEnabled (613-623)
  • ExecuteJS (684-690)
  • StartDrag (649-655)
  • StartResize (675-682)
  • MessageDialog (710-758)
  • AllocFileFilterArray (762-765)
  • Opendialog (815-902)
  • sendShowInspectorMessage (916-918)
  • ShowInspector (911-914)
  • InstallF12Hotkey (921-931)
  • createApp (939-943)
  • runApp (945-948)
🪛 Clang (14.0.6)
v2/internal/frontend/desktop/linux/window_webkit6.c

[error] 4-4: 'jsc/jsc.h' file not found

(clang-diagnostic-error)

v2/internal/frontend/desktop/linux/window_webkit6.h

[error] 7-7: 'jsc/jsc.h' file not found

(clang-diagnostic-error)

Comment on lines +233 to +245
func (w *Window) GetPosition() (int, int) {
//// TODO: gtk_window_get_position was removed in gtk4
// var width, height C.int
// var wg sync.WaitGroup
// wg.Add(1)
// invokeOnMainThread(func() {
// C.gtk_window_get_position(w.asGTKWindow(), &width, &height)
// wg.Done()
// })
// wg.Wait()
// return int(width), int(height)
return 0, 0
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Position/min/max size are stubs; options are silently ignored.

GetPosition returns (0,0) and SetMin/MaxSize call a no-op C function. Either implement a GTK4-friendly fallback (size-allocate clamping) or clearly document the limitation and log once at startup.

Would you like a follow-up patch that clamps sizes via size-allocate and signals?

Also applies to: 247-261

🤖 Prompt for AI Agents
In v2/internal/frontend/desktop/linux/window_webkit6.go around lines 233-245
(and similarly for 247-261), GetPosition currently returns a hardcoded (0,0) and
SetMin/SetMaxSize are no-ops which silently ignore limits; replace these stubs
with a GTK4-compatible implementation or add a clear one-time startup log and
documented limitation: implement size clamping by connecting to the
"size-allocate" signal on the GTK window (on the main thread) to enforce min/max
constraints and maintain/return the last known position from allocate/configure
events, or if you cannot implement clamping now, add a single startup log
warning explaining that position/min/max are not supported on GTK4 and ensure
the functions return deterministic values and do not silently ignore inputs.

@Sammy-T
Copy link
Author

Sammy-T commented Oct 17, 2025

@leaanthony I don't see any workarounds for gtk4's removal of window positioning and I'll respect that that's the direction they want to go in so I've just left it as is. I've fixed checking window minimization state. Drag and drop should be working now. And I added window transparency but just be aware that the transparency affects the entire widget including the menu and all of the webview's contents.

I'm marking this as ready. I've done all I can and it does successfully utilize webkitgtk-6.

@Sammy-T
Copy link
Author

Sammy-T commented Nov 1, 2025

@leaanthony Are you able to look this over?

Copy link
Member

@leaanthony leaanthony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question: just wondering why you went with #ifdef in some files and separating out the different versions using the filename convention in others. I'm not against it but the separation pattern is what we have elsewhere. Might be easier to read? Just curious

@Sammy-T
Copy link
Author

Sammy-T commented Nov 3, 2025

Yeah, I don't consider it ideal either. But my intent was to reduce the amount of duplicated files/code where there was little to no change in the Go side of the code. Do you want me to migrate the ifdefs to the separate file strategy instead?

@leaanthony
Copy link
Member

I think it might be easier to follow/debug? Might be something an LLM can do reasonably quickly.

I'm going to try and get a v2 release out today and will look at including this in the next release. I'll install a fresh linux to test today.

@Sammy-T
Copy link
Author

Sammy-T commented Nov 9, 2025

Alright. That's great. I prefer to migrate it myself. But I'll try to get it done soon.

@Sammy-T
Copy link
Author

Sammy-T commented Nov 9, 2025

The ifdefs are replaced now.

@leaanthony
Copy link
Member

Legend! 👍

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 96fe012 and bd50c5a.

📒 Files selected for processing (14)
  • v2/internal/frontend/desktop/linux/clipboard.go (1 hunks)
  • v2/internal/frontend/desktop/linux/clipboard_webkit6.go (1 hunks)
  • v2/internal/frontend/desktop/linux/frontend.go (1 hunks)
  • v2/internal/frontend/desktop/linux/frontend_webkit6.go (1 hunks)
  • v2/internal/frontend/desktop/linux/keys.go (1 hunks)
  • v2/internal/frontend/desktop/linux/keys_webkit6.go (1 hunks)
  • v2/internal/frontend/desktop/linux/webkit2.go (1 hunks)
  • v2/internal/frontend/desktop/linux/webkit6.go (1 hunks)
  • v2/pkg/assetserver/webview/request_linux.go (1 hunks)
  • v2/pkg/assetserver/webview/request_linux_webkit6.go (1 hunks)
  • v2/pkg/assetserver/webview/responsewriter_linux.go (1 hunks)
  • v2/pkg/assetserver/webview/responsewriter_linux_webkit6.go (1 hunks)
  • v2/pkg/assetserver/webview/webkit2_36+.go (1 hunks)
  • v2/pkg/assetserver/webview/webkit6.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • v2/pkg/assetserver/webview/webkit2_36+.go
🚧 Files skipped from review as they are similar to previous changes (5)
  • v2/internal/frontend/desktop/linux/webkit2.go
  • v2/pkg/assetserver/webview/responsewriter_linux.go
  • v2/pkg/assetserver/webview/request_linux.go
  • v2/internal/frontend/desktop/linux/keys.go
  • v2/internal/frontend/desktop/linux/clipboard.go
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: Mihara
Repo: wailsapp/wails PR: 4481
File: v3/internal/commands/updatable_build_assets/linux/nfpm/nfpm.yaml.tmpl:29-30
Timestamp: 2025-08-08T10:25:32.415Z
Learning: For Wails v3 Linux nfpm template, Debian/Ubuntu WebKitGTK runtime package names differ: Debian 12 (Bookworm) uses libwebkit2gtk-4.1-0 while Ubuntu 22.04 (Jammy) uses libwebkit2gtk-4.0-37. Prefer an OR dependency "libwebkit2gtk-4.1-0 | libwebkit2gtk-4.0-37" in v3/internal/commands/updatable_build_assets/linux/nfpm/nfpm.yaml.tmpl to support both.
Learnt from: Sammy-T
Repo: wailsapp/wails PR: 4570
File: v2/internal/frontend/desktop/linux/window_webkit6.go:97-108
Timestamp: 2025-10-17T23:16:11.570Z
Learning: For webkit_6/GTK4 builds in v2/internal/frontend/desktop/linux/window_webkit6.go, GTK widget creation should not be wrapped in invokeOnMainThread. The activation mechanism (activateWg + onActivate export) already handles thread safety, and additional wrapping would cause issues.
Learnt from: Mihara
Repo: wailsapp/wails PR: 4481
File: v3/internal/commands/updatable_build_assets/linux/nfpm/nfpm.yaml.tmpl:37-38
Timestamp: 2025-08-08T11:10:17.787Z
Learning: In Wails v3 nfpm templates for RPM (RHEL-family), do not use a boolean OR between webkit2gtk3 and webkit2gtk4.1. Binaries built against WebKitGTK 4.1 are not ABI-compatible with 4.0, so the dependency must be pinned to the exact ABI: use webkit2gtk4.1 for 4.1 builds (e.g., RHEL/Rocky 10) and webkit2gtk3 for 4.0 builds (RHEL/Rocky 8/9).
Learnt from: Mihara
Repo: wailsapp/wails PR: 4481
File: v3/internal/commands/updatable_build_assets/linux/nfpm/nfpm.yaml.tmpl:29-30
Timestamp: 2025-08-08T10:25:32.415Z
Learning: Ubuntu 22.04 (Jammy) official repos include both WebKitGTK runtimes: libwebkit2gtk-4.0-37 and libwebkit2gtk-4.1-0 (Universe). For nfpm templates, depend on the exact SONAME matching the built ABI (use libwebkit2gtk-4.1-0 when targeting 4.1; use libwebkit2gtk-4.0-37 when targeting 4.0) rather than an OR across ABIs.
📚 Learning: 2025-10-17T23:16:11.570Z
Learnt from: Sammy-T
Repo: wailsapp/wails PR: 4570
File: v2/internal/frontend/desktop/linux/window_webkit6.go:97-108
Timestamp: 2025-10-17T23:16:11.570Z
Learning: For webkit_6/GTK4 builds in v2/internal/frontend/desktop/linux/window_webkit6.go, GTK widget creation should not be wrapped in invokeOnMainThread. The activation mechanism (activateWg + onActivate export) already handles thread safety, and additional wrapping would cause issues.

Applied to files:

  • v2/internal/frontend/desktop/linux/frontend.go
  • v2/internal/frontend/desktop/linux/keys_webkit6.go
  • v2/pkg/assetserver/webview/request_linux_webkit6.go
  • v2/pkg/assetserver/webview/responsewriter_linux_webkit6.go
  • v2/internal/frontend/desktop/linux/clipboard_webkit6.go
  • v2/pkg/assetserver/webview/webkit6.go
  • v2/internal/frontend/desktop/linux/webkit6.go
  • v2/internal/frontend/desktop/linux/frontend_webkit6.go
📚 Learning: 2025-08-08T10:25:32.415Z
Learnt from: Mihara
Repo: wailsapp/wails PR: 4481
File: v3/internal/commands/updatable_build_assets/linux/nfpm/nfpm.yaml.tmpl:29-30
Timestamp: 2025-08-08T10:25:32.415Z
Learning: For Wails v3 Linux nfpm template, Debian/Ubuntu WebKitGTK runtime package names differ: Debian 12 (Bookworm) uses libwebkit2gtk-4.1-0 while Ubuntu 22.04 (Jammy) uses libwebkit2gtk-4.0-37. Prefer an OR dependency "libwebkit2gtk-4.1-0 | libwebkit2gtk-4.0-37" in v3/internal/commands/updatable_build_assets/linux/nfpm/nfpm.yaml.tmpl to support both.

Applied to files:

  • v2/internal/frontend/desktop/linux/frontend.go
  • v2/pkg/assetserver/webview/webkit6.go
  • v2/internal/frontend/desktop/linux/webkit6.go
📚 Learning: 2025-08-08T09:13:16.916Z
Learnt from: APshenkin
Repo: wailsapp/wails PR: 4480
File: v2/internal/frontend/desktop/darwin/message.h:17-19
Timestamp: 2025-08-08T09:13:16.916Z
Learning: In Wails v2 bindings origin verification, processBindingMessage intentionally has different signatures across platforms: Darwin includes an isMainFrame bool (WKWebKit provides it), Linux uses two params (message, source) as WebKitGTK doesn’t expose main-frame info there, and Windows handles origin checks in Go via WebView2 sender/args without a C bridge. This divergence is acceptable/expected per maintainer (APshenkin).

Applied to files:

  • v2/pkg/assetserver/webview/responsewriter_linux_webkit6.go
  • v2/pkg/assetserver/webview/webkit6.go
  • v2/internal/frontend/desktop/linux/webkit6.go
  • v2/internal/frontend/desktop/linux/frontend_webkit6.go
📚 Learning: 2025-08-08T11:10:17.787Z
Learnt from: Mihara
Repo: wailsapp/wails PR: 4481
File: v3/internal/commands/updatable_build_assets/linux/nfpm/nfpm.yaml.tmpl:37-38
Timestamp: 2025-08-08T11:10:17.787Z
Learning: In Wails v3 nfpm templates for RPM (RHEL-family), do not use a boolean OR between webkit2gtk3 and webkit2gtk4.1. Binaries built against WebKitGTK 4.1 are not ABI-compatible with 4.0, so the dependency must be pinned to the exact ABI: use webkit2gtk4.1 for 4.1 builds (e.g., RHEL/Rocky 10) and webkit2gtk3 for 4.0 builds (RHEL/Rocky 8/9).

Applied to files:

  • v2/pkg/assetserver/webview/webkit6.go
  • v2/internal/frontend/desktop/linux/webkit6.go
📚 Learning: 2025-08-08T10:25:32.415Z
Learnt from: Mihara
Repo: wailsapp/wails PR: 4481
File: v3/internal/commands/updatable_build_assets/linux/nfpm/nfpm.yaml.tmpl:29-30
Timestamp: 2025-08-08T10:25:32.415Z
Learning: Ubuntu 22.04 (Jammy) official repos include both WebKitGTK runtimes: libwebkit2gtk-4.0-37 and libwebkit2gtk-4.1-0 (Universe). For nfpm templates, depend on the exact SONAME matching the built ABI (use libwebkit2gtk-4.1-0 when targeting 4.1; use libwebkit2gtk-4.0-37 when targeting 4.0) rather than an OR across ABIs.

Applied to files:

  • v2/pkg/assetserver/webview/webkit6.go
  • v2/internal/frontend/desktop/linux/webkit6.go
📚 Learning: 2024-09-30T06:13:46.595Z
Learnt from: leaanthony
Repo: wailsapp/wails PR: 3763
File: v3/examples/window/main.go:472-475
Timestamp: 2024-09-30T06:13:46.595Z
Learning: In `v3/examples/window/main.go`, `time.Sleep` is used within a goroutine and does not block the UI thread.

Applied to files:

  • v2/internal/frontend/desktop/linux/frontend_webkit6.go
🧬 Code graph analysis (5)
v2/internal/frontend/desktop/linux/keys_webkit6.go (1)
v2/pkg/menu/keys/keys.go (5)
  • Modifier (9-9)
  • ShiftKey (17-17)
  • ControlKey (21-21)
  • CmdOrCtrlKey (13-13)
  • OptionOrAltKey (15-15)
v2/pkg/assetserver/webview/request_linux_webkit6.go (2)
v2/pkg/assetserver/webview/request.go (1)
  • Request (8-17)
v2/pkg/assetserver/webview/responsewriter.go (1)
  • ResponseWriter (20-25)
v2/internal/frontend/desktop/linux/clipboard_webkit6.go (1)
v2/internal/frontend/desktop/windows/win32/clipboard.go (2)
  • GetClipboardText (37-75)
  • SetClipboardText (77-143)
v2/internal/frontend/desktop/linux/webkit6.go (1)
v2/pkg/assetserver/webview/webkit6.go (1)
  • Webkit2MinMinorVersion (23-23)
v2/internal/frontend/desktop/linux/frontend_webkit6.go (6)
v2/pkg/options/options.go (4)
  • SecondInstanceData (196-199)
  • SingleInstanceLock (190-194)
  • RGBA (111-116)
  • DragAndDrop (201-216)
v2/internal/frontend/originvalidator/originValidator.go (2)
  • OriginValidator (10-12)
  • NewOriginValidator (15-23)
v2/pkg/assetserver/assetserver.go (1)
  • NewAssetServerMainPage (53-59)
v2/pkg/assetserver/webview/request.go (1)
  • Request (8-17)
v2/pkg/assetserver/webview/request_linux.go (1)
  • NewRequest (23-29)
v2/pkg/assetserver/webview/request_linux_webkit6.go (1)
  • NewRequest (21-27)

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
6 Security Hotspots
50.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade to webkitgtk-6.0

3 participants