Repository navigation
frontend: Queue scene changes that scripts make from a timer - #1417
Merged
Merged
Conversation
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 18, 2026
A Lua script that calls obs_frontend_set_current_scene() from a timer and also has a frontend event callback hangs OBS (obsproject/obs-studio#3385, reported by woganmay). Script timers run on libobs's graphics thread holding the scripting callback lock. The call waits for the UI thread, and the UI thread, sending the scene change to the script's event callback, waits for that lock. The new phase (run_tier4.py --only scripts, also part of the full run) starts OBS with scenes A and B and such a script, which switches to B from a 2 s timer. It checks that the call returns, that B is on program and that the UI thread still answers SetCurrentProgramScene. On v0.1.0-beta.20261018 and master 065fa7d 2 of 4 checks fail: the call never returns and SetCurrentProgramScene times out. Refs obs-rust#1416
obs_frontend_set_current_scene() ran the scene change on the UI thread and waited for it. Script timers run on libobs's graphics thread with the scripting callback lock held (the GIL for Python), and the scene change sends frontend events to the scripts' event callbacks on the UI thread, which take that lock. A script that switched scenes from a timer and also had an event callback deadlocked OBS (obsproject/obs-studio#3385). Called on libobs's graphics, audio or destroy thread, the scene change is now queued and the call returns, as the profile calls already do through RunFrontendApiCall() (obs-rust#805). Called from any other thread (obs-websocket, plugins' own threads) it still waits until the scene has changed. The Studio Mode path (TransitionToScene) does the same. The Tier 4 scripts phase passes 4 of 4. Fixes obs-rust#1416
rdoupe
force-pushed
the
fix/lua-timer-scene-switch
branch
from
October 18, 2026 16:12
6677717 to
af0db1a
Compare
zackees
enabled auto-merge
October 18, 2026 16:13
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.
Fixes #1416
What and why
A Lua or Python script that switches scenes from a timer no longer hangs OBS when it also has a frontend event callback (upstream obsproject/obs-studio#3385, reported by woganmay in 2020, confirmed by RytoEX; PatTheMav traced the deadlock).
obs_frontend_set_current_scene()(frontend/OBSStudioAPI.cpp.hpp) ran the scene change on the UI thread withWaitConnection()and waited for it.RunFrontendApiCall()(frontend: Wait for profile changes made through the frontend API #805). The graphics thread must not wait for the UI thread anyway, because the UI thread waits for it. Called from any other thread (obs-websocket's pool, a plugin's own thread) it still waits until the scene has changed, soSetCurrentProgramScenefollowed byGetCurrentProgramScenebehaves as before. The Studio Mode path (TransitionToScene) does the same.obs_frontend_set_current_scene()gets control back before the scene has changed. The change happens right after, on the UI thread. Before, the call never returned.InLibobsThread()moves above its new first user, and its comment now says why these threads must not wait.RED → GREEN
test: Add failing Tier 4 phase for a Lua timer that switches scenes.run_tier4.py --only scripts(also part of the full run, before the GPU phase) starts OBS with scenes A and B and a Lua script that adds an event callback and, from a 2 s timer, callsobs_frontend_set_current_scene(B). On v0.1.0-beta.20261018 and on master 065fa7d (C lane, built with Lua) 2 of 4 checks fail.obs_frontend_set_current_scene from a Lua timer returns: the script logs "switching to B" and never gets past the call.UI thread still answers after the switch:SetCurrentProgramScenetimes out, OBS hangs. B does reach program before the UI thread blocks. The phase fails, not skips, when the script never runs (a build without Lua): CI's Ubuntu build installs swig and LuaJIT.Checklist
masterdocs/features.mdis added (Fixed upstream bugs, Scripting)-W..., ratchets): noneAI note: Claude Code (Claude Opus 5.5) wrote the code, the test, the commit messages and this text under the submitter's direction, and ran the tests above on the submitter's machines.