Skip to content

bug: libobs: hiding a source that is only in the Studio Mode preview never hides it ("Shutdown source when not visible" never fires) (upstream #4120) #357

Closed

Description

@rdoupe

Upstream OBS bug, reported by Bobber-bob in obsproject/obs-studio#4120 (Windows 10, OBS 26.1.1). In Studio Mode, a browser source with "Shutdown source when not visible" that is only in the Preview scene is not unloaded when it is hidden with the eye icon: showing it again brings back its old state. Fenrirthviti confirmed it in 2021 and again on 32.0.1 in 2025-10; shailander asked for an update in 2023. PatTheMav found that media sources are affected too and traced it to the scene item audio actions (2025-11). The code has not changed in this fork.

Location

  • libobs/obs-scene.c obs_sceneitem_set_visible() (line 3058): hiding an item whose source has audio (browser and media sources, scenes and groups) does not hide it at once. It queues an audio action, so the audio thread can apply it on a sample boundary. Adding such an item works the same way (line 2320).
  • The audio actions are applied by scene_audio_render() (line 1653 when nothing plays, apply_scene_item_volume() otherwise). libobs/obs-audio.c audio_callback() (lines 598-608) only renders the active tree of the output channels.
  • The frontend shows the Studio Mode Preview scene with obs_source_inc_showing(), so that scene is showing but not active. Its scene_audio_render() never runs, the hide action stays queued, and the source keeps its show reference. Its hide callback never fires, and "Shutdown source when not visible" never shuts it down. Hiding and showing again only adds more queued actions.

Class

Wrong behaviour: a source with audio that is hidden in a scene that is only showing keeps running as if it were visible. Removing the item works (it is applied at once).

How it is reached

  • Studio Mode, a browser source with "Shutdown source when not visible" in a scene that is in the Preview and not in the Program. Hide it with the eye icon: the source is never told it is hidden. Media sources and every other source with audio take the same path.
  • The same applies to every other place that only shows a scene: projectors of a scene and the multiview.
  • A scene with a pending hide that leaves the Program right away (hide, then switch scenes in Studio Mode) keeps the hide queued.

Reproduced headlessly against libobs on master: a Program scene on output channel 0 and a Preview scene shown with obs_source_inc_showing(), as the frontend does. A source with audio is hidden in the Preview scene and never gets its hide callback; a video-only source does.

Upstream work

None found: no upstream PR references obsproject/obs-studio#4120 or changes how audio actions are applied. The browser-side report, obsproject/obs-browser#412, was closed in favour of the obs-studio issue.

Proposed fix and failing test

Fix: in scene_video_tick(), apply the pending audio actions of a scene that is not active. The audio thread only mixes the active tree, so such a scene mixes no audio and nothing is lost by applying them at once. Active scenes are unchanged, so the Program still fades audio on a sample boundary.

RED test (cmocka, test_preview_only_hide). It registers a source that counts its show/hide and activate/deactivate callbacks, with audio and video-only, starts core video and audio, puts a Program scene on the output and shows a Preview scene the way the frontend does. Six cases:

  • hide, show and hide again an item with audio in the Preview scene, then remove it;
  • hide and show a group in the Preview scene;
  • hide an item in the Program scene and switch the Program to another scene right away;
  • controls: the same toggling with a video-only source, removing a visible item with audio from the Preview scene, and hiding an item with audio in the Program scene.

The first three fail today and the controls pass.

Activity

  1. rdoupe commented on Oct 12, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: this issue.

    1. RED: test_preview_only_hide (3 of 6 failing): counting sources with and without audio in a scene shown like the Studio Mode preview; hiding an item with audio, or a group, must reach the source's hide callback within a few ticks.
    2. GREEN: apply pending scene item show/hide actions on the video tick for scenes that mix no audio.
      PR today.
  2. added a commit that references this issue on Oct 12, 2026
    452cb14
  3. rdoupe commented on Oct 12, 2026

    @rdoupe
    CollaboratorAuthor

    @Bobber-bob you reported this in obsproject/obs-studio#4120, so a heads-up: it's fixed here in obs-rust by #358, merged today with a regression test.

    Cause: hiding a scene item whose source has audio (browser sources, media sources, groups) isn't applied at once; libobs queues it so the audio thread can fade it on a sample boundary. The audio thread only mixes the scenes that are live on Program, and the Studio Mode preview (like a projector or the multiview) is shown but not mixed, so a hide there stayed queued forever: the source never got its "hidden" event and "Shutdown source when not visible" never fired. That's the cause PatTheMav described in your thread, and Fenrirthviti confirmed it was still present last year. Now a scene that isn't being mixed applies those queued changes on the next video frame; scenes on Program behave exactly as before. The test shows a scene the way Studio Mode's preview does and hides a source with audio in it: before, the source never got hidden; now it does within a frame.

    Not covered: tested with test sources in libobs, not a real browser source or the OBS UI.

    Workaround on stock OBS: remove the source from the preview scene instead of hiding it, or hide it while that scene is on Program.

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

    If you try it, a short reply here on whether your browser source shuts down when hidden in the preview 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