Repository navigation
libobs: Move the active-child link when an item changes group - #242
Merged
Merged
Conversation
Moving a scene item into or out of a group changes which scene holds it, but the source stays an active child of the old scene. Activation and deactivation then walk different trees: a source moved into a hidden group stays active and showing after its scene goes off the output (audio keeps playing, the mixer keeps listing it), and a source moved out of a hidden group is never activated. The test checks the raw activate/show counts through obs_scene_reorder_items2() (what the source tree's drag and drop uses), obs_sceneitem_group_add_item()/_remove_item() and obs_scene_insert_group(), including a nested scene, a move between two groups and hidden items, and ends every case by deleting everything while the scene is on the output, where the counts must return to exactly zero. Visible-group, hidden-item, insert_group and nested-preview cases are controls that already pass. It fails on the six hidden-group move cases. Reported upstream in obsproject/obs-studio#9961 by walker-WSH, with a second report by kpaulisse. Refs obs-rust#241. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A visible scene item's source is an active child of the scene that holds it. obs_sceneitem_group_add_item(), obs_sceneitem_group_remove_item(), obs_scene_reorder_items2() and obs_scene_insert_group() move items into or out of a group's scene without moving that link, so activation and deactivation walk different trees and the source's activate/show counts drift: a source moved into a hidden group stays active after its scene leaves the output, and one moved out of a hidden group is never activated. Whenever a visible item changes parent, add its source as an active child of the new parent, then remove it from the old one. Adding first means a source that stays on screen (a move into a visible group) never drops to zero in between. Hidden items hold no activation and are left alone. Upstream: obsproject/obs-studio#9961 (reported by walker-WSH). Fixes obs-rust#241. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Local-Gate: v1 tree=52d9f27104c1cd1471529804926d9a007e43b1ce secs=84 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791731633,"gate":"rust/all/fmt","host":"linux-x86_64","key":"a1eee73fbbdd9b2cd96aaf0757a5d1790f2fbb8fd52c00192d64ab12332db728","lane":"lint","parents":["01e8129cf812d32d5beea93d4b30329aef585cfd"],"secs":14,"stamp":"ddc6588cf6451995edaaa036113f7d6b","tree":"52d9f27104c1cd1471529804926d9a007e43b1ce","v":1,"via":"run"} Ci-Attestation: {"at":1791731633,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"a1eee73fbbdd9b2cd96aaf0757a5d1790f2fbb8fd52c00192d64ab12332db728","lane":"lint","parents":["01e8129cf812d32d5beea93d4b30329aef585cfd"],"secs":14,"stamp":"f738b1ffa5a5eff74e09b0c51083caf4","tree":"52d9f27104c1cd1471529804926d9a007e43b1ce","v":1,"via":"run"} Ci-Attestation: {"at":1791731633,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"0e88c2ccfb87d10b31714427d8354c5ff7e210a2bf4487fd14ba8edde7ed083d","lane":"rust-test","parents":["01e8129cf812d32d5beea93d4b30329aef585cfd"],"secs":29,"stamp":"93475932dfd7ac00d94a88aa20b7e64a","tree":"52d9f27104c1cd1471529804926d9a007e43b1ce","v":1,"via":"run"} Ci-Attestation: {"at":1791731633,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"9506e2e235ff506757536d45ce23e24d9c3a5cea23346ddaf483f9f871f95970","lane":"tier2-linux","parents":["01e8129cf812d32d5beea93d4b30329aef585cfd"],"secs":40,"stamp":"ed610bbc9c47331d14b6457df332f66a","tree":"52d9f27104c1cd1471529804926d9a007e43b1ce","v":1,"via":"run"}
Member
|
Verified locally, rebased onto master and stamped. The test skips without a display, so I ran it with
Merging once CI is green. |
zackees
force-pushed
the
fix/241-group-active-refs
branch
from
October 11, 2026 15:13
d9108cc to
9ce8e92
Compare
zackees
approved these changes
Oct 11, 2026
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.
Description
Moving a source into a hidden group (or out of one) no longer leaves its active/show counts wrong. Before this change, a source moved into a hidden group kept playing audio and stayed in the mixer, even after the group and the source were deleted; a source moved out of a hidden group was visible but never activated.
A visible scene item's source is an active child of the scene that holds it.
obs_sceneitem_group_add_item(),obs_sceneitem_group_remove_item(),obs_scene_reorder_items2()(the source tree's drag and drop) andobs_scene_insert_group()move items between a scene and a group's scene without moving that relationship, so activation and deactivation walk different trees.test: Group moves must keep activate/show counts balanced:test_group_active_refsruns core video and audio, builds scenes and groups, and checks the rawactivate_refs/show_refsafter each step, finishing every case by deleting everything while the scene is on the output (the counts must return to exactly 0). 6 of 10 cases fail on this commit: drag and drop into and out of a hidden group,group_add_itemandgroup_remove_itemwith a hidden group, a nested scene dragged into a hidden group, and swapping sources between a hidden and a visible group. The 4 controls pass: a visible group, a hidden item,obs_scene_insert_group()with a hidden item, and kpaulisse's nested-scene studio-mode setup.libobs: Move the active-child link when an item changes group: amove_active_child()helper, called from the four functions, adds a visible item's source as an active child of its new scene and then removes it from the old one. Adding first means a source that stays on screen never drops to zero in between; hidden items hold no activation and are skipped. All 10 cases pass.Why this approach: the activation state is not stored per link, it is recomputed by walking the tree, so the fix has to apply the difference at the moment the item changes scene. Lain-B closed the frontend workaround (#10417) because the bug is in the backend (
obs-scene.c); fixing it there also covers every plugin and script that moves items through the API. It reusesobs_source_add_active_child()/obs_source_remove_active_child()exactly asobs_sceneitem_set_visible()does, and adds no API.Motivation and Context
Fixes #241 (upstream obsproject/obs-studio#9961, reported by walker-WSH)
Why this one: a confirmed bug open upstream since 2023 (and in an earlier report since OBS 25), hit by ordinary drag and drop in the source tree. walker-WSH traced it to unmatched
show_refs/activate_refs, kpaulisse reported the same symptoms, and Lain-B's review of #10417 pointed atobs-scene.c. Users hear audio from sources they have hidden or deleted.How Has This Been Tested?
Automated:
test_group_active_refsfails 6 of 10 at the RED commit and passes 10 of 10 at the GREEN commit; 10 of 10 repeated runs at GREEN pass. The full cmocka suite passes at GREEN (81 of 81). All runs used a private Xvfb with software GL. clang-format and gersemi are clean.Reviewed every caller for double adds or removes. Hidden items, deleting an item after removing it from a group (what the frontend's Remove does) and
obs_scene_insert_group()with mixed visibility have test cases. An item with a pending hide was checked by reading the code: the audio action later removes the link from the item's current parent, which is now the new one.kpaulisse's variant (hide a group holding a nested scene while the parent scene is in program and in the studio mode preview) involves no move, and libobs already balances it, with and without audio flowing and with a duplicated program scene. It is kept as a control.
Not tested:
obs_scene_reorder_items2()already relinks that group's items without its lock; this change does not widen that.Types of changes
Checklist:
🤖 Generated with Claude Code