Repository navigation
libobs: Keep slot A inactive after a failed add - #2485
Merged
Merged
Conversation
obs_transition_set() marks slot A active even when the source cannot be added as an active child (it contains the transition). The next call then removes a reference the transition never added, so the program scene, the sources in it and the transition are deactivated while the output channel still shows the scene, and a source set after the cycle ends up with negative counts. Refs obs-rust#2484
obs_transition_set() marked slot A active even when its source could not be added as an active child of the transition, which happens when the source contains the transition. The next set then removed an active reference the transition never added, so a scene shown in Program or a projector, the sources in it and the transition itself were deactivated while still shown, and a source set after the cycle ended up with negative counts. Clear the flag again when the add fails and slot A still holds the source. The success path is unchanged, and the source is still stored in the slot as before. Fixes obs-rust#2484
This was referenced Oct 26, 2026
Member
|
Coordinator review: correct. When obs_source_add_active_child() fails (the source contains the transition), slot A's flag is cleared under the transition lock, guarded by a check that the slot still holds that source. So the next set no longer drops a reference another parent holds. The change is in obs-source-transition.c.h, which the C, hybrid and libobs-c-reference builds all compile, so no Rust diverges, and README's 'characterized, not endorsed' note is updated to match. A new graphics-suite test is added, no existing test changes, and the ledger line is in. Queuing. |
zackees
enabled auto-merge
October 26, 2026 14:32
This was referenced Oct 26, 2026
rdoupe
added a commit
to rdoupe/obs-studio
that referenced
this pull request
Oct 26, 2026
* test: Check transition swap active counts Swap a transition that holds a scene into a transition inside that scene, then set it to nothing or to another source, and check the activate/show counts of the scene, its sources and the transition. The swap marks the slot active although the add of the scene failed (a cycle), so the set takes the scene's references away. Refs obs-rust#2486 * libobs: Keep swapped slots inactive on failed add copy_source_state() copied the old transition's slot flag to the new one even when the add of that slot's source on the new transition failed (the source contains the new transition). The next obs_transition_set() then removed an active reference the new transition never had, taking the scene's references away from its other parent. Clear the flag when the add fails, as obs-rust#2485 does for obs_transition_set(). Fixes obs-rust#2486
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 #2484
What and why
obs_transition_set()marked slot A active even when its source could not be added as an active child of the transition. The add fails when the source contains the transition, for example a scene that holds the transition as an item. The nextobs_transition_set()then removed an active reference the transition never added. The scene lost the reference of whatever else shows it (the output channel, or a projector), so the scene, every source in it and the transition were deactivated (or hidden) while still shown, and theirdeactivate/hidecallbacks ran (a media source in that scene would stop). When the next set gave the transition another source, the scene's deactivation walked the transition, which already held that source before it was added, so the new source ended at -1 and was never shown. Upstream OBS Studio master has the same code; there is no upstream issue or fix.The fix: when the add fails, clear slot A's flag again, if the slot still holds that source. The success path and the order of the remove and add calls are unchanged. The source is still stored in the slot, so
obs_transition_get_source()is unchanged.obs_transition_load()already refuses such a source, andset_source()(used byobs_transition_start()) already marks nothing when its add fails.The decision is in C: the Rust step
obs_source_transition_start_child_active()(#2478) only combines "there is a child" and "the slot is active", and stays as it is.rust/README.mddropsobs_transition_set()from its "kept, characterized, not endorsed" list.Needs maintainer sign-off: the stand-in models in
test/cmocka/test_transition_start_steps.c(the block "characterized, not endorsed: a set whose add fails still marks slot A active") andrust/obs-source/tests/source/transition_start.rs(the same case in the set test) copy the oldobs_transition_set()and still assert the old flag. 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 both lines is a follow-up for a maintainer to approve.New test
test_transition_set_active(real libobs, core video, Linux under xvfb-run,graphicssuite intest-graph.json): a scene holds a leaf source and the transition.cycle_keeps_output_channel_reference: the scene is output channel 0's source; set the transition to the scene, then to nothing; the scene, leaf and transition keep 1/1 activate/show counts and the leaf gets no deactivate or hide callback.cycle_keeps_shown_reference: the same with the scene shown only (obs_source_inc_showing(), as a projector does).acyclic_source_is_held_and_released(control): a source outside the cycle is activated by the transition and released by the next set.cycle_then_acyclic_source: a cyclic source replaced by an acyclic one; the scene keeps its counts and the new source is held, then released.Not in this PR, found while testing (same fixture, scratch probe):
obs_transition_swap_begin()(copy_source_state()) has the same imbalance: it copies the source's slot flag to the destination transition even when its add there fails. After a swap into a transition that the scene contains, the next set took the scene's references away.obs_source_inc_showing(scene)did not return within 5 seconds. Any walk would do the same, for example the audio thread's walk of an output channel.RED → GREEN
test: Check obs_transition_set active counts).test_transition_set_activefails 3 of 4 cases on the C build, hybrid libobs and libobs-c-reference (the control passes). For example:after clearing the cycle: 'cycle scene' activate_refs=0 show_refs=0, expected 1/1,'leaf' activate=1 deactivate=1 show=1 hide=1, expected 1/0/1/0,after replacing the cycle: 'other' activate_refs=-1 show_refs=-1, expected 1/1.test_transition_set_active4/4 on all three lanes. The affected ctest set (transition|scene|studio_mode|fade|stinger|group|source_active|swap) passes with no skips: 49/49 on the C build, 58/58 on hybrid libobs, 58/58 against libobs-c-reference (rebuilt first). Exported symbols are the same on all three. Local gate:--lane lint,--test-diff origin/masterand--lane crosspass.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