Repository navigation
media-playback: Publish cached seek frame only while paused - #731
Merged
zackees merged 6 commits intoOct 15, 2026
Merged
Conversation
Member
|
Two failures here, both from the new test 1. Format (gersemi), also shows up as "Rust Tests" -> Fix: 2. Tier 2 Linux, ENABLE_RUST_LIBOBS=OFF build: link error The test (or something it pulls in) uses a libm symbol but the target does not link libm. Likely fix in |
zackees
marked this pull request as ready for review
October 14, 2026 23:11
The Linux link failed with "libm.so.6: error adding symbols: DSO missing
from command line".
Local-Gate: v1 tree=92cc4db5b93bcd8b5bff168d91dbb66c2fd7e748 secs=478 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run
Ci-Attestation: {"at":1792021892,"gate":"rust/all/fmt","host":"linux-x86_64","key":"cd3c55520ec6991ec9389948b400db7eb48d025282c5c412e084ed7b0b5ecb10","lane":"lint","parents":["a49c7eee0f50a50d7f43a2cb2058e6fccc5863bb"],"secs":43,"stamp":"c86703f38ee31b13bdc62d22a7d8a85f","tree":"92cc4db5b93bcd8b5bff168d91dbb66c2fd7e748","v":1,"via":"run"}
Ci-Attestation: {"at":1792021892,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"cd3c55520ec6991ec9389948b400db7eb48d025282c5c412e084ed7b0b5ecb10","lane":"lint","parents":["a49c7eee0f50a50d7f43a2cb2058e6fccc5863bb"],"secs":43,"stamp":"06db2ec64bd6e09a78a22405b343ea9a","tree":"92cc4db5b93bcd8b5bff168d91dbb66c2fd7e748","v":1,"via":"run"}
Ci-Attestation: {"at":1792021892,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"09d590e78c5a7e6d22109c47c83e7ac723db7a11f9215b6e51f0dc69b692cf3f","lane":"rust-test","parents":["a49c7eee0f50a50d7f43a2cb2058e6fccc5863bb"],"secs":104,"stamp":"38ed4960f4b3dd624121dc2d9ef328c5","tree":"92cc4db5b93bcd8b5bff168d91dbb66c2fd7e748","v":1,"via":"run"}
Ci-Attestation: {"at":1792021892,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"fecac0f20b5c6e163e995fb8c9bc8fec34bf8c8adc82b5b0fd1b9e8665b58301","lane":"cross","parents":["a49c7eee0f50a50d7f43a2cb2058e6fccc5863bb"],"secs":74,"stamp":"4cb56a65a43a8ecf72b1a617bacebb4c","tree":"92cc4db5b93bcd8b5bff168d91dbb66c2fd7e748","v":1,"via":"run"}
Ci-Attestation: {"at":1792021892,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"fecac0f20b5c6e163e995fb8c9bc8fec34bf8c8adc82b5b0fd1b9e8665b58301","lane":"cross","parents":["a49c7eee0f50a50d7f43a2cb2058e6fccc5863bb"],"secs":74,"stamp":"98c47671124c52ab0f6a60d61c74171a","tree":"92cc4db5b93bcd8b5bff168d91dbb66c2fd7e748","v":1,"via":"run"}
Ci-Attestation: {"at":1792021892,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"fecac0f20b5c6e163e995fb8c9bc8fec34bf8c8adc82b5b0fd1b9e8665b58301","lane":"cross","parents":["a49c7eee0f50a50d7f43a2cb2058e6fccc5863bb"],"secs":74,"stamp":"2d165065232b373806a0d1d9f5b3a7c2","tree":"92cc4db5b93bcd8b5bff168d91dbb66c2fd7e748","v":1,"via":"run"}
Ci-Attestation: {"at":1792021892,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"fecac0f20b5c6e163e995fb8c9bc8fec34bf8c8adc82b5b0fd1b9e8665b58301","lane":"cross","parents":["a49c7eee0f50a50d7f43a2cb2058e6fccc5863bb"],"secs":74,"stamp":"fbbfba6282bb35a6e4fbfce6cecafe5b","tree":"92cc4db5b93bcd8b5bff168d91dbb66c2fd7e748","v":1,"via":"run"}
Ci-Attestation: {"at":1792021892,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"fecac0f20b5c6e163e995fb8c9bc8fec34bf8c8adc82b5b0fd1b9e8665b58301","lane":"cross","parents":["a49c7eee0f50a50d7f43a2cb2058e6fccc5863bb"],"secs":74,"stamp":"75541b54309c468e2943915d9b351f85","tree":"92cc4db5b93bcd8b5bff168d91dbb66c2fd7e748","v":1,"via":"run"}
Ci-Attestation: {"at":1792021892,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"fecac0f20b5c6e163e995fb8c9bc8fec34bf8c8adc82b5b0fd1b9e8665b58301","lane":"cross","parents":["a49c7eee0f50a50d7f43a2cb2058e6fccc5863bb"],"secs":74,"stamp":"e80e5aae2bcfb90bf2bfd0e0fdc19194","tree":"92cc4db5b93bcd8b5bff168d91dbb66c2fd7e748","v":1,"via":"run"}
Ci-Attestation: {"at":1792021892,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"e7d521ea5ff112cb8721927bf6bee1de7ad8c6fc399b42605a34b896ec8d8b19","lane":"tier2-linux","parents":["a49c7eee0f50a50d7f43a2cb2058e6fccc5863bb"],"secs":256,"stamp":"1365d3e9e28127e66a9afa687b540255","tree":"92cc4db5b93bcd8b5bff168d91dbb66c2fd7e748","v":1,"via":"run"}
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.
Problem
When a local full-decode media source is paused and then sought, the cache selects the requested frame but does not publish it. The displayed video therefore stays on the pre-seek frame until playback resumes. The non-cached path already publishes the seek frame in this case.
Root cause
On master,
shared/media-playback/media-playback/cache.c:480-485handles a seek by settingseek_next_ts, selecting cached indices, and immediately continuing. A paused cache then returns to its semaphore wait before normal video output. The existing seek-frame callback path is incache.c:285-286, but the seek branch never calls it. The non-cached path (media.c:563) callsmp_media_next_video(m, true)after a seek only whenm->pauseis set.Fix
After selecting cached indices, call
mp_cache_next_video(c, true)when the cache is paused and has video and a seek callback:if (pause && c->has_video && c->v_seek_cb). This mirrors the pause check atmedia.c:563. One difference:media.cchecksv_preload_cb, while this checksv_seek_cb, the callback it actually calls, so it can never call a NULL seek callback. The only in-tree consumer registers both. The fix reuses the existing seek callback path, only publishes for consumers that requested it, and leaves playback paused. A seek while playing does not call the seek callback; the normal output path shows the landed frame, as before.seek_frame) uploads a texture and resets the async frame clock, which is wrong during playback. An earlier revision of this branch did this and the review caught it; the new playing-seek case pins the guard.Evidence
RED:
test_media_cached_paused_seekon baseea3df88c79862e1ac01623f24d941f44b8884de6plus tests-only RED commit09c994d0250f5aa4112cd5ad54ec8b259a3ecd5efails both paused cases, with Rust libobs OFF and ON (3/3 runs each):paused seek: normal=3 seek_callbacks=0 seek_luma=0 expected_luma=0and... expected_luma=5. The playing case passes on the base (nothing is published there), as it should.GREEN: all three cases pass on
617577a3d448174ba07732984be303fbde59c8e5(30/30 repeated runs with Rust libobs OFF, 20/20 with ON).The test uses the real full-decode cache API and a local mixed video/audio Matroska fixture. Each case issues its request from the cache thread's own video callback after the third normal frame (luma 10), so no sleeps or libobs test hooks are needed for ordering:
v_seek_cbis called exactly once with the first frame (luma 0). Kills "never publish" and "publish the pre-seek frame".v_seek_cbcall, and the first normal frame after the request is the landed frame (luma 5). The cache thread is sequential, so a normal frame after the request proves the seek was already handled. This case fails on the earlier version of the fix that published on every seek.Negative results are proven by event barriers rather than timeouts. In the paused cases the test waits for the cache thread to take the request (
cache.seekcleared undercache.mutex), then callsmp_cache_stop;stop_cbruns on the cache thread in a later loop iteration than the seek, so any seek callback has already run. The condition-variable waits are only a liveness bound.Mutants (macOS, Rust libobs OFF; each fails every run, 3/3):
pauseguard)!pause)video_frames.array[0]mp_cache_next_video(c, false)(normal output path)seek_toFixture:
test/cmocka/data/media_cached_paused_seek.mkv(487 KB: 5 s, 16x16 ffv1 at 10 fps with luma5 * frame_index, plus 48 kHz mono s16 audio). The same decoded content is committed by the other media-playback test branches under different names. The generator command is in the test header:ffmpeg -f lavfi -i "color=c=black:s=16x16:r=10:d=5,format=yuv420p,geq=lum='5*N':cb=128:cr=128" -f lavfi -i "aevalsrc='500*(floor(t*10)+1)/32768':s=48000:d=5:c=mono" -c:v ffv1 -c:a pcm_s16le -t 5 out.mkv. Decoded frames and samples match the committed file; only container bytes differ between runs.Local build: macOS arm64, Debug,
ENABLE_UNIT_TESTS=ON, frontend, scripting, browser and websocket OFF, no sanitizer;ENABLE_RUST_LIBOBSOFF and ON.Real run: no separate full OBS session. The headless test exercises the cache thread, pause, seek, and video callback directly.
Fork CI: not run. Our self-hosted CI is down (see our note on #699), so this relies on upstream PR CI.
Compatibility & risk
No C API or ABI changes. A seek while paused, with a registered video seek callback, now publishes the selected cached frame while preserving the paused state, matching the non-cached path. A seek while playing is unchanged from master. One edge case: when
seek_torejects an out-of-range position (cache.c:169-172) it returns early, and a paused seek then re-publishes the frame at the current index. That is harmless. Local validation covered macOS arm64 with Rust libobs OFF and ON; Linux OFF/ON was not run locally and relies on upstream PR CI.Status
Tests-only RED:
09c994d0250f5aa4112cd5ad54ec8b259a3ecd5e. GREEN:617577a3d448174ba07732984be303fbde59c8e5. Both are pushed to the fork branchfix/media-paused-cache-seek. Status: draft. Opened so upstream PR CI can run it.How this was tested
test_media_cached_paused_seekCMocka target in macOS arm64 Debug withENABLE_RUST_LIBOBSOFF and ON,ENABLE_UNIT_TESTS=ON. On the base both paused cases reportseek_callbacks=0; after the fix all three cases pass. The six mutants above were run locally (OFF). No sanitizer was enabled locally.Thank you to the obs-rust maintainers and contributors for building this project in the open. In the American spirit of free expression and individual independence, and with the principle of judging contributions on their merit alone, this PR is a small piece of what independent people can build when they come together.