Repository navigation
linux-pipewire: Do not renegotiate a camera stream for the format it has - #820
Merged
Merged
Conversation
…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"}
Member
zackees
force-pushed
the
fix/pw-camera-reneg
branch
from
October 15, 2026 09:44
f0e6570 to
f73398a
Compare
zackees
enabled auto-merge
October 15, 2026 09:44
This was referenced Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()andframerate_selected()inplugins/linux-pipewire/camera-portal.cpush 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, andcamera_source->framerateis read from the settings only inpipewire_camera_create(). A stream thatstream_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-websocketSetInputSettings; the stream negotiated NV12 640x480 30/1 and streamed:OpenInputPropertiesDialog), 3 other camera nodes come and go (about 175 property passes)Renegotiating stream->paused-> NV12 640x480 30/1 again ->streamingGetInputPropertiesListPropertyItems3 timesThe 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
test/cmocka: Add failing test for renegotiating a streaming PipeWire camera.test_pipewire_camera_renegotiaterunscamera-portal.cagainst 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 thattest_pipewire_cursor_hdr.shstarts, 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") andreplugged_camera_keeps_the_picked_framerate("negotiated framerate 30/1, expected 15/1"); the guardcamera_streamspasses. Same result in 3 of 3 runs per lane.ENABLE_RUST_LIBOBSOFF and ON, 3 runs per lane; without a display the cases skip. Full ctest (private Xvfb, systemlibobs-openglmasked, TMPDIR unset): 241/241 in both lanes, every PipeWire/PulseAudio test ran; skipped onlyopen_crashes_without_obs_core. clang-format and gersemi clean.Checklist
master-W..., ratchets): noneAI 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