Repository navigation
linux-pipewire: Fail cleanly when the PipeWire client cannot start - #429
Conversation
|
Verified locally while it's a draft (Tier 2 image + pipewire, wireplumber, dbus):
Without PipeWire the test skips (exit 77), so plain CI doesn't exercise it. Once you mark it ready, I'll rebase, gate and merge. |
97e50b0 to
703712d
Compare
|
Thanks for verifying. The skip is fixed in the latest push:
Checked at both commits, with the daemon and with
Marking it ready; CI is still running. One request while the AppImage fix is still in review: could you add a warning to the top of the > [!WARNING]
> **The Linux AppImage crashes on launch if a scene has a Screen Capture (PipeWire) source** (the usual capture on Wayland). A fix is in progress: #426. Until then, use another build or remove the Screen Capture source before launching.
|
A PipeWire client without its configuration crashed OBS at launch: the obs-rust AppImage pointed PIPEWIRE_CONFIG_DIR at a directory that was not packaged, so pw_context_new() returned NULL and obs_pipewire_connect_fd() passed that on to pw_context_connect_fd(). Any scene with a PipeWire screen capture crashed while loading. Against a private PipeWire daemon, connecting with a missing configuration directory must return NULL, log why and close the fd it was given. missing_configuration_fails_cleanly segfaults here. Part of obs-rust#426 Co-Authored-By: Claude Opus 5.5 <[email protected]>
obs_pipewire_connect_fd() did not check pw_thread_loop_new() or pw_context_new(). When PipeWire cannot load its client configuration (client.conf), pw_context_new() returns NULL and pw_context_connect_fd() then dereferenced it, so a scene with a PipeWire screen capture crashed OBS while loading. The obs-rust AppImage hit this: it pointed PIPEWIRE_CONFIG_DIR at a directory that was not packaged. Check every step, log the cause, and on failure stop and free what was set up and close the portal's fd, which the callers do not close. The screencast source counts a failed connection as a failed reconnect attempt, and the camera portal no longer runs a roundtrip on NULL. Part of obs-rust#426 Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=62ed7f49bb37a9530761cdcbab1a76599b436da8 secs=151 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791860250,"gate":"rust/all/fmt","host":"linux-x86_64","key":"a3b91dc812031b9a85d60ac666b5931775fd2f24ac926f40cbd676812975ff73","lane":"lint","parents":["de5bedf065eb11cabd706f5fcb8dc69b27531e98"],"secs":27,"stamp":"1f9ed8a33f594ed4cc0096267d35a065","tree":"62ed7f49bb37a9530761cdcbab1a76599b436da8","v":1,"via":"run"} Ci-Attestation: {"at":1791860250,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"a3b91dc812031b9a85d60ac666b5931775fd2f24ac926f40cbd676812975ff73","lane":"lint","parents":["de5bedf065eb11cabd706f5fcb8dc69b27531e98"],"secs":27,"stamp":"d37e08b4902f8b62cb8ecdf4aafc44b0","tree":"62ed7f49bb37a9530761cdcbab1a76599b436da8","v":1,"via":"run"} Ci-Attestation: {"at":1791860250,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"c773801b99a98194eb42360c4158f9a07be0f92ad5e3430ec8a8709431d3cd7c","lane":"rust-test","parents":["de5bedf065eb11cabd706f5fcb8dc69b27531e98"],"secs":53,"stamp":"bd53e1fd5a4e4c54be179349dc69b0f2","tree":"62ed7f49bb37a9530761cdcbab1a76599b436da8","v":1,"via":"run"} Ci-Attestation: {"at":1791860250,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"a5006369b8ff6fcb2cdcdc96f0bbe37cf2b125f0e8d15fe7d00effd83419b7f8","lane":"tier2-linux","parents":["de5bedf065eb11cabd706f5fcb8dc69b27531e98"],"secs":71,"stamp":"0bf8b85b73e747b661b7683b7675033d","tree":"62ed7f49bb37a9530761cdcbab1a76599b436da8","v":1,"via":"run"}
703712d to
d51aa53
Compare
Every published AppImage crashed on start for anyone whose scene holds a PipeWire screen capture: the bundled libpipewire was pointed at module and config directories that were never bundled, pw_context_new() returned NULL and the next PipeWire call segfaulted (obs-rust#429 now turns that into a dead source). The AppImage test passed anyway: it only started OBS once with an empty profile, where nothing touches PipeWire, so the broken build was published. test-appimage.sh now takes one scenario, and CI runs each in its own fresh stock container, so nothing one scenario starts or leaves behind can affect another: 1. bundle: check-appdir.sh requires every path AppRun exports into the AppDir to exist, PipeWire's client.conf with the modules and SPA plugins it loads, gconv and Qt's X11 and Wayland plugins; every bundled ELF file must resolve its libraries and symbols from the bundle with the bundled loader, and every module the build installed must be there. No desktop-session package is installed in this scenario. 2. first-start: a new profile opens a window that renders, then OBS must quit on SIGINT, by itself, with status 0. 3. probes: a test helper (testkit.c, built next to the AppImage and run next to obs with the same RPATH and AppRun's environment) connects to PipeWire and PulseAudio, converts text through gconv and uses the session bus. 4. saved-profile: OBS starts with a returning user's scene (PipeWire screen capture, PipeWire camera, PulseAudio microphone) and --startrecording, against a private D-Bus, PipeWire, WirePlumber and pipewire-pulse, a fake ScreenCast/Camera portal served by the helper, and test producers (colour bars, a bouncing ball, a 440 Hz tone). OBS must get its PipeWire connection from the portal, stay up, map PipeWire, PulseAudio and GLib from the AppImage, load every module the build installed, start every source and quit cleanly. verify-recording.sh then checks, outside the container, that the recording decodes at 320x240 with enough frames, both pictures keep moving and the tone is there throughout; its --self-test proves it fails on a frozen picture, a silent microphone and a broken file. Only Ubuntu 22.04, whose PipeWire 0.3.x cannot run the producers, runs it without them; an unreadable or old PipeWire anywhere else fails. Every scenario ends by stopping what it started and fails if any of it, or any OBS, is still running 10 s later or an OBS instance socket is still open. AppRun hides a crash from its caller (it saves a report and starts OBS again under gdb), so any AppRun crash report fails the scenario too. The test only signals processes it started, picks a free X display and clears the caller's session variables first. The daily beta (release-rust.yaml) took the AppImage artifact even when its tests had failed; it now takes it only when the appimage workflow passed. The continuous release already waits for every test job. Refs obs-rust#426 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Description
A scene with a PipeWire screen capture crashed OBS while it loaded whenever the PipeWire client couldn't start. The
continuousAppImage hit this on every launch: it pointsPIPEWIRE_CONFIG_DIRat a directory it doesn't package. With this, the capture stays empty and the log says why. OBS keeps running.test: Crash when PipeWire has no client configuration (RED)addstest_pipewire_context_fail. The failure cases need no PipeWire daemon (the configuration is read before connecting, and a socketpair stands in for the portal's fd), so they also run in CI images without PipeWire installed. Only the control case needs a daemon:test_pipewire_context_fail.shstarts a private one whenpipewireis installed, with its own runtime dir and a minimal configuration (native protocol and access control only: no D-Bus, no realtime or X11 modules, no session manager, no devices), and that case skips otherwise.missing_configuration_fails_cleanlysegfaults on this commit.linux-pipewire: Fail cleanly when the PipeWire client cannot start:obs_pipewire_connect_fd()now checkspw_thread_loop_new()andpw_context_new(). Before, it passed a NULL context topw_context_connect_fd(), which dereferenced it.[pipewire] Error creating PipeWire context: <errno> (is the PipeWire client configuration missing?).pw_context_connect_fd()can still leak if PipeWire fails before taking it over; that predates this change and is left for a follow-up.obs_pipewire_roundtrip()on NULL. As with its other setup errors, a failed camera connection is not retried until OBS restarts; that predates this change and is left for a follow-up.Motivation and Context
Part of #426
Upstream has the same unchecked
pw_context_new(). Normal installs never reach it because the system always hasclient.conf, but any broken or partial PipeWire install (a missing config package, a badPIPEWIRE_CONFIG_DIR, an out-of-memory error) crashes OBS instead of disabling one source.How Has This Been Tested?
Automated (
test_pipewire_context_fail, no display needed). Each cell was run at both commits, with the private daemon and withpipewireabsent fromPATH(as in the Tier 2 image):connects_with_its_configurationmissing_configuration_fails_cleanlyPIPEWIRE_CONFIG_DIR→ missing dir: returns NULL, closes the fd, logs "Error creating PipeWire context"unusable_fd_fails_cleanlyENABLE_RUST_LIBOBSOFF) passes headless;test_screencast_portal_teardownskips without a display as before.ci/test_registration.pyis clean.Not run: the Docker Tier 2 lane (
./unittest; no Docker access on the test machines; the regression no longer depends on the image having a PipeWire daemon) and the Rust lint lanes (soldrnot installed; no Rust changes). clang-format 22.1.3, gersemi 0.25.0 and the CI self-tests pass throughci/local_gate.py --lane lint.Types of changes
Checklist:
🤖 Generated with Claude Code