Repository navigation
Description
obs_transition_set() marks slot A active even when the source it sets there cannot be added as an active child of the transition. The add fails when the source contains the transition (a cycle, for example a scene that holds the transition as an item). The transition then holds no reference on the source, but the slot says it does, so the next obs_transition_set() removes an active child that was never added. That takes away the reference another parent holds: the source, everything in it and the transition itself are deactivated (or hidden) while that parent still shows them. The same code is in upstream OBS Studio master; there is no upstream issue or fix for it.
Location
libobs/obs-source-transition.c.h, obs_transition_set():
transition->transition_source_active[0] = true;
transition->transition_sources[0] = source;
...
unlock_transition(transition);
for (size_t i = 0; i < 2; i++) {
if (obs_source_transition_start_child_active(s[i] != NULL, active[i]))
obs_source_remove_active_child(transition, s[i]);
obs_source_release(s[i]);
}
if (source)
obs_source_add_active_child(transition, source);The result of obs_source_add_active_child() is ignored. The Rust step obs_source_transition_start_child_active() (from the transition start port, #2478) only combines "there is a child" and "the slot is active"; the slot flag itself is written in C, so the decision to fix is in C. obs_transition_load() already checks the same add and refuses the source with "infinite recursion", and set_source() (used by obs_transition_start()) marks nothing when its add fails.
Class
Reference count imbalance: wrong activate/show counts, sources deactivated while shown, counts below zero.
How it is reached
- A scene contains the transition as an item, and the scene is shown: it is the program of an output channel (main view), or shown as a projector shows it (auxiliary view). The transition is then active through the scene.
obs_transition_set(transition, scene). The add fails (the scene contains the transition), and slot A is marked active anyway.obs_transition_set(transition, NULL)(or any other source). The transition removes the scene as an active child, once per show reference of the transition.
Evidence (real libobs, C build, private Xvfb)
test/cmocka/test_transition_set_active.c builds the scene above with a leaf source in it. After step 3:
cycle_keeps_output_channel_reference
after clearing the cycle: 'cycle scene' activate_refs=0 show_refs=0, expected 1/1
after clearing the cycle: 'leaf' activate_refs=0 show_refs=0, expected 1/1
after clearing the cycle: 'transition' activate_refs=0 show_refs=0, expected 1/1
after clearing the cycle: 'leaf' activate=1 deactivate=1 show=1 hide=1, expected 1/0/1/0
cycle_keeps_shown_reference
after clearing the cycle: 'cycle scene' activate_refs=0 show_refs=0, expected 0/1
after clearing the cycle: 'leaf' activate_refs=0 show_refs=0, expected 0/1
cycle_then_acyclic_source (step 3 sets another leaf, 'other', instead of NULL)
after replacing the cycle: 'cycle scene' activate_refs=0 show_refs=0, expected 1/1
after replacing the cycle: 'other' activate_refs=-1 show_refs=-1, expected 1/1
The program scene stays in output channel 0, but it and its sources are inactive: the leaf's deactivate and hide callbacks run, so a media source in that scene would stop. In the last case the scene's deactivation walks the transition, which already holds the new source, before that source is added, so the new source ends at -1 and is never shown. Hiding the scene later does not bring the counts back.
Fix
When the add fails, clear slot A's active flag again (if the slot still holds that source). The success path is unchanged, and the source is still stored in the slot, as before, so obs_transition_get_source() is unchanged.
Not in scope
While slot A holds the cyclic source, the active tree of the scene goes through the transition back to the scene, so any walk of it (the audio thread's walk of an output channel, or showing the scene again) locks the transition's non-recursive mutex twice and hangs. A probe on the same fixture (output channel 0 shows the scene, obs_transition_set(transition, scene), then obs_source_inc_showing(scene)) did not return within 5 seconds. That is a separate problem with storing the cycle at all (obs_transition_load() refuses it; obs_transition_set() does not), and is not changed here.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Oct 26, 2026
Claiming: #2484 (fix ready).
libobs: Keep slot A inactive after a failed add (obs-rust#2485)