Skip to content

requesthandler: Report a missing program or preview scene as null - #17

Merged
zackees merged 1 commit into
obs-rust:masterfrom
rdoupe:fix/current-scene-null
Oct 17, 2026
Merged

zackees merged 1 commit into
obs-rust:masterfrom
rdoupe:fix/current-scene-null

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Refs obs-rust/obs-studio#1254

What and why

GetCurrentProgramScene aborted OBS when there was no program scene. That happens in Studio Mode after the program scene is removed (upstream obsproject/obs-websocket#1349, reported by stevets). The frontend keeps the program scene as a weak reference, so obs_frontend_get_current_scene() returns NULL once the scene is destroyed. The handler put obs_source_get_name(NULL) into a json string, which throws std::logic_error ("basic_string: construction from null is not valid") on the websocket thread, so OBS aborts. On macOS it is a SIGSEGV in strlen.

  • GetCurrentProgramScene now answers Success with sceneName, sceneUuid, currentProgramSceneName and currentProgramSceneUuid all null when there is no program scene. GetSceneList already reports the same state as currentProgramSceneName: null.
  • GetCurrentPreviewScene has the same unchecked shape and gets the same check.
  • Nothing changes while the scene exists. The doc comments say when the fields are null.
  • Port of requesthandler: Fix GtCurrentProgramScene crash obsproject/obs-websocket#1353 by andrewsoncha (program scene, without its whitespace changes; co-author on the commit), extended to the preview scene.

RED → GREEN

The test lives in obs-rust/obs-studio (test/cmocka/test_ws_current_scene_removed.cpp, PR to follow, RED commit 727373b38 against this fork's d79d2c2): 2 of 4 cases fail (both "scene removed" cases throw), and all 4 pass with this commit, with ENABLE_RUST_LIBOBS OFF and ON. In the app (master build, headless), GetCurrentProgramScene after RemoveScene of the Studio Mode program scene goes from SIGABRT to {"sceneName": null, ...}, and SetCurrentProgramScene afterwards works.

AI 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.

🤖 Generated with Claude Code

In studio mode the frontend keeps the program scene as a weak
reference. Once that scene is removed, obs_frontend_get_current_scene()
returns NULL, and GetCurrentProgramScene put the NULL name into a json
string: std::logic_error ("basic_string: construction from null is not
valid") on the websocket thread, and OBS aborted (upstream
obsproject/obs-websocket#1349, reported by stevets).

GetCurrentProgramScene now answers with null names and UUIDs when there
is no program scene, as GetSceneList already does. GetCurrentPreviewScene
gets the same check. Nothing changes while the scene exists.

Port of obsproject/obs-websocket#1353 by andrewsoncha (program scene),
extended to the preview scene.

Refs obs-rust/obs-studio#1254.

Co-Authored-By: andrewsoncha <65234283+andrewsoncha@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zackees
zackees merged commit 0d663ee into obs-rust:master Oct 17, 2026
1 check passed
@zackees

zackees commented Oct 17, 2026

Copy link
Copy Markdown
Member

Merged (rebase); fork master is now 0d663ee. Go ahead with the obs-studio submodule bump plus the protocol test for #1254.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants