Repository navigation
linux-pipewire: Draw each screen capture frame on its own video tick - #612
Merged
Merged
Conversation
test_pipewire_frame_pacing replays a compositor sending frames at a fixed rate with +-2 ms of delivery jitter against OBS's 60 fps video ticks, and counts which frames each tick draws. The decision is kept in a small obs_pw_frame_pacer (frame-pacing.c) that for now does what pipewire.c does today: every frame replaces the previous one at once and a tick draws the newest. Fails today: a 60 Hz source over 34 phases has 8 bad phases, 901 duplicated and 905 skipped frames in 10 s each; a source 1% faster than OBS (drifting clocks) has up to 27 duplicated and 33 skipped frames where only its 6 surplus frames need to go. Guards that pass: nothing is drawn before the first frame, steady frames between ticks are each drawn once, a 120 Hz source keeps a bounded latency, a 30 Hz source is repeated and never reordered, and every frame is released exactly once. Refs obs-rust#191. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A screen capture replaced its texture as soon as a frame arrived and each video tick drew the newest one. The compositor's frames and OBS's ticks run on separate clocks, so whenever frames land close to a tick, a little delivery jitter makes one tick see two new frames (the first is never drawn) and the next none (the previous one is drawn again): the recording repeats a frame, then skips one. Frames now wait in arrival order in obs_pw_frame_pacer, which moves on by at most one frame per video tick (in video_render, once per tick however often the source is drawn) and holds at most three frames, dropping the oldest waiting one when a source runs faster than the output. A frame that lands just after a tick is drawn one tick later instead of being lost, so the capture may run up to one frame behind; a steady source between ticks is drawn as before. Waiting frames need textures of their own. Frames in memory were already uploaded into a new texture; DMA-BUF frames are now drawn into a texture of ours as they arrive (after waiting for the explicit sync acquire point and exporting the release point after the copy), so their buffers still go back to the compositor at once. Crop and transform travel with each frame; the cursor still follows the newest metadata. Fixes obs-rust#191. Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=b9921fa7e202f1eb3af0959c477f5a2e27c6dd8b secs=349 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run Ci-Attestation: {"at":1791919376,"gate":"rust/all/fmt","host":"linux-x86_64","key":"0908a3cc7b905eec94aa94ddd1f403085ebf6154540e54c8223141b8d074a399","lane":"lint","parents":["1107015475c00a6ad1b45b73d5ab83f0deb4f18f"],"secs":25,"stamp":"0356762f6b925f2bca6614c854987cd4","tree":"b9921fa7e202f1eb3af0959c477f5a2e27c6dd8b","v":1,"via":"run"} Ci-Attestation: {"at":1791919376,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"0908a3cc7b905eec94aa94ddd1f403085ebf6154540e54c8223141b8d074a399","lane":"lint","parents":["1107015475c00a6ad1b45b73d5ab83f0deb4f18f"],"secs":25,"stamp":"49db61750d9dad98ab9250075cca9092","tree":"b9921fa7e202f1eb3af0959c477f5a2e27c6dd8b","v":1,"via":"run"} Ci-Attestation: {"at":1791919376,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"6a01d683a39a8095ec2f4b36606325cfec51c2fd03cac20b14c1721af7748ba4","lane":"rust-test","parents":["1107015475c00a6ad1b45b73d5ab83f0deb4f18f"],"secs":115,"stamp":"1610461617fde06538a8fbd7687b20fc","tree":"b9921fa7e202f1eb3af0959c477f5a2e27c6dd8b","v":1,"via":"run"} Ci-Attestation: {"at":1791919376,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"469bb1beec08d0c3b561b8940158c81d5a28cc705405c92e958c27d15e1095d9","lane":"cross","parents":["1107015475c00a6ad1b45b73d5ab83f0deb4f18f"],"secs":89,"stamp":"65b4b4a933109b853048e5f39246fe2a","tree":"b9921fa7e202f1eb3af0959c477f5a2e27c6dd8b","v":1,"via":"run"} Ci-Attestation: {"at":1791919376,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"469bb1beec08d0c3b561b8940158c81d5a28cc705405c92e958c27d15e1095d9","lane":"cross","parents":["1107015475c00a6ad1b45b73d5ab83f0deb4f18f"],"secs":89,"stamp":"54a75d2b98beb23f1a87db861b1be4d7","tree":"b9921fa7e202f1eb3af0959c477f5a2e27c6dd8b","v":1,"via":"run"} Ci-Attestation: {"at":1791919376,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"469bb1beec08d0c3b561b8940158c81d5a28cc705405c92e958c27d15e1095d9","lane":"cross","parents":["1107015475c00a6ad1b45b73d5ab83f0deb4f18f"],"secs":89,"stamp":"aaae464b796f288e649e6d8c1dbf4145","tree":"b9921fa7e202f1eb3af0959c477f5a2e27c6dd8b","v":1,"via":"run"} Ci-Attestation: {"at":1791919376,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"469bb1beec08d0c3b561b8940158c81d5a28cc705405c92e958c27d15e1095d9","lane":"cross","parents":["1107015475c00a6ad1b45b73d5ab83f0deb4f18f"],"secs":89,"stamp":"5b09ec2d1a7bb89c475432f6e4f3a6fc","tree":"b9921fa7e202f1eb3af0959c477f5a2e27c6dd8b","v":1,"via":"run"} Ci-Attestation: {"at":1791919376,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"469bb1beec08d0c3b561b8940158c81d5a28cc705405c92e958c27d15e1095d9","lane":"cross","parents":["1107015475c00a6ad1b45b73d5ab83f0deb4f18f"],"secs":89,"stamp":"313921e27496837e92d3f75269da6afa","tree":"b9921fa7e202f1eb3af0959c477f5a2e27c6dd8b","v":1,"via":"run"} Ci-Attestation: {"at":1791919376,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"469bb1beec08d0c3b561b8940158c81d5a28cc705405c92e958c27d15e1095d9","lane":"cross","parents":["1107015475c00a6ad1b45b73d5ab83f0deb4f18f"],"secs":89,"stamp":"3342443b5ff61ca411149d7f6634bef0","tree":"b9921fa7e202f1eb3af0959c477f5a2e27c6dd8b","v":1,"via":"run"} Ci-Attestation: {"at":1791919376,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"62ca862125b6f6738ed188230e26cc06a99f3d0c0b97e94a614faa1c5a0e48ca","lane":"tier2-linux","parents":["1107015475c00a6ad1b45b73d5ab83f0deb4f18f"],"secs":121,"stamp":"0d2316bc5e62bef6c485562d5922fc8f","tree":"b9921fa7e202f1eb3af0959c477f5a2e27c6dd8b","v":1,"via":"run"}
zackees
force-pushed
the
fix/pipewire-dup-skip
branch
from
October 13, 2026 19:22
43f088e to
efb69d8
Compare
Member
|
Verified locally (Tier 2 OFF and ON):
|
Member
|
Follow-up: since the pipewire.c rework isn't covered by plain CI, I also ran every PipeWire test against efb69d8 with a private PipeWire daemon, WirePlumber and D-Bus under xvfb-run. 11/11 pass: screencast_resume, screencast_shm, camera_nv12, camera_unplug, camera_unload, cursor_hdr, context_fail, frame_layout, frame_pacing, reconnect, wrapper. |
This was referenced Oct 13, 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.
Description
PipeWire screen capture now draws every frame it receives on its own video tick. Before, a recording of a 60 Hz screen at 60 fps repeated some frames and then skipped one, again and again.
process_video_sync()inplugins/linux-pipewire/pipewire.creplaced the capture's texture as soon as a frame arrived, and each video tick drew whatever arrived last. The compositor's frames (the display's vblank) and OBS's ticks run on separate clocks. Whenever the frames land close to a tick, a little delivery jitter makes one tick see two new frames (the first is never drawn) and the next tick none (the previous frame is drawn again).obs_pw_frame_pacer(frame-pacing.c, no PipeWire or graphics calls, so it is tested on its own).video_rendermoves on by at most one frame per video tick, once per tick however often the source is drawn (preview, projectors). At most three frames are held; when a source runs faster than the output, the oldest waiting frame is dropped.test/cmocka: Screen capture draws some frames twice and skips others:test_pipewire_frame_pacingreplays a compositor at a fixed rate with deterministic +-2 ms jitter against OBS's 60 fps ticks and counts what each tick draws. The pacer at this commit does whatpipewire.cdoes today. 7 cases:2 of 7 fail today: 8 bad phases with 901 duplicated and 905 skipped frames, and up to 27 duplicated and 33 skipped frames for the drifting source, where only 6 should go.
linux-pipewire: Draw each screen capture frame on its own video tick: the fix. 7 of 7 pass: 1 duplicated and 0 skipped frames over all 34 phases, and 0 duplicated and 6 skipped for the drifting source.Motivation and Context
Fixes #191 (upstream obsproject/obs-studio#13292, reported by debug686: recording a 60 Hz screen at 60 fps, on GNOME/Wayland with the Flatpak, shows some frames twice and then skips one). eclipise confirmed it on Fedora 44 with GNOME 50.1 and an NVIDIA card. They saw the same in GPU Screen Recorder, and OBS 32.0.4 shows it too once the newer GNOME is installed, which points to the compositor's delivery timing changing. Any capture that draws only the newest frame on its own clock turns that jitter into repeated and lost frames; OBS can absorb it.
Why this one: a recording that repeats and drops frames in the main Linux capture source, confirmed by a second user, open upstream with no fix.
How Has This Been Tested?
Reproduced in the current release AppImage (OBS 33.0.0-beta6-799-gd711a972c, Rust libobs), headless: a private Xvfb, a private D-Bus session with a fake ScreenCast portal, and a private PipeWire daemon. A producer sent 640x360 frames in memory, each showing its frame number as 16 black/white bars, on a fixed schedule. OBS recorded at 60 fps; the bars were decoded from every recorded frame (the first second left out), 3540 frames per 60 s run:
A 60.05 Hz source has 3 more frames than OBS has ticks in 60 s, so 0 duplicated and 3 skipped is the best possible. The producer sends every frame once and in order; the repeats and gaps come from which frame each tick picks.
The same AppImage with
linux-pipewire.sobuilt from master, then from this branch (same harness):DMA-BUF, with a master build: a headless libobs on Wayland (a headless sway on the GPU's render node) running the real screen capture through the fake portal. The producer sent linear XRGB8888 GBM buffers with the same counters; the capture imported them (no fallback to memory). Each output frame was decoded through a raw video callback, 60 s per run:
A real compositor: nested Hyprland 0.56.2 with xdg-desktop-portal-hyprland, capturing an mpv window that plays a 60 fps counter video on a 60 Hz output, 60 s: master 33 duplicated and 32 skipped, this branch 6 and 6 (mpv's own presentation is not perfectly regular either). The portal's DMA-BUF buffers could not be imported in this nested setup, so this ran on frames in memory.
Automated, in both libobs lanes (
ENABLE_RUST_LIBOBSOFF and ON), on current master:test_pipewire_frame_pacing: 2 of 7 cases fail at the RED commit and 7 of 7 pass at GREEN. It needs no display, daemon or GPU, so it runs in CI.test_pipewire_screencast_shm,test_pipewire_cursor_hdr,test_pipewire_screencast_resume, the camera tests) pass under a private Xvfb with every case run.open_crashes_without_obs_core.Not tested:
SPA_META_SyncTimeline): the test producer does not send sync objects. That path waits on the acquire point and exports the release point, as before, but around the copy instead of the draw.Types of changes
Checklist:
🤖 Generated with Claude Code