Repository navigation
image-source: Clear an emptied legacy slideshow in manual, paused and deactivated modes - #735
Merged
zackees merged 5 commits intoOct 15, 2026
Conversation
Member
|
Tier 2 Linux: one cmocka test fails, 208/209 pass. Cause: in add_test(NAME test_slideshow_empty COMMAND ${XVFB_RUN_EXECUTABLE} -a $<TARGET_FILE:test_slideshow_empty>)(and likewise |
zackees
marked this pull request as ready for review
October 14, 2026 23:11
The old add_test(<name> <cmd>) form does not expand generator
expressions, so xvfb-run was given the literal $<TARGET_FILE:...>.
Local-Gate: v1 tree=68604a72309e3d34ca7e9343354d71acd8c1dbc2 secs=409 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run
Ci-Attestation: {"at":1792022409,"gate":"rust/all/fmt","host":"linux-x86_64","key":"d529a945ba00a8902ecd161f348c2352d3b0020e8865c5bef70d9c49246d8328","lane":"lint","parents":["8bd824010e84fd507a1ba10b3ddcec06434565a6"],"secs":43,"stamp":"b84ea637ab81b5e21f488b431e0dc00d","tree":"68604a72309e3d34ca7e9343354d71acd8c1dbc2","v":1,"via":"run"}
Ci-Attestation: {"at":1792022409,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"d529a945ba00a8902ecd161f348c2352d3b0020e8865c5bef70d9c49246d8328","lane":"lint","parents":["8bd824010e84fd507a1ba10b3ddcec06434565a6"],"secs":43,"stamp":"19b89ad1096b891a6dc91c79fcb02f54","tree":"68604a72309e3d34ca7e9343354d71acd8c1dbc2","v":1,"via":"run"}
Ci-Attestation: {"at":1792022409,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"d18ef087d91d45ee61df013cb92b54fc2fd46db87b46df4d75100873524827d3","lane":"rust-test","parents":["8bd824010e84fd507a1ba10b3ddcec06434565a6"],"secs":98,"stamp":"88b32901e3605ea26a568a05216489a0","tree":"68604a72309e3d34ca7e9343354d71acd8c1dbc2","v":1,"via":"run"}
Ci-Attestation: {"at":1792022409,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"68cb8242d6ce328837ed96462bab2b481eab51f3fd501daa5303a2f868807090","lane":"cross","parents":["8bd824010e84fd507a1ba10b3ddcec06434565a6"],"secs":72,"stamp":"f1ddde48a8f8f6025f14ba7f56bdffcf","tree":"68604a72309e3d34ca7e9343354d71acd8c1dbc2","v":1,"via":"run"}
Ci-Attestation: {"at":1792022409,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"68cb8242d6ce328837ed96462bab2b481eab51f3fd501daa5303a2f868807090","lane":"cross","parents":["8bd824010e84fd507a1ba10b3ddcec06434565a6"],"secs":72,"stamp":"def621e7d1bbd2716ffb951d9bf48b1e","tree":"68604a72309e3d34ca7e9343354d71acd8c1dbc2","v":1,"via":"run"}
Ci-Attestation: {"at":1792022409,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"68cb8242d6ce328837ed96462bab2b481eab51f3fd501daa5303a2f868807090","lane":"cross","parents":["8bd824010e84fd507a1ba10b3ddcec06434565a6"],"secs":72,"stamp":"e522914472f42391ba3283fc3b7d4e15","tree":"68604a72309e3d34ca7e9343354d71acd8c1dbc2","v":1,"via":"run"}
Ci-Attestation: {"at":1792022409,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"68cb8242d6ce328837ed96462bab2b481eab51f3fd501daa5303a2f868807090","lane":"cross","parents":["8bd824010e84fd507a1ba10b3ddcec06434565a6"],"secs":72,"stamp":"7c4f50189aef6b7f8773ca3c49b45757","tree":"68604a72309e3d34ca7e9343354d71acd8c1dbc2","v":1,"via":"run"}
Ci-Attestation: {"at":1792022409,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"68cb8242d6ce328837ed96462bab2b481eab51f3fd501daa5303a2f868807090","lane":"cross","parents":["8bd824010e84fd507a1ba10b3ddcec06434565a6"],"secs":72,"stamp":"896869ad0572e91f0f8f87d12b32e5c8","tree":"68604a72309e3d34ca7e9343354d71acd8c1dbc2","v":1,"via":"run"}
Ci-Attestation: {"at":1792022409,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"68cb8242d6ce328837ed96462bab2b481eab51f3fd501daa5303a2f868807090","lane":"cross","parents":["8bd824010e84fd507a1ba10b3ddcec06434565a6"],"secs":72,"stamp":"1d07de5a6b4bba540d32bc1ba1483c12","tree":"68604a72309e3d34ca7e9343354d71acd8c1dbc2","v":1,"via":"run"}
Ci-Attestation: {"at":1792022409,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"1c799fad48e8d4397f43103b310a456cd8e669309c147afb3e20db1f09570768","lane":"tier2-linux","parents":["8bd824010e84fd507a1ba10b3ddcec06434565a6"],"secs":196,"stamp":"4a221cac1352e6f44aef9eeec2fe799b","tree":"68604a72309e3d34ca7e9343354d71acd8c1dbc2","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
The legacy slideshow source (
plugins/image-source/obs-slideshow.c) fades out and reportsmedia_endedwhen its file list becomes empty, but only in automatic playback. If the list is emptied while the slideshow is in manual mode, paused, stopped, or deactivated with "pause on deactivate", the transition's active child is never cleared and the media state never reaches ENDED.Fixing that exposes a second problem in the same function. The clear path (and the restart and list-end transitions) ran with the non-recursive
ss->mutexheld and emittedmedia_endedandslide_changedsynchronously. A signal subscriber that callsobs_source_enum_active_sources()on the slideshow re-entersss_enum_sources(), which locks the same mutex, and the video thread deadlocks. So the clear has to be decided under the lock and carried out after it is released.Root cause
All line numbers are
upstream/master(a48a9a13d).plugins/image-source/obs-slideshow.c:734returns throughgoto finishforpause_on_deactivate || manual || stop || paused. The empty-list block at:739-746comes after it, so those modes never reach it.do_transition(ss, true)(:744) withss->mutexheld (locked at:719). The other tick transitions (:727,:757,:759) are also called under the lock.do_transition(:252-276) emitsmedia_ended(:267) andslide_changed(:275).signal_handler_signalcalls each subscriber synchronously (libobs/callback/signal.c:305), andobs_source_media_endedraises the signal atlibobs/obs-source.c:6040.obs_source_enum_active_sources()reachessource->info.enum_active_sources(libobs/obs-source.c:4695), which isss_enum_sources(obs-slideshow.c:1058). That function takesss->mutex(:824), and the mutex is created with default attributes (:689), so it cannot be taken twice. The reproduction is deterministic, not a race.Fix
Only
plugins/image-source/obs-slideshow.cchanges (GREEN).do_transitionis split into two steps:prepare_transition()runs under the lock and copies the decision into astruct transition_plan(obs-slideshow.c:255-280on the GREEN commit): referenced transition and destination, a copy of the path, the index,tr_speed, and theuse_cut/to_nullflags.run_transition()(:282) performs the transition calls and emits the signals, and the tick now calls it afterpthread_mutex_unlock(:818-821).do_transitionremains for the callers that never hold the mutex (ss_updateand the media actions) and is documented "Callers must not hold ss->mutex" (:309).In
ss_video_tick(:755-822)::779-796) moved above the manual/paused/stop guard (:798). It takes a reference to the transition, releases the mutex (:785), then starts the NULL transition, sets ENDED and emitsmedia_endedwith no lock held, and returns. It still only fires when a child is active, so later empty ticks stay quiet.:766-775) and the end-of-list branch (:808-811) now build a plan under the lock and run it after unlock.stop_restartslideshow ends it again once per activation.Alternatives:
ss->mutexrecursive. Not taken: it would change the lock type for every path instead of removing the callbacks-under-lock pattern.obs-slideshow-mk2.ctoo. Not done: see Compatibility & risk.Evidence
Branch
fix/slideshow-manual-empty-clearon the fork, two commits on base7cf6f3932(an olderupstream/master; the file differs from currentupstream/masteronly in anEPSILONcast and a reformattedobs_missing_file_createcall, away from the code touched here):86df3c8a0fd8999dcb6731628f48e6fd75a7e689"image-source: test empty slideshow clearing in paused modes (RED)".3a3717f10bb57cf72364850bd661d6db88188d6a"image-source: clear empty slideshow outside the mutex (GREEN)".Tests (
test/cmocka/test_slideshow_empty.c, registered intest/cmocka/tests.d/test_slideshow_empty.cmake, which is guarded byif(TARGET image-source AND TARGET obs-transitions)). The file is byte-identical in RED and GREEN. It links the real slideshow and cut-transition sources with libobs and drives the registeredupdate,activateandvideo_tickcallbacks synchronously, with no video thread, sleeps or timing.manual_empty_clears,paused_empty_clears,deactivated_empty_clears(:237,:275,:283), plusautomatic_empty_clears(:232) as a control. Each asserts the active child is NULL, state ENDED, exactly onemedia_ended, and none on a second empty tick.obs_source_enum_active_sources():manual_empty_callback_reenters(:246),manual_activation_empty_clears(:313, a manualstop_restartslideshow emptied before activation),activation_restart_reenters(:338),list_end_hide_reenters(:356),list_end_keep_reenters(:373).manual_one_image_tick_retains_child(:255, a settled one-image manual slideshow is not cleared),empty_reactivation_ends_again(:394,media_endedreaches 2), andrestart_reports_slide_payload(:422, theslide_changedindex and path after an update and after an activation restart).alarm(5)(CASE_TIMEOUT_SECONDS,:455; fork at:500, alarm at:507). Windows runs the cases in-process. The CTest timeout is 60 s (tests.d/test_slideshow_empty.cmake:27) so the four bounded hangs fit.Local results from our review (macOS, Apple Clang, C17,
-Werror, the test linked against existing libobs frameworks built with the Rust port OFF and ON; not a CMake/CTest run of CI):RED test on the base slideshow, OFF and ON identical (2 runs each, 22-25 s):
The four controls that pass on base (
automatic_empty_clears,manual_one_image_tick_retains_child,empty_reactivation_ends_again,restart_reports_slide_payload) pass.GREEN:
0 of 12 case(s) failed, 3 runs per mode (2.3-3.9 s), OFF and ON, and each case also passes when run alone. Our CTest runs of the same test passed in both modes (100% tests passed out of 1, about 3 s).Mutants against GREEN (OFF), each failing a named case:
plan->index = 0:restart_reports_slide_payload,0 != 1.plan->pathtaken from the first file:restart_reports_slide_payload,"a.png" != "b.png".files.num:empty_reactivation_ends_again,1 != 6(state PLAYING instead of ENDED).died from signal 14 (hang)for the matching cases (2, 2 and 1 cases).files.num <= 1boundary mutant is killed bymanual_one_image_tick_retains_child.A review pass on a commit with the same production file as GREEN compared tick traces (
media_endedcount, media state, cleared child,slide_changedcount, index and path) between base and GREEN on seven lifecycle scenarios, in OFF and ON, and found them identical. These were review probes and are not committed tests.Fork CI: not run. Our self-hosted CI is down (see our note on #699), so this relies on upstream PR CI.
Real-run evidence: the full app was not run. The cases use the real slideshow and cut-transition code and real libobs signals, but no decoder or renderer.
Compatibility & risk
No C API, ABI, export or Rust change. Rust parity needs nothing: there is no slideshow code under
rust/, andENABLE_RUST_LIBOBSonly changes which libobs the test links, so the same C plugin runs in both modes.Behaviour changes, all in the legacy slideshow tick:
media_endedonce, as automatic mode already did.media_endedandslide_changedsubscribers now run afterss->mutexis released and after the tick's flags (restart_on_activate,use_cut,stop) are cleared, so they can enumerate the source. Theslide_changedpayload comes from the plan's copy of the index and path.obs_source_media_next, whichss_next_slideignores when the list is empty (obs-slideshow.c:543onupstream/master), andss_updateresetselapsed(:510on GREEN).Limits found in review:
plugins/image-source/obs-slideshow-mk2.c, the version-2 source registered next to it (image-source.c:403-404), has the same early return before the empty-list block (obs-slideshow-mk2.c:845-846, empty block at:850). It is not changed here, so this PR must not be read as fixing current slideshows. The legacy source is flaggedOBS_SOURCE_CAP_OBSOLETE(obs-slideshow.c:1048). A follow-up for mk2 can reuse the same split if the maintainers want it.hideset, the end re-fires everyslide_time.use_cutbeforeprepare_transitionin the restart branch. The headless cut-only fixture cannot tell a cut from an automatic start, so it would only show with a real fade.fork, so on Windows the cases run in-process with only the 60 s CTest bound, and an unknown case name passed asargv[1]runs nothing and exits 0 on POSIX.detect_leaksor Windows run, and no full./unittest. The same review's allocation probe showed zero residual allocations for every case in OFF and ON, but that is a review probe, not a committed assertion.Status
Draft. Opened so upstream PR CI can run it.
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.