Skip to content

linux-pipewire: Do not renegotiate a camera stream for the format it has - #820

Merged
zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/pw-camera-reneg
Oct 15, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/pw-camera-reneg

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Fixes #819

What and why

Opening or reloading the Properties window of a "Video Capture Device (PipeWire)" source no longer renegotiates its running stream when nothing about the format changes. Cameras behind libcamera cannot be reconfigured while they stream, so on them each needless renegotiation broke the stream: shetozz's freeze in obsproject/obs-studio#10399 (stephematician added the libcamera log, Camera in Running state trying configure()), and the drops, stutter and freeze a Surface Pro 5 user (Intel IPU3, libcamera 0.2.0) reported on #390 after testing #391.

  • obs_source_properties() applies the settings, which runs every modified callback: format_selected() and framerate_selected() in plugins/linux-pipewire/camera-portal.c push the selected size and framerate into the running stream each time. While the window is open, the camera portal reloads it for every PipeWire node that comes or goes (obs_source_update_properties() in its registry callbacks).
  • obs_pipewire_stream_set_framerate() and _set_resolution() (pipewire.c) renegotiated whenever the value differed from the one the stream was started with, even when the stream had already negotiated that exact value. They now keep the value and skip the renegotiation when the stream already runs with it. A real change renegotiates as before.
  • framerate_selected() kept the picked framerate only on the current stream, and camera_source->framerate is read from the settings only in pipewire_camera_create(). A stream that stream_camera() starts later (the camera came back, the device or pixel format changed) started without it, negotiated the camera's default and was renegotiated on the next Properties pass. The callback now keeps it on the source too (and clears it when the format has no framerates).

Reproduced in release v0.1.0-beta.20261014 (AppImage, headless: private Xvfb, dbus-run-session, private HOME, --multi, private PipeWire 1.6.8 without a session manager, a fake camera portal, a GStreamer NV12 640x480 30 FPS camera node linked by hand). The source was saved with only its device and got its format and framerate through obs-websocket SetInputSettings; the stream negotiated NV12 640x480 30/1 and streamed:

Then Release Release + this branch's linux-pipewire.so (Rust libobs lane)
Open Properties (OpenInputPropertiesDialog), 3 other camera nodes come and go (about 175 property passes) 1 renegotiation, on opening: Renegotiating stream -> paused -> NV12 640x480 30/1 again -> streaming 0
GetInputPropertiesListPropertyItems 3 times 1 renegotiation 0
Control: format and framerate saved at startup, same two runs 0

The test camera renegotiates cleanly; on libcamera this renegotiation is where the stream breaks. libcamera itself was not available here, so the fix is not tested on a libcamera camera.

RED → GREEN

  • RED commit: 5d37faf test/cmocka: Add failing test for renegotiating a streaming PipeWire camera. test_pipewire_camera_renegotiate runs camera-portal.c against a fake camera portal on a private D-Bus bus (GTestDBus) and a driving camera node (YUY2 64x48, 30 FPS default or 15 FPS) on the private PipeWire daemon that test_pipewire_cursor_hdr.sh starts, and links it to the source's stream itself. 2 of 3 cases fail in both lanes: properties_keep_a_streaming_camera ("opening Properties renegotiated a streaming camera 1 time(s) for its own format") and replugged_camera_keeps_the_picked_framerate ("negotiated framerate 30/1, expected 15/1"); the guard camera_streams passes. Same result in 3 of 3 runs per lane.
  • GREEN: f0e6570. 3 of 3 with ENABLE_RUST_LIBOBS OFF and ON, 3 runs per lane; without a display the cases skip. Full ctest (private Xvfb, system libobs-opengl masked, TMPDIR unset): 241/241 in both lanes, every PipeWire/PulseAudio test ran; skipped only open_crashes_without_obs_core. clang-format and gersemi clean.

Checklist

  • Base is master
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): none
  • Intentional differences from C listed in the parity test header and rust/README.md (ports): not a port

AI note: Claude Code (Claude Opus 5.5) wrote the code, the test, the commit messages and this text under the submitter's direction, and ran the tests above on the submitter's machines.

🤖 Generated with Claude Code

@rdoupe
rdoupe requested a review from zackees as a code owner October 15, 2026 09:17
@zackees zackees added the ci-full Run every CI job on this PR, including the release-gating OBS app builds and Flatpak label Oct 15, 2026
rdoupe and others added 2 commits October 15, 2026 02:20
…camera

The Properties window runs the camera source's property callbacks every
time it opens or reloads, and it reloads whenever a PipeWire node comes
or goes. The framerate callback asks the running stream for the saved
framerate again, and pipewire.c renegotiates whenever the stream was
started without it, although the stream already runs at that framerate.
A stream restarted after its camera came back is also started without
the framerate the user picked. libcamera cannot reconfigure a running
camera, so there the stream breaks (upstream obsproject/obs-studio#10399,
reported by shetozz; seen on a Surface Pro with an IPU3 camera on
obs-rust#390).

test_pipewire_camera_renegotiate runs camera-portal.c against a fake
camera portal on a private D-Bus bus and a camera node on a private
PipeWire daemon. Two of three cases fail: opening Properties
renegotiates a stream for its own framerate, and a replugged camera's
new stream comes back at 30 FPS instead of the picked 15 FPS.

Refs obs-rust#819.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
obs_pipewire_stream_set_framerate() and _set_resolution() renegotiated
whenever the requested value differed from the one the stream was
started with, even when the stream had already negotiated exactly that
value. The camera portal asks again for the selected framerate and size
each time its properties are shown, so opening or reloading the
Properties window renegotiated a running camera for nothing, which
cameras behind libcamera do not survive (obsproject/obs-studio#10399).
Keep the requested value and skip the renegotiation when the stream
already runs with it.

framerate_selected() also kept the picked framerate only on the current
stream, so a stream that stream_camera() starts later (the camera came
back, or the device changed) started without it and was renegotiated to
it on the next Properties reload. Keep it on the source too.

Fixes obs-rust#819.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local-Gate: v1 tree=6db1956d49032546cb880857b625fa635eaee244 secs=1404 lanes=lint:run,rust-test:reused@241456d52183,cross:reused@b456eff62019,tier2-linux:run
Ci-Attestation: {"at":1792057447,"gate":"rust/all/fmt","host":"linux-x86_64","key":"3a9c5b072c866f58a71d2639e21f0893eaa6f13d3735ab9e722e2e6c6a2b6a00","lane":"lint","parents":["209f31edf7b01a16bde66c0b91155a9d61159720"],"secs":42,"stamp":"cd13d5838352ecb2e32b1b094cf0cf74","tree":"6db1956d49032546cb880857b625fa635eaee244","v":1,"via":"run"}
Ci-Attestation: {"at":1792057447,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"3a9c5b072c866f58a71d2639e21f0893eaa6f13d3735ab9e722e2e6c6a2b6a00","lane":"lint","parents":["209f31edf7b01a16bde66c0b91155a9d61159720"],"secs":42,"stamp":"beda2d941b9dd39e36e6f3ddf84d98a5","tree":"6db1956d49032546cb880857b625fa635eaee244","v":1,"via":"run"}
Ci-Attestation: {"at":1792052374,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"241456d52183502cf4b88cfa70413b65dfc08dc645f90e8d74ed72769dac7fe4","lane":"rust-test","parents":["209f31edf7b01a16bde66c0b91155a9d61159720"],"secs":null,"stamp":"ad4ae1b475a1c45f798965f1b1232c9f","tree":"6db1956d49032546cb880857b625fa635eaee244","v":1,"via":"reused"}
Ci-Attestation: {"at":1792052374,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"b456eff62019370969ffb6f2fc0c955838c3003441e52044ffee254e4fee916f","lane":"cross","parents":["209f31edf7b01a16bde66c0b91155a9d61159720"],"secs":null,"stamp":"99cc2cb58dfe686351ea2f3b22f39a0b","tree":"6db1956d49032546cb880857b625fa635eaee244","v":1,"via":"reused"}
Ci-Attestation: {"at":1792052374,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"b456eff62019370969ffb6f2fc0c955838c3003441e52044ffee254e4fee916f","lane":"cross","parents":["209f31edf7b01a16bde66c0b91155a9d61159720"],"secs":null,"stamp":"9c7d4ef257e909e4c5553a9d369a8c4e","tree":"6db1956d49032546cb880857b625fa635eaee244","v":1,"via":"reused"}
Ci-Attestation: {"at":1792052374,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"b456eff62019370969ffb6f2fc0c955838c3003441e52044ffee254e4fee916f","lane":"cross","parents":["209f31edf7b01a16bde66c0b91155a9d61159720"],"secs":null,"stamp":"289e0a0fbaba043d8007f5a6cdabb639","tree":"6db1956d49032546cb880857b625fa635eaee244","v":1,"via":"reused"}
Ci-Attestation: {"at":1792052374,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"b456eff62019370969ffb6f2fc0c955838c3003441e52044ffee254e4fee916f","lane":"cross","parents":["209f31edf7b01a16bde66c0b91155a9d61159720"],"secs":null,"stamp":"e912410f70916649597c02ec543576d9","tree":"6db1956d49032546cb880857b625fa635eaee244","v":1,"via":"reused"}
Ci-Attestation: {"at":1792052374,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"b456eff62019370969ffb6f2fc0c955838c3003441e52044ffee254e4fee916f","lane":"cross","parents":["209f31edf7b01a16bde66c0b91155a9d61159720"],"secs":null,"stamp":"b37a704e0bef379ffb0a151934079551","tree":"6db1956d49032546cb880857b625fa635eaee244","v":1,"via":"reused"}
Ci-Attestation: {"at":1792052374,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"b456eff62019370969ffb6f2fc0c955838c3003441e52044ffee254e4fee916f","lane":"cross","parents":["209f31edf7b01a16bde66c0b91155a9d61159720"],"secs":null,"stamp":"148797392a950989b5e5fe4ac0f4b969","tree":"6db1956d49032546cb880857b625fa635eaee244","v":1,"via":"reused"}
Ci-Attestation: {"at":1792057447,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"f5c54a507a512e0dbbe17971930e14ee324d8bb506c8400b784f9c7f7cca1512","lane":"tier2-linux","parents":["209f31edf7b01a16bde66c0b91155a9d61159720"],"secs":1362,"stamp":"0bd22865457a18458c5dc5b63bbe7985","tree":"6db1956d49032546cb880857b625fa635eaee244","v":1,"via":"run"}
@zackees

zackees commented Oct 15, 2026

Copy link
Copy Markdown
Member

Rebased onto master, set ci-full (plugin change), and ran the stamped local gate, whose Tier 2 now runs the PipeWire tests (#783). Your RED (5d37fafa1: 2 of 3 fail, both lanes) / GREEN evidence stands.

  • Rebased on master, local gate passed; pushed as f73398a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-full Run every CI job on this PR, including the release-gating OBS app builds and Flatpak

Projects

Status: Done

2 participants