Skip to content

fix(desktop): stop bundling glib in the Linux libmpv slice - #2359

Open
chrisdebian wants to merge 1 commit into
maxrave-dev:devfrom
chrisdebian:fix/linux-desktop-bundled-glib
Open

fix(desktop): stop bundling glib in the Linux libmpv slice#2359
chrisdebian wants to merge 1 commit into
maxrave-dev:devfrom
chrisdebian:fix/linux-desktop-bundled-glib

Conversation

@chrisdebian

Copy link
Copy Markdown

What

scripts/mpv-linux/stage.sh bundles libglib-2.0.so.0 (2.72, from the Ubuntu 22.04 stage container) into the Linux libmpv slice because it wasn't in SYSTEM_LIBS. On a newer glib host (e.g. Ubuntu 24.04, glib 2.80), the bundled glib claims the soname before AWT's XDesktopPeer.init() can dlopen the system libgio-2.0.so.0, which then fails with an undefined symbol and disables java.awt.Desktop for the rest of the process — breaking all 23 external-link call sites via LocalUriHandler.

This is the root cause already documented in CLAUDE.md's 2026-07-31 entry ("Bundled glib disabled java.awt.Desktop on Linux"), which also names the cure directly: "The actual cure is to stop bundling glib — add it to SYSTEM_LIBS, which needs the Linux tarball rebuilt, republished and re-pinned in mpvNativesChecksums." This PR is that first half.

Adding libglib-2.0.so.0 to SYSTEM_LIBS excludes it from the bundle, so the loader falls through to the host's own glib — same mechanism as every other libc-family exclusion already in that list.

What this does NOT do

  • Doesn't touch the Desktop.isDesktopSupported() workaround in DesktopApp.kt — still needed for anyone on the currently-published tarball, and removing it here would break them.
  • Doesn't rebuild/republish the actual tarball or re-pin mpvNativesChecksums — per CLAUDE.md, that only happens through mpvBundleAll, which I don't have access to.

Verification

I don't have the mpvBundleAll pipeline available, so this hasn't been tested against a real staged build. bash -n and shellcheck both clean on the modified script — no new warnings introduced. Happy to help however's useful once it's staged on your end (e.g. confirming the fix against a built artifact, if you can share one).

AI disclosure

This PR was drafted with Claude Code's help — it traced the fix against your own CLAUDE.md root-cause entry, and I reviewed and confirmed the change before opening this.

libglib-2.0.so.0 (2.72, built on the Ubuntu 22.04 stage container) was
missing from SYSTEM_LIBS, so it shipped in the bundle and claimed the
glib soname the moment JNA loaded libmpv. On a newer glib host (e.g.
Ubuntu 24.04, glib 2.80) AWT's XDesktopPeer.init() could then no
longer dlopen the system libgio-2.0.so.0, dying with an undefined
symbol and disabling java.awt.Desktop for the rest of the process --
the root cause already documented in CLAUDE.md's 2026-07-31 entry.

Adding it to SYSTEM_LIBS excludes it from the bundle so the loader
falls through to the host's own glib, matching every other libc-family
exclusion already in this list.

Does not touch the DesktopApp.kt isDesktopSupported() workaround --
still needed for anyone on the currently-published tarball.

Note: this only changes the staging script. Taking effect requires
rebuilding the Linux tarball, republishing it to
maxrave-dev/simpmusic-files, and re-pinning mpvNativesChecksums --
steps only doable through the existing mpvBundleAll pipeline. I don't
have that pipeline available to verify end-to-end; this matches the
root cause and fix already documented in CLAUDE.md, but hasn't been
tested against a real staged build.

@maxrave-dev maxrave-dev left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks — this is exactly the cure already documented in CLAUDE.md's 2026-07-31 entry, and it checks out against the real staged bundle. Verified before approving:

  • Only libharfbuzz.so.0 links glib in the whole closure (pulled in via libass; Ubuntu's harfbuzz is built with glib support). No libgobject/libgio/libgmodule ever gets bundled, so excluding libglib-2.0.so.0 alone fully cuts the soname clash.
  • harfbuzz imports only 11 ancient glib symbols (g_bytes_* ≥ 2.32, g_unichar_* / g_unicode_script_* ≈ 2.30) — so resolving against the host's glib is safe in both directions: newer hosts (2.80) are a superset, and any distro glib since ~2012 satisfies it. No "fixed on 24.04, broken on older hosts" trade hiding here.
  • is_system() matches tokens exactly and ldd prints exactly libglib-2.0.so.0, so the one-token change is mechanically sound; the in-container resolution check and smoke test still pass, since the stage container has its own system glib.

Two notes for the record:

  1. libpcre.so.3 will remain in the bundle as a ~470 KB orphan — it only ever entered the closure as glib 2.72's own dependency (verified: nothing else NEEDs it), but collect() walks ldd's transitive output, so it still gets copied. Deliberately NOT asking for it in SYSTEM_LIBS: pcre1 no longer exists on modern hosts (Ubuntu 24.04 ships only pcre2), so excluding it would hide a genuinely missing dependency in-container and detonate on users — the exact trap this PR escapes. Dead weight is the safer failure mode.
  2. As you noted, this only takes effect at the next tarball rebuild (rebuild → republish to simpmusic-files → re-pin mpvNativesChecksums). We'll fold that into the next mpv bump rather than doing a dedicated rebuild, since the isDesktopSupported() probe plus the xdg-open fallback already mask the symptom for current users. Correct call leaving that workaround untouched.

Appreciate the honest scoping and the AI disclosure — this is precisely the kind of AI-assisted-but-human-reviewed contribution CONTRIBUTING.md welcomes.

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.

2 participants