The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(appimage): prefer the host WebKitGTK when it is at least as new (#7652)
M3gA-Mind7a2487b221df
diff --git a/.github/workflows/build-desktop.yml b/.github/workflows/build-desktop.ymlindex 9506fd8df8..0702bba432 100644--- a/.github/workflows/build-desktop.yml+++ b/.github/workflows/build-desktop.yml@@ -480,12 +480,13 @@ jobs:fidone- # Strip host graphics libraries (Mesa/libdrm/libva/libgbm) that lib4bin- # ldd-walks into the AppImage. Final-artifact validation runs before- # re-signing: amd64 also gets a bounded Xvfb launch from a foreign CWD,- # while arm64 receives static validation in this change. CEF's own- # SwiftShader subdir is untouched, and updater archives are rebuilt only- # after the validated image is final.+ # Strip host graphics libraries (Mesa/libdrm/libva/libgbm) that the+ # AppImage bundler copies in, and install the AppRun hook that prefers the+ # host's webkit2gtk-4.1 when it is at least as new (#7652). Final-artifact+ # validation runs before re-signing: amd64 also gets bounded Xvfb launches+ # (host and bundled WebKit) from a foreign CWD, while arm64 receives+ # static validation. Updater archives are rebuilt only after the validated+ # image is final.- name: Strip host graphics libs and validate final AppImageif: startsWith(matrix.settings.platform, 'ubuntu-')shell: bashdiff --git a/docs/gitbooks/en/features/platform.md b/docs/gitbooks/en/features/platform.mdindex 2b6c4a011f..4d802f404e 100644--- a/docs/gitbooks/en/features/platform.md+++ b/docs/gitbooks/en/features/platform.md@@ -29,6 +29,8 @@ On Debian and Ubuntu the install script picks the `.deb`. Elsewhere it picks theIf that happens on Debian or Ubuntu, use the `.deb`. On Fedora, openSUSE and other distributions, include the distro version, kernel version, GPU and driver stack, and the exact AppImage filename when you report the problem. That helps maintainers tell host restrictions from a bad AppImage runtime.+The AppImage uses your system's graphics drivers. If your system has `webkit2gtk-4.1` installed and it is at least as new as the bundled copy, the AppImage also uses the system WebKitGTK, so the WebKit build matches your drivers. It prints `using host WebKitGTK from ...` when it does this. To force the bundled copy, launch it with `OPENHUMAN_APPIMAGE_WEBKIT=bundled`.+## Why native mattersNative beats a web wrapper for three reasons.diff --git a/scripts/release/appimage-system-webkit-hook.sh b/scripts/release/appimage-system-webkit-hook.shnew file mode 100644index 0000000000..bb6a4dde99--- /dev/null+++ b/scripts/release/appimage-system-webkit-hook.sh@@ -0,0 +1,62 @@+# shellcheck shell=bash+# linuxdeploy AppRun hook: prefer the host's WebKitGTK over the bundled one (#7652).+#+# strip-appimage-graphics-libs.sh installs this as apprun-hooks/openhuman-system-webkit.sh,+# stamps the bundled library's real name below, and makes AppRun source it before+# every other hook. AppRun provides `$this_dir` (the AppDir) and the positional args.+#+# The bundled WebKitGTK comes from the build runner, but the bundled Mesa/EGL is+# stripped so the host's graphics drivers are used. A host Mesa much newer than the+# bundled WebKitWebProcess can make it abort with "Could not create default EGL+# display: EGL_BAD_PARAMETER" (Fedora 44, Mesa 26.2). When the host has its own+# webkit2gtk-4.1 at least as new as the bundled one, run the app against the host's+# library directory instead, the same as the reporter's working+# `LD_LIBRARY_PATH=/usr/lib64` workaround. The host WebKit then launches its own+# helper processes, built against the host's Mesa. Bundled libraries still cover+# anything the host lacks through the binary's $ORIGIN RUNPATH.+#+# OPENHUMAN_APPIMAGE_WEBKIT=bundled keeps the bundled WebKit.++OPENHUMAN_BUNDLED_WEBKIT='@BUNDLED_WEBKIT@'++# Prints the host directory holding libwebkit2gtk-4.1.so.0 for this machine's+# architecture, from the loader cache.+openhuman_host_webkit_dir() {+ local arch ldconfig lib=""+ case "$(uname -m)" in+ x86_64) arch='x86-64' ;;+ aarch64) arch='AArch64' ;;+ *) return 1 ;;+ esac+ # Debian-family PATHs for normal users omit /sbin.+ for ldconfig in ldconfig /sbin/ldconfig /usr/sbin/ldconfig; do+ lib="$("$ldconfig" -p 2>/dev/null \+ | awk -v arch="$arch" '$1 == "libwebkit2gtk-4.1.so.0" && index($0, arch) { print $NF; exit }')" || lib=""+ [ -n "$lib" ] && break+ done+ [ -n "$lib" ] || return 1+ dirname "$lib"+}++# True when the host's webkit2gtk-4.1 is usable and not older than the bundled one.+# ponytail: compares libtool real names (libwebkit2gtk-4.1.so.0.X.Y), which grow+# with every WebKitGTK release that adds API; an unreadable name keeps the bundle.+openhuman_prefer_host_webkit() {+ local dir="$1" host oldest+ [ -e "$dir/libjavascriptcoregtk-4.1.so.0" ] || return 1+ host="$(basename "$(readlink -f "$dir/libwebkit2gtk-4.1.so.0")")" || return 1+ case "$host" in libwebkit2gtk-4.1.so.0.*) ;; *) return 1 ;; esac+ oldest="$(printf '%s\n%s\n' "$OPENHUMAN_BUNDLED_WEBKIT" "$host" | sort -V 2>/dev/null | head -n 1)" || return 1+ [ "$oldest" = "$OPENHUMAN_BUNDLED_WEBKIT" ]+}++if [ "${OPENHUMAN_APPIMAGE_WEBKIT:-}" != "bundled" ] \+ && openhuman_host_webkit_dir_value="$(openhuman_host_webkit_dir)" \+ && openhuman_prefer_host_webkit "$openhuman_host_webkit_dir_value"; then+ echo "[openhuman] using host WebKitGTK from $openhuman_host_webkit_dir_value (set OPENHUMAN_APPIMAGE_WEBKIT=bundled to use the bundled copy)" >&2+ export LD_LIBRARY_PATH="$openhuman_host_webkit_dir_value${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"+ # The linuxdeploy GTK hook forces X11 for the bundled stack; keep that default.+ export GDK_BACKEND="${GDK_BACKEND:-x11}"+ exec "$this_dir/usr/bin/OpenHuman" "$@"+fi+unset openhuman_host_webkit_dir_valuediff --git a/scripts/release/strip-appimage-graphics-libs.sh b/scripts/release/strip-appimage-graphics-libs.shindex aab68283ef..07c5dc8f3a 100755--- a/scripts/release/strip-appimage-graphics-libs.sh+++ b/scripts/release/strip-appimage-graphics-libs.sh@@ -1,17 +1,18 @@#!/usr/bin/env bash# Strip host graphics libraries from AppImage bundles so they load the user's-# system Mesa/libdrm/libva at launch instead of the older versions baked in by-# lib4bin's ldd-walk on the ubuntu-22.04 build runner.+# system Mesa/libdrm/libva at launch instead of the older versions the AppImage+# bundler copies in from the build runner.#-# Without this, AppImages built on Mesa 22.x fail to initialize on systems-# with newer GPUs (RDNA3, Intel Arc, Lovelace) because the bundled drivers-# can't talk to the host kernel/driver stack. AppImage convention is to never-# ship graphics drivers — they must come from the host. See:+# Without this, AppImages fail to initialize on systems with newer GPUs (RDNA3,+# Intel Arc, Lovelace) because the bundled drivers can't talk to the host+# kernel/driver stack. AppImage convention is to never ship graphics drivers —+# they must come from the host. See:# https://github.com/AppImageCommunity/pkg2appimage/blob/master/excludelist#-# Only top-level lib directories are swept. CEF's own subdirs (swiftshader/,-# locales/, libcef.so neighbors) are left alone — CEF ships its own-# GLES/EGL implementation that must stay bundled.+# Only top-level lib directories are swept, so subdirectories such as the+# bundled webkit2gtk-4.1/ helper directory are left alone. The bundled WebKitGTK+# itself stays, but on a linuxdeploy AppDir an AppRun hook prefers the host's+# webkit2gtk-4.1 when it is at least as new (install_system_webkit_hook, #7652).## Usage: strip-appimage-graphics-libs.sh <bundle-root> [bundle-root...]# where <bundle-root> contains an `appimage/` subdir with *.AppImage files.@@ -773,6 +774,65 @@ patch_apprun_sharun_cwd() {fi}+SYSTEM_WEBKIT_HOOK="openhuman-system-webkit.sh"++# install_system_webkit_hook — make a linuxdeploy AppRun prefer the host's+# webkit2gtk-4.1 (#7652; see appimage-system-webkit-hook.sh for why). The hook is+# sourced before every other hook, so when it execs the app against the host+# WebKit, the bundled GTK hook never runs.+#+# Returns 0 if the hook was installed, 1 if the layout is not linuxdeploy or the+# hook is already there. Exits when the bundled WebKit cannot be identified.+install_system_webkit_hook() {+ local appdir="$1"+ local apprun="$appdir/AppRun"+ [ -f "$apprun" ] || return 1+ [ "$(LC_ALL=C head -c 2 "$apprun" 2>/dev/null || true)" = '#!' ] || return 1+ grep -q 'AppRun\.wrapped' "$apprun" || return 1+ if grep -Fq "$SYSTEM_WEBKIT_HOOK" "$apprun"; then+ return 1+ fi++ # The bundler copied the runner's WebKitGTK, so the runner's real library name+ # is the bundled version.+ local runner_lib bundled+ runner_lib="$(system_module_runtime_library libwebkit2gtk-4.1.so.0)" || runner_lib=""+ bundled="$(basename "$(readlink -f "$runner_lib" 2>/dev/null)" 2>/dev/null)" || bundled=""+ case "$bundled" in+ libwebkit2gtk-4.1.so.0.*) ;;+ *)+ echo "[strip-libs] ERROR: cannot read the build runner's libwebkit2gtk-4.1 version (got '$bundled'); refusing to install the system WebKit hook without it" >&2+ exit 1+ ;;+ esac++ mkdir -p "$appdir/apprun-hooks"+ sed "s|@BUNDLED_WEBKIT@|$bundled|" "$SCRIPT_DIR/appimage-system-webkit-hook.sh" \+ >"$appdir/apprun-hooks/$SYSTEM_WEBKIT_HOOK"++ # Insert before the first hook (or, with none, before the hand-off), after+ # linuxdeploy's `this_dir=` line that the hook relies on.+ local tmp_apprun+ tmp_apprun="$(mktemp)"+ awk -v hook="$SYSTEM_WEBKIT_HOOK" '+ !done && (/^source .*apprun-hooks\// || /^exec .*AppRun\.wrapped/) {+ print "source \"$this_dir\"/apprun-hooks/\"" hook "\""+ print ""+ done = 1+ }+ { print }+ ' "$apprun" >"$tmp_apprun"+ if ! grep -Fq "apprun-hooks/\"$SYSTEM_WEBKIT_HOOK\"" "$tmp_apprun"; then+ rm -f "$tmp_apprun"+ echo "[strip-libs] ERROR: could not find where to source $SYSTEM_WEBKIT_HOOK in the linuxdeploy AppRun" >&2+ exit 1+ fi+ chmod --reference="$apprun" "$tmp_apprun"+ mv "$tmp_apprun" "$apprun"+ echo "[strip-libs] installed apprun-hooks/$SYSTEM_WEBKIT_HOOK (bundled WebKit: $bundled)"+ return 0+}+validate_rebuilt_appimage() {local rebuilt_path="$1""$APPIMAGE_RUNTIME_VALIDATOR" "$rebuilt_path" || return 1@@ -803,6 +863,7 @@ strip_one_appimage() {local rewrote_libpath=0local patched_apprun=0local rewrote_rpaths=0+ local installed_webkit_hook=0if ! stage_module_runtime_libraries "$appdir"; thenrm -rf "$workdir"return 1@@ -848,6 +909,9 @@ strip_one_appimage() {if sanitize_elf_rpaths "$appdir"; thenrewrote_rpaths=1fi+ if install_system_webkit_hook "$appdir"; then+ installed_webkit_hook=1+ fiif ! validate_sharun_lib_path "$appdir"; thenrm -rf "$workdir"return 1@@ -857,7 +921,7 @@ strip_one_appimage() {return 1fi- if [ "$removed" -eq 0 ] && [ "$added_loader" -eq 0 ] && [ "$rewrote_libpath" -eq 0 ] && [ "$patched_apprun" -eq 0 ] && [ "$rewrote_rpaths" -eq 0 ] && [ "$added_module_libraries" -eq 0 ]; then+ if [ "$removed" -eq 0 ] && [ "$added_loader" -eq 0 ] && [ "$rewrote_libpath" -eq 0 ] && [ "$patched_apprun" -eq 0 ] && [ "$rewrote_rpaths" -eq 0 ] && [ "$added_module_libraries" -eq 0 ] && [ "$installed_webkit_hook" -eq 0 ]; thenecho "[strip-libs] No graphics libs, missing sharun interpreter, or build-machine RPATHs found in $original; leaving unchanged."if ! validate_rebuilt_appimage "$original"; thenrm -rf "$workdir"@@ -866,7 +930,7 @@ strip_one_appimage() {rm -rf "$workdir"returnfi- echo "[strip-libs] Removed $removed file(s), added $added_loader loader file(s), patched AppRun=$patched_apprun, rewrote RPATHs=$rewrote_rpaths, staged module libraries=$added_module_libraries; repacking AppImage."+ echo "[strip-libs] Removed $removed file(s), added $added_loader loader file(s), patched AppRun=$patched_apprun, rewrote RPATHs=$rewrote_rpaths, staged module libraries=$added_module_libraries, system WebKit hook=$installed_webkit_hook; repacking AppImage."local rebuilt="$workdir/$name"local appimage_archdiff --git a/scripts/release/test-strip-appimage-rpaths.sh b/scripts/release/test-strip-appimage-rpaths.shindex a2a643b19f..c43dd7c248 100644--- a/scripts/release/test-strip-appimage-rpaths.sh+++ b/scripts/release/test-strip-appimage-rpaths.sh@@ -884,4 +884,102 @@ if ! ( validate_appimage_required_libs "$GUARD_DIR" ) 2>/dev/null; thenfiecho "[test-rpaths] ok: guard passes when libxdo.so.3 is satisfied from usr/lib"+# --- Case 3: linuxdeploy AppRun prefers the host WebKitGTK (#7652) ------------+# The AppRun below is linuxdeploy's generated wrapper, verbatim in shape.+WK="$WORK/system-webkit"+WK_APPDIR="$WK/appdir"+mkdir -p "$WK_APPDIR/apprun-hooks" "$WK_APPDIR/usr/bin" "$WK/runner" "$WK/stubs"+cat >"$WK_APPDIR/AppRun" <<'APPRUN'+#! /usr/bin/env bash++# autogenerated by linuxdeploy++# make sure errors in sourced scripts will cause this script to stop+set -e++this_dir="$(readlink -f "$(dirname "$0")")"++source "$this_dir"/apprun-hooks/"linuxdeploy-plugin-gtk.sh"++exec "$this_dir"/AppRun.wrapped "$@"+APPRUN+printf 'export GTK_HOOK_RAN=1\n' >"$WK_APPDIR/apprun-hooks/linuxdeploy-plugin-gtk.sh"+printf '#!/bin/sh\necho "bundled gtk=$GTK_HOOK_RAN args=$*"\n' >"$WK_APPDIR/AppRun.wrapped"+printf '#!/bin/sh\necho "system gtk=${GTK_HOOK_RAN:-} ld=$LD_LIBRARY_PATH gdk=$GDK_BACKEND args=$*"\n' \+ >"$WK_APPDIR/usr/bin/OpenHuman"+chmod +x "$WK_APPDIR/AppRun" "$WK_APPDIR/AppRun.wrapped" "$WK_APPDIR/usr/bin/OpenHuman"++: >"$WK/runner/libwebkit2gtk-4.1.so.0.13.7"+ln -s libwebkit2gtk-4.1.so.0.13.7 "$WK/runner/libwebkit2gtk-4.1.so.0"+SAVED_SYSTEM_LOOKUP="$(declare -f system_module_runtime_library || true)"+system_module_runtime_library() { printf '%s/%s\n' "$WK/runner" "$1"; }+install_system_webkit_hook "$WK_APPDIR" >/dev/null \+ || fail "system WebKit hook was not installed into a linuxdeploy AppRun"+if install_system_webkit_hook "$WK_APPDIR" >/dev/null; then+ fail "system WebKit hook was installed twice"+fi+[ -z "$SAVED_SYSTEM_LOOKUP" ] || eval "$SAVED_SYSTEM_LOOKUP"+[ "$(grep -c "$SYSTEM_WEBKIT_HOOK" "$WK_APPDIR/AppRun")" = "1" ] \+ || fail "system WebKit hook is not sourced exactly once"+[ "$(grep -m 1 '^source ' "$WK_APPDIR/AppRun")" = "source \"\$this_dir\"/apprun-hooks/\"$SYSTEM_WEBKIT_HOOK\"" ] \+ || fail "system WebKit hook is not sourced before the GTK hook"+grep -q "^OPENHUMAN_BUNDLED_WEBKIT='libwebkit2gtk-4.1.so.0.13.7'$" "$WK_APPDIR/apprun-hooks/$SYSTEM_WEBKIT_HOOK" \+ || fail "system WebKit hook does not carry the runner's WebKit version"++# A sharun ELF AppRun is not a linuxdeploy wrapper and must be left alone.+if install_system_webkit_hook "$RELEASED_LAYOUT" >/dev/null 2>&1; then+ fail "system WebKit hook was installed into a sharun AppDir"+fi++# Host stubs: a loader cache listing the host WebKit, for this architecture.+HOST_LIBS="$WK/host-lib"+mkdir -p "$HOST_LIBS"+WK_MACHINE="$(uname -m | sed 's/^arm64$/aarch64/')"+case "$WK_MACHINE" in+ aarch64) WK_ARCH='AArch64' ;;+ *) WK_MACHINE='x86_64' WK_ARCH='x86-64' ;;+esac+cat >"$WK/stubs/ldconfig" <<LDCONFIG+#!/bin/sh+[ "\$1" = "-p" ] || exit 1+[ -e "$HOST_LIBS/libwebkit2gtk-4.1.so.0" ] || exit 0+printf '\tlibwebkit2gtk-4.1.so.0 (libc6,$WK_ARCH) => %s\n' "$HOST_LIBS/libwebkit2gtk-4.1.so.0"+LDCONFIG+printf '#!/bin/sh\necho %s\n' "$WK_MACHINE" >"$WK/stubs/uname"+chmod +x "$WK/stubs/ldconfig" "$WK/stubs/uname"++set_host_webkit() {+ rm -f "$HOST_LIBS"/*+ [ -n "$1" ] || return 0+ : >"$HOST_LIBS/$1"+ ln -s "$1" "$HOST_LIBS/libwebkit2gtk-4.1.so.0"+ : >"$HOST_LIBS/libjavascriptcoregtk-4.1.so.0"+}+run_wk_apprun() {+ env -u GDK_BACKEND -u LD_LIBRARY_PATH -u GTK_HOOK_RAN PATH="$WK/stubs:$PATH" "$@" \+ "$WK_APPDIR/AppRun" --flag 2>/dev/null+}++set_host_webkit libwebkit2gtk-4.1.so.0.19.2+out="$(run_wk_apprun)"+[ "$out" = "system gtk= ld=$HOST_LIBS gdk=x11 args=--flag" ] \+ || fail "newer host WebKit was not preferred: '$out'"+set_host_webkit libwebkit2gtk-4.1.so.0.13.7+out="$(run_wk_apprun)"+case "$out" in system*) ;; *) fail "equal host WebKit was not preferred: '$out'" ;; esac+out="$(run_wk_apprun OPENHUMAN_APPIMAGE_WEBKIT=bundled)"+[ "$out" = "bundled gtk=1 args=--flag" ] \+ || fail "OPENHUMAN_APPIMAGE_WEBKIT=bundled did not keep the bundled WebKit: '$out'"+set_host_webkit libwebkit2gtk-4.1.so.0.11.9+out="$(run_wk_apprun)"+[ "$out" = "bundled gtk=1 args=--flag" ] || fail "older host WebKit was preferred: '$out'"+set_host_webkit libwebkit2gtk-4.1.so.0.19.2+rm "$HOST_LIBS/libjavascriptcoregtk-4.1.so.0"+out="$(run_wk_apprun)"+[ "$out" = "bundled gtk=1 args=--flag" ] || fail "host WebKit without JavaScriptCore was preferred: '$out'"+set_host_webkit ""+out="$(run_wk_apprun)"+[ "$out" = "bundled gtk=1 args=--flag" ] || fail "missing host WebKit did not fall back: '$out'"+echo "[test-rpaths] ok: linuxdeploy AppRun prefers a host WebKitGTK at least as new as the bundle"+echo "[test-rpaths] PASS"diff --git a/scripts/release/validate-appimage-runtime.sh b/scripts/release/validate-appimage-runtime.shindex 562243b23d..83828d7202 100755--- a/scripts/release/validate-appimage-runtime.sh+++ b/scripts/release/validate-appimage-runtime.sh@@ -137,6 +137,16 @@ validate_linuxdeploy_appdir() {done < <(find "$appdir/apprun-hooks" -maxdepth 1 -type f -print0)fi+ # The system-WebKit hook (#7652) must be installed with its version stamped,+ # and sourced before every other hook so the bundled GTK hook cannot run first.+ local webkit_hook="$appdir/apprun-hooks/$SYSTEM_WEBKIT_HOOK"+ [ -f "$webkit_hook" ] \+ || { runtime_validation_error "apprun-hooks/$SYSTEM_WEBKIT_HOOK is missing"; return 1; }+ grep -q "^OPENHUMAN_BUNDLED_WEBKIT='libwebkit2gtk-4.1.so.0\." "$webkit_hook" \+ || { runtime_validation_error "apprun-hooks/$SYSTEM_WEBKIT_HOOK has no bundled WebKit version stamped"; return 1; }+ [ "$(grep -m 1 '^source .*apprun-hooks/' "$apprun")" = "source \"\$this_dir\"/apprun-hooks/\"$SYSTEM_WEBKIT_HOOK\"" ] \+ || { runtime_validation_error "AppRun does not source $SYSTEM_WEBKIT_HOOK before the other hooks"; return 1; }+local desktop_countdesktop_count="$(find "$appdir/usr/share/applications" -maxdepth 1 -name '*.desktop' 2>/dev/null | wc -l | tr -d ' ')"[ "$desktop_count" = "1" ] \@@ -483,7 +493,7 @@ smoke_extracted_apprun() {return 1fi- grep -Ei 'loader|loading|cef|startup|started|ready' "$log_file" \+ grep -Ei 'loader|loading|webkit|startup|started|ready' "$log_file" \| sed 's/^/[appimage-runtime] /' \|| trueecho "[appimage-runtime] Application remained alive for the 15-second startup window"@@ -527,7 +537,13 @@ validate_final_appimage() (validate_extracted_appdir "$appdir" || return 1if [ "${APPIMAGE_RUNTIME_SMOKE:-0}" = "1" ]; then+ # On the runner the host WebKit matches the bundled one, so the default run+ # takes the system-WebKit hook path (#7652). Smoke the bundled path as well,+ # because hosts without webkit2gtk-4.1 still take it.smoke_extracted_apprun "$appdir" "$foreign_cwd" "$smoke_log" || return 1+ echo "[appimage-runtime] Smoking again with OPENHUMAN_APPIMAGE_WEBKIT=bundled"+ OPENHUMAN_APPIMAGE_WEBKIT=bundled \+ smoke_extracted_apprun "$appdir" "$foreign_cwd" "$smoke_log" || return 1elseecho "[appimage-runtime] Static validation complete; executable smoke disabled for this architecture"fi