Repository navigation
Linux: report both WebKitGTK load errors; never switch on Xlib threads late - #68
Merged
Merged
Conversation
The Linux loader kept only the last dlerror(), so a 4.1 library that was installed but failed to load read exactly like a host with no WebKitGTK. Each attempt's reason is now kept, for WebKit and JavaScriptCore alike. JNI_OnLoad's JNI_ERR makes the JVM throw a generic "unsupported JNI version 0xFFFFFFFF", so the reason only ever reached stderr. The loader now also sets the system property ca.weblite.webview.nativeLoadError before failing, so an embedder can tell the user why the WebView is unavailable. Publishing is best effort and never changes the outcome. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KJGbJfSqGDbZWCbUnoKYVx
Xlib needs XInitThreads() before any display is opened. The jDeploy launcher initialises GTK for its splash before the JVM starts, so the pump's gtk_init reuses a display that has no locks; the pump's late XInitThreads() then makes Xlib lock it, and the first cursor WebKit loads (Xcursor -> XGetDefault -> XrmQGetResource) calls pthread_mutex_lock(NULL) on libX11 1.7.x (Ubuntu 22.04): a SIGSEGV on focusing any text field, seen with a core dump. GtkPump::ensure_started now calls XInitThreads() only when gdk_display_get_default() is NULL, i.e. when nothing has opened a GDK display yet. Reproduced on Ubuntu 22.04 / libX11 1.7.5 with a minimal GTK program: late XInitThreads -> SIGSEGV; skipped -> survives. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KJGbJfSqGDbZWCbUnoKYVx
shannah
marked this pull request as ready for review
October 3, 2026 14:10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two Linux fixes found while getting an agentic-app-framework app (Cloudbeds Assistant) running on Ubuntu 22.04.
1. Report both WebKitGTK load errors and publish them to Java (Canvas 8)
On a 22.04 host without WebKitGTK, the loader message showed only the last
dlerror(). So a 4.1 library that is installed but fails to load looked the same as having no WebKitGTK at all. The reason also reached only stderr, because the JVM turnsJNI_ERRinto a genericUnsatisfiedLinkError: unsupported JNI version 0xFFFFFFFF.JNI_OnLoadpublishes the message as the system propertyca.weblite.webview.nativeLoadErrorbefore returningJNI_ERR. This is best effort and never changes the outcome. Embedders read it; webliteca/agentic-app-framework#458 shows it in a dialog.libwebkit2gtk-4.1-0installed, the library loads and the property stays unset.2. Never switch on Xlib threads after a GDK display exists (Canvas 7)
Crash: on Ubuntu 22.04 (libX11 1.7.5), a jDeploy-launched app crashes with
segfault at 10 … in libc.so.6when you focus a text field. The core dump from the affected VM:Cause:
XInitThreads(). With libX11 < 1.8, that display and its resource database get no locks.XInitThreads()late, thengtk_initreuses that display.Change:
GtkPump::ensure_startedcallsXInitThreads()only whengdk_display_get_default()is NULL, that is, when nothing has opened a GDK display yet.gdk_set_allowed_backends("x11")moves ahead of the check, since it must run before the display manager is created. Canvas 7 gets an Approach note, a Structure note and a never-relax Safeguard.Verification with a minimal GTK program on Ubuntu 22.04 / libX11 1.7.5, using a display that has a resource database:
XGetDefault, then a lateXInitThreads(), thenXGetDefault→ SIGSEGV (139).XInitThreads()first (the launcher fix, shannah/client4jgo#78) → survives.The launcher fix is the primary one. This change makes swingwebview safe under any host that initialises GTK first, including launchers that predate that fix.
Both changes build with the release recipe and pass the no-WebKit-NEEDED and glibc ≤ 2.31 gates.
🤖 Generated with Claude Code
https://claude.ai/code/session_01KJGbJfSqGDbZWCbUnoKYVx