Repository navigation
libobs: Apply scene item visibility changes in scenes that are only shown - #358
Merged
Merged
Conversation
…Mode preview In Studio Mode the frontend shows the Preview scene with obs_source_inc_showing(); only the Program is on an output channel. A source that is only in the Preview scene must stop showing when its item is hidden, so "Shutdown source when not visible" (browser source, media source) can fire. The test registers a source that counts its show/hide and activate/deactivate callbacks, with audio (like a browser or media source) and video-only, puts the Program scene on output channel 0 and shows a Preview scene with obs_source_inc_showing(). Each check waits up to 500 ms (15 video ticks). Cases: - hide, show and hide again an item with audio in the Preview scene, then remove it (the steps from the report); - hide and show a group in the Preview scene (groups carry audio); - hide an item in the Program scene and switch the Program to another scene right away, so its scene is left only in the Preview; - controls: the same toggling with a video-only source, removing a visible item with audio from the Preview scene, and hiding and showing an item with audio in the Program scene. On master, under xvfb (both ENABLE_RUST_LIBOBS lanes, with the built OpenGL module and the system one masked), the three cases fail: the hidden source keeps show_refs=1 and never gets its hide callback. The controls pass. Without a display every case skips. Reported upstream in obsproject/obs-studio#4120 by Bobber-bob; confirmed by Fenrirthviti (still present in 32.0.1) and diagnosed by PatTheMav, who traced it to the scene item audio actions. Refs obs-rust#357. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…hown In Studio Mode, hiding a source that was only in the Preview scene never hid it, so "Shutdown source when not visible" never shut down a browser source. Showing or hiding an item whose source has audio (browser and media sources, scenes, groups) is queued as an audio action, so the audio thread can apply it on a sample boundary. The actions are applied in scene_audio_render(), and the audio thread only renders the active tree of the output channels. The frontend shows the Preview scene with obs_source_inc_showing(), so it is showing but not active, and its audio is never rendered. The hide stayed queued, the source kept its show reference and its hide callback never ran. Projectors of a scene and the multiview show scenes the same way, and a scene that left the Program right after a hide kept it queued as well. Apply the pending audio actions of a scene that is not active from its video tick. It mixes no audio, so nothing is lost by applying them at once. Active scenes are unchanged. With the fix, under xvfb (both ENABLE_RUST_LIBOBS lanes, with the built OpenGL module and the system one masked), the hidden source gets its hide callback and drops its show reference within a few ticks in all six cases; the controls are unchanged. Reported upstream in obsproject/obs-studio#4120 by Bobber-bob; confirmed by Fenrirthviti and diagnosed by PatTheMav. Fixes obs-rust#357. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Local-Gate: v1 tree=f2d19479568b293c020406c523999d7939d2c808 secs=154 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791800361,"gate":"rust/all/fmt","host":"linux-x86_64","key":"4f0eb4ebedc92189332681bdd5abf5ecc4a3b96b1019ad791c6ed960aba82383","lane":"lint","parents":["b327cfad2aa8bb3b40803a8bb741ef9480e8c53c"],"secs":56,"stamp":"6a9c8abae19e70beb712833bb0b36071","tree":"f2d19479568b293c020406c523999d7939d2c808","v":1,"via":"run"} Ci-Attestation: {"at":1791800361,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"4f0eb4ebedc92189332681bdd5abf5ecc4a3b96b1019ad791c6ed960aba82383","lane":"lint","parents":["b327cfad2aa8bb3b40803a8bb741ef9480e8c53c"],"secs":56,"stamp":"d5aa3ba353faacd6e13aeebdf2a561de","tree":"f2d19479568b293c020406c523999d7939d2c808","v":1,"via":"run"} Ci-Attestation: {"at":1791800361,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"ecd339ab6f8db57191f221bad4621df4da86360e71b8578cfa23ade39f5b45e0","lane":"rust-test","parents":["b327cfad2aa8bb3b40803a8bb741ef9480e8c53c"],"secs":47,"stamp":"e86924b87149beff1352bac0a00311ca","tree":"f2d19479568b293c020406c523999d7939d2c808","v":1,"via":"run"} Ci-Attestation: {"at":1791800361,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"a56a955930ac926a67c502d73cae842c5b857759f464a52cfb0e85349af1cf35","lane":"tier2-linux","parents":["b327cfad2aa8bb3b40803a8bb741ef9480e8c53c"],"secs":51,"stamp":"c31ddeb692c9d4768286110c85dfea86","tree":"f2d19479568b293c020406c523999d7939d2c808","v":1,"via":"run"}
Member
|
Verified locally under xvfb-run, 3 runs per commit:
Without a display the test skips and reports Passed, so plain Tier 2 / CI doesn't exercise it. Rebased on master, local gate passed; pushed as 452cb14. |
zackees
force-pushed
the
fix/4120-preview-only-hide
branch
from
October 12, 2026 10:19
525b770 to
452cb14
Compare
This was referenced Oct 22, 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
In Studio Mode, hiding a source that is only in the Preview scene now hides it, so "Shutdown source when not visible" fires for browser sources. Before, a source with audio (browser, media, scenes, groups) hidden there stayed "visible" forever.
obs_sceneitem_set_visible()does not hide an item whose source has audio at once. It queues an audio action, so the audio thread can fade the audio on a sample boundary. Those actions are applied inscene_audio_render(), and the audio thread only renders the active tree of the output channels.obs_source_inc_showing(): it is showing but not active. Its audio is never rendered, so the hide stayed queued and the source kept its show reference. Itshidecallback never ran. Projectors of a scene and the multiview show scenes the same way. A scene that leaves the Program right after a hide (switching scenes in Studio Mode) kept the hide queued too.test/cmocka: Add failing test for hiding a source only in the Studio Mode preview:test_preview_only_hideregisters 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 output channel 0 and shows a Preview scene withobs_source_inc_showing(), as the frontend does. Each check waits up to 500 ms (15 video ticks). The cases are:Today the hidden source keeps
show_refs=1and gets nohidecallback. 3 of 6 fail; the controls pass.libobs: Apply scene item visibility changes in scenes that are only shown: applies the queued actions fromscene_video_tick()when the scene is not active. 6 of 6 pass.Motivation and Context
Fixes #357 (upstream obsproject/obs-studio#4120, reported by Bobber-bob with a counter page that shows the problem). Fenrirthviti confirmed it upstream in 2021 and again on 32.0.1 in 2025; PatTheMav found that media sources are affected too and traced it to the scene item audio actions, which this fix follows.
There is no upstream PR for this. The browser-side report, obsproject/obs-browser#412, was closed in favour of the obs-studio issue.
Related merged fixes in this fork touch the same code but not this path: #242 (group active refs) and #325 (group hide transitions) cover scenes on the Program, and #250 (media stale frame) is a media source change. Their tests pass unchanged.
Why this one: "Shutdown source when not visible" is how browser overlays are reset, and Studio Mode is where people prepare the next scene. The issue has been open and confirmed since 2021.
How Has This Been Tested?
Automated, in both libobs lanes (
ENABLE_RUST_LIBOBSOFF and ON), on current master:test_preview_only_hide: 3 of 6 cases fail at the RED commit (every time in 6 runs) and 6 of 6 pass at GREEN, under a private Xvfb with software GL, using the OpenGL module built in the tree with the installed system one masked.ctest -Vshows every case run, none skipped. Repeated 20 times per lane at GREEN: same result every time.ci/test_registration.pyare clean. The test is registered on Linux only and links only libobs (and its caption headers) and cmocka, like the other libobs scene tests.Not tested:
obs_source_inc_showing()for the Preview,obs_sceneitem_set_visible()for the eye icon) and checks thehidecallback that the browser source's shutdown option hooks into.Types of changes
Checklist:
🤖 Generated with Claude Code