Repository navigation
libobs: Refuse a cycle in obs_transition_set - #2498
Merged
Merged
Conversation
Member
|
Coordinator review: correct. obs_transition_set() now refuses a source that contains the transition (or is the transition), with the same recursion walk and warning that obs_transition_load() and obs_transition_start() already use, before changing anything. That's what prevents the double lock. transition_start.rs's walk rule is widened to match, with its parity test. A new test is added and no existing assertion changes. Queuing. |
zackees
enabled auto-merge
October 26, 2026 16:02
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 26, 2026
Set a transition to a scene that holds it, to a scene holding that scene and to itself, and check that the set is refused and that showing the scene again returns. obs_transition_set() stores the cycle, and the walk of the scene's tree locks the transition's mutex twice: a watchdog thread fails the test after 5 seconds instead of letting it hang. Refs obs-rust#2487
obs_transition_set() stored a source that contains the transition (or the transition itself) in slot A. A walk of that source's active tree then entered the transition again and locked its mutex twice: showing the scene hung. Refuse such a source before changing anything, with the recursion walk obs_transition_start() uses, and log it, as obs_transition_load() does. Fixes obs-rust#2487
rdoupe
force-pushed
the
fix/transition-set-cycle
branch
from
October 26, 2026 16:41
fd508aa to
ea3394f
Compare
zackees
enabled auto-merge
October 26, 2026 16:52
3 of 7 tasks
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 #2487
What and why
obs_transition_set()stored any source in slot A, even one that contains the transition (a scene that holds the transition as an item, a scene holding that scene, or the transition itself).obs_transition_load()refuses such a source with "infinite recursion", andobs_transition_start()refuses such a destination before it changes anything, butsetdid not. While the slot holds it, the source's tree goes through the transition back to the source, so any walk of its active tree (showing or activating the scene, or the audio thread's walk of an output channel) enters the transition a second time and locks its non-recursive mutex twice: OBS hangs. Upstream OBS Studio master has the same code; there is no upstream issue or fix.The fix:
obs_transition_set()first runs the recursion walk ofobs_transition_start()over the new source (check_transition_recursion(), withobs_source_transition_start_walks()from #2478 deciding whether it runs, and the transition itself counting as recursive). On a cycle it logs a warning and returns before changing anything: no stop signal, both slots and their flags stay as they were, so the transition keeps its source. Every other source is set as before.obs_transition_set()already walked the new source's tree once (insideobs_source_add_active_child()), so the extra walk takes no lock thatsetdid not already take.The walk decision stays the Rust
walks()(rust/obs-sourcetransition_start), unchanged; it now has a second caller, named in its doc comments, the header andrust/README.md. No Tier 1 test changes: the function's rule is the same.How this fits with #2485 (merged): #2485 keeps slot A inactive when the add of its source fails. After this PR,
setno longer reaches that add with a cycle, so #2484's case needs the add to fail although the walk just before it found no cycle. Both walks test the same edges, andobs_scene_add()refuses to add the transition to a scene it holds, so that should not happen; #2485 stays as the backstop, and each fix is correct without the other. Withobs_transition_start(): its pre-check is unchanged, and its own calls ofobs_transition_set()(finishing a running transition, and the manual reset) pass a source the transition already holds, which passed the same check when it came in.Needs maintainer sign-off: the stand-in model of
obs_transition_set()intest/cmocka/test_transition_start_steps.c(the block "characterized, not endorsed: a set whose add fails still marks slot A active") and the one inrust/obs-source/tests/source/transition_start.rscopy the old function and do not refuse a cycle. They do not call the real function, so they still pass, but they no longer describe it. Existing C test assertions are not changed here (AGENTS.md); retiring that line is a follow-up for a maintainer to approve (it is the same line #2485 left).New test
test_transition_set_cycle(real libobs, core video, Linux under xvfb-run,graphicssuite intest-graph.json): a scene holds a leaf source and the transition, and an outer scene holds that scene. Each case sets the transition to an unrelated source, makes the scene output channel 0's source, sets the transition to the cycle, and checks that slot A still holds the unrelated source, that showing the scene again returns, and that the activate/show counts and the leaf's callbacks are right. The walk runs under a watchdog thread: if it has not returned after 5 seconds, the test printsHANG: ...and exits with a failure, so a hang fails instead of stalling CI.set_acyclic_source_is_stored(control): a source outside the cycle is stored, held, and released by the next set.set_containing_scene_is_refused: the scene that holds the transition.set_outer_scene_is_refused: the outer scene (the cycle is two levels deep).set_itself_is_refused: the transition itself.Not in this PR:
obs_transition_swap_begin()can still store such a source. A transition outside the scene that holds the scene, swapped into a transition the scene contains, leaves the scene in the destination's slot A; a probe on top of this fix (swap, thenobs_source_inc_showing(scene)) hung the same way. #2486 fixes the reference counts of that swap, not the stored cycle.RED → GREEN
test: Check obs_transition_set refuses a cycle). On the C build, hybrid libobs and libobs-c-reference, the control passes, thenset_containing_scene_is_refusedreportsslot A holds 'cycle scene', expected 'other'andHANG: showing the scene after setting the scene that holds the transition did not return within 5000 ms, and the watchdog ends the test binary (about 6 s) with a failure.test_transition_set_cycle4/4 on all three lanes, each refused set logged once (3 warnings); all cases skip without a display. The affected ctest set (transition|scene|studio_mode|fade|stinger|group|source_active|swap) passes with no skips: 50/50 on the C build, 59/59 on hybrid libobs, 59/59 against libobs-c-reference (rebuilt first). Exported symbols are the same on all three. Local gate:--lane lint,--test-diff origin/masterand--lane crosspass.obs_transition_set: cannot set transition '<name>' to source '<name>' due to infinite recursion.Checklist
master(or the description starts with a Stacked: note)docs/features.mdis added or updated (not applicable: no user-visible change)-W..., ratchets): built with scripting ON (PR CI builds no OBS app: rungh workflow run ci.yml --ref <branch>for the full builds) and cross-checked with clang and MSVC