Skip to content

bug: libobs: moving a source into or out of a hidden group leaves it active (audio plays while hidden, or goes silent while visible) (upstream #9961) #241

Closed

Description

@rdoupe

Upstream OBS bug, reported by walker-WSH in obsproject/obs-studio#9961 (confirmed there; kpaulisse added a second report). Code unchanged in this fork.

Location

  • libobs/obs-scene.c:3701 obs_sceneitem_group_add_item() and :3737 obs_sceneitem_group_remove_item(): detach the item from one scene and attach it to the other.
  • libobs/obs-scene.c:3856 obs_scene_reorder_items2(): what the source tree's drag and drop calls (frontend/components/SourceTree.cpp:383); it reassigns item->parent when an item is dropped into or out of a group.
  • libobs/obs-scene.c:3536 obs_scene_insert_group(): same pattern when grouping selected items.

Class

Reference-count imbalance. A source stays active and showing when it is not on screen (audio keeps playing, the mixer keeps listing it, and it survives deleting everything), or is visible but never activated.

How it is reached

A visible scene item's source is an "active child" of the scene that holds it: activating a scene walks its tree and activates the child, and deactivation walks it again. None of the functions above move that relationship when an item changes scene, so the two walks see different trees. The steps from the report: hide a group, move an audio source into it, show the group, switch to an empty scene. The source was activated once by the outer scene and once by the group, but deactivated only once. Moving a source out of a hidden group does the opposite: it is visible but inactive, and switching away drives its counts negative.

Reproduced in a cmocka test with core video and audio running (private Xvfb, software GL): drag and drop and the add/remove API all leave the counts wrong; a visible group happens to balance.

kpaulisse's variant (hiding a group that holds a nested scene, with the parent scene in program and in the studio mode preview) involves no move. It balances in libobs, with and without audio flowing and with a duplicated program scene, so that report most likely reached the bad state through an earlier move into or out of the group.

Proposed fix and failing test

Fix: a move_active_child() helper in obs-scene.c. When a visible item changes parent, it adds the source as an active child of the new scene first and then removes it from the old one, so a source that stays on screen never drops to zero. Hidden items hold no activation and are left alone. It is called from the four functions above. This is the backend fix Lain-B asked for when closing the frontend workaround (#10417).

RED test (cmocka, test_group_active_refs): 10 cases that check the raw activate/show counts and finish by deleting everything while the scene is on the output. 6 fail today (every move into or out of a hidden group, a nested scene, a move between two groups); the 4 controls pass. With the fix all 10 pass.

Activity

  1. rdoupe commented on Oct 11, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: this issue.

    1. RED: test_group_active_refs (6 of 10 cases leave the counts unbalanced today).
    2. GREEN: move a visible item's active-child link to its new parent in the four group/reorder functions.
      PR within the hour.
  2. added 2 commits that reference this issue on Oct 11, 2026
    9ce8e92
    01e8129
  3. rdoupe commented on Oct 11, 2026

    @rdoupe
    CollaboratorAuthor

    @walker-WSH @kpaulisse @afonsofsdomingues you reported, hit or offered to fix this in obsproject/obs-studio#9961, so a heads-up: it's fixed here in obs-rust by #242, with a regression test.

    Cause: a visible scene item's source is linked as an "active child" of the scene that holds it. Moving an item into or out of a group (group add/remove, drag and drop in the source tree via obs_scene_reorder_items2, and obs_scene_insert_group) changed the item's parent without moving that link, so showing and hiding walked a different tree than the one the source was counted in. Sources then kept playing audio while hidden, or went silent while visible. As Lain-B said when closing the earlier frontend workaround, the fix belonged in libobs: the link now moves with the item. The test checks the exact activate/show counts through every kind of move, and that they return to zero when everything is removed.

    kpaulisse, your steps (hiding and showing a group that holds a nested scene, in Studio Mode, without moving anything) balanced correctly in libobs both before and after the fix, so if you still see it, the state most likely came from an earlier move into or out of that group, which this fix covers.

    Workaround on stock OBS: after moving sources into or out of groups, restart OBS (or switch scene collections and back), which rebuilds the scenes with correct counts.

    obs-rust is an AI-assisted fork of OBS; on Arch it's obs-studio-rust-git in the AUR.

    If you get a chance to try it, a short reply here on whether hidden sources in groups now stay silent would really help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions