Skip to content

appimage: load optional host libraries (libva) lazily, and fail clearly when a required one is missing #959

Closed

Description

@zackees

Problem

The AppImage takes the GPU driver stack from the host on purpose (#625, #722): libEGL, libGL/libOpenGL, libgbm, libdrm, libva*, libvulkan, libwayland-* and NVIDIA's libraries are excluded from the bundle (assemble-appdir.sh, EXCLUDE). But FFmpeg's libavutil and OBS's VA-API encoder link libva.so.2, libva-drm.so.2 and libva-x11.so.2 with DT_NEEDED. On a host without libva the loader fails before OBS's main() runs:

obs-studio-rust-gui: error while loading shared libraries: libva.so.2: cannot open shared object file: No such file or directory

Seen on NixOS 26.05 with a master AppImage (#722 onward) run through appimageTools.wrapType2: libva is not in the FHS env, in nix-ld's library directory, or in /run/opengl-driver/lib. The beta.20261014 AppImage bundled libva and started. Most users only see the dock icon doing nothing, because the message goes to a terminal they don't have open.

libva is optional: OBS works without VA-API (NVENC, x264 and the rest). A missing optional library must not stop OBS from starting. A missing required one must give a message the user can act on.

Proposal: a loader that knows required from optional

1. Optional host libraries are loaded lazily through shims (libva first)

  • Generate shims with Implib.so at build time from the real libraries on the build base (AlmaLinux 8's libva 2.13): libobs-va.so.2, libobs-va-drm.so.2, libobs-va-x11.so.2. Each exports every symbol of the original; the first call dlopens the host's library and fills the table.
  • assemble-appdir.sh runs patchelf --replace-needed libva.so.2 libobs-va.so.2 (and the same for -drm and -x11) on every bundled ELF file. The shims must not be called libva.so.2, because glibc matches loaded libraries by soname, so a shim with the real name would get itself back from dlopen.
  • The --dlopen-callback search runs in this order: $OBS_LIBVA_PATH, then /run/opengl-driver/lib (NixOS), /usr/lib/x86_64-linux-gnu, /usr/lib64, /usr/lib, then the ldconfig cache (the soname alone). The host's own libva is used, so it stays matched to the host's VA drivers (the reason appimage: use host VA drivers with audited FFmpeg compatibility and GPU checks #722 excluded it).
  • If no libva is found, every VA call returns VA_STATUS_ERROR_UNKNOWN. vaInitialize fails, VA-API encoders and decoders are unavailable, and OBS starts. It logs one line once: libva not found on this system (searched: ...); VA-API hardware encoding and decoding are disabled. The state is exposed for the frontend: GPU acceleration status light (green/yellow/red) in the status bar #846 status light.

2. Required host libraries are checked before OBS starts

AppRun (or a small preflight helper run with the AppImage's own environment) resolves the libraries OBS cannot run without: libEGL.so.1, libOpenGL.so.0 or libGL.so.1, libgbm.so.1, libdrm.so.2, and libwayland-client.so.0 (needed even on X11, because Qt and OBS link it). If any is missing, it exits with status 127 and a message like this:

OBS-Studio-Rust needs these libraries from your system, and they were not found:
  libEGL.so.1 (EGL, from your graphics driver)
Install them with your package manager (Debian/Ubuntu: libegl1; Fedora: libglvnd-egl; Arch: libglvnd).
On NixOS, enable hardware.graphics and run the AppImage through appimage-run or nix-ld.

The message goes to stderr, and to notify-send or zenity when one exists, so someone launching from a dock sees it too. The list of required versus optional libraries lives in one file that both the preflight and the test read.

Tests (packaging rule, #426)

test-appimage.sh gets these lanes, each running the AppImage the way a user does, with a saved profile:

  1. libva removed from the container. The AppImage starts, records with x264, and logs the libva line. RED today: the AppImage fails at load time with libva.so.2: cannot open shared object file.
  2. libva present. VA-API encoders are listed, and /proc/<pid>/maps shows the host's libva, not a bundled one.
  3. A required library removed (for example libEGL). The AppImage exits with status 127 and the message names it.
  4. NixOS-shaped: no libva in the standard dirs, but present in a fake /run/opengl-driver/lib. The shim finds it there.

Related

Activity

  1. added
    claimed
    on Oct 16, 2026
  2. self-assigned this
    on Oct 16, 2026
  3. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    Claiming: #959 (taking over the idle claim, with maintainer approval).

    1. PR 1: optional libva shims (Implib.so, libobs-va*.so.2, patchelf --replace-needed in assemble-appdir.sh) with the search order from the proposal and a single log line when libva is missing. Tests: test-appimage.sh lanes 1 (libva removed: starts and records), 2 (libva present: host libva mapped) and 4 (NixOS-shaped /run/opengl-driver/lib). RED is lane 1 against the current AppImage.
    2. PR 2: required-library preflight in AppRun (exit 127, a message naming the library and the package that provides it, notify-send/zenity), with one list file shared by preflight and test, plus lane 3.

    The first PR (RED) goes up as soon as the lane 1 test exists.

  4. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    Status: both parts of the proposal already shipped inside #927 (build-aux/appimage/hostlib/: the libva shims and the obs-hostlib-check preflight in AppRun). #1981 adds the packaged-AppImage lane 1 (no libva: OBS starts) to test-appimage.sh and CI. Lanes 2–4 remain; next I'm wiring hostlib/test-hostlib.sh or adding the matching scenarios.

  5. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    Done. The loader (libva shims and the obs-hostlib-check preflight, build-aux/appimage/hostlib/) shipped in #927. Test coverage, lane by lane:

    1. no libva, OBS starts: test-appimage.sh first-start-no-libva on AlmaLinux 8 and Ubuntu 22.04 (appimage: test that OBS starts on a host without libva (#959) #1981);
    2. host libva used and 3. a required library missing (exit 127, named): hostlib/test-hostlib.sh, now run in the AppImage build job (appimage: run the host-library loader test in CI (#959) #1982);
    3. NixOS layout: test-appimage-nixos.sh (existing).
      The AppImage jobs run on schedule, dispatch and releases, not on PRs, so the first CI run of 1 and 2 is the next nightly. Locally both pass on today's continuous AppImage and in the build image.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

claimed

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions