Skip to content

bug: obs-websocket: RemoveScene removes the last scene and the next GetCurrentProgramScene aborts OBS (upstream obsproject/obs-studio#10532, #10533) #519

Closed
obs-rust/obs-websocket
#5

Description

@rdoupe

Upstream OBS bug, reported by timmaclean in obsproject/obs-studio#10532 (OBS 30.1.2: removing every scene over obs-websocket, then GetCurrentProgramScene, crashes OBS) and obsproject/obs-studio#10533 (same, with CreateScene of the removed scene's name). Glitched reported the same on macOS in obsproject/obs-studio#10533. tt2468 suggested on obsproject/obs-studio#10532 that the "at least one scene" check was failing. Both issues are still open upstream, and the bug is in this fork too.

Location

  • plugins/obs-websocket/src/utils/Obs_NumberHelper.cpp GetCanvasSceneCount() (line 44) counts scenes into size_t ret;, which is never initialized. The result is whatever the stack held plus the number of scenes.
  • plugins/obs-websocket/src/requesthandler/RequestHandler_Scenes.cpp RemoveScene (line 307) refuses to remove the last scene of the main canvas only when that count is below 2. With a garbage count the check passes, and the last scene is removed.
  • With no scene left, GetCurrentProgramScene (line 131) puts the name of a null scene into the response. That throws std::logic_error and aborts OBS.

Class

Crash (SIGABRT) from an unchecked request. The check meant to prevent it reads an uninitialized variable.

How it is reached

Any obs-websocket client that removes scenes: GetSceneList, then RemoveScene for each scene, then GetCurrentProgramScene (obsproject/obs-studio#10532). Or with a new scene made current first, then the same, then CreateScene (obsproject/obs-studio#10533). Stream Deck plugins, bots and scripts that rebuild a scene collection all do this.

Reproduced in the current release

AppImage 33.0.0-beta6-799 (Rust libobs), driven headless over obs-websocket (private Xvfb, private config, password set):

Steps Result
obsproject/obs-studio#10532: one scene "Scene"; RemoveScene "Scene" succeeds ({}), log "User Removed scene 'Scene'"; GetSceneList returns no scenes
then GetCurrentProgramScene OBS aborts: terminate called after throwing an instance of 'std::logic_error' (3 of 3 runs)
obsproject/obs-studio#10533: CreateScene TestScene, make it current, remove both scenes both removals succeed, no scenes left
then CreateScene TestScene, GetCurrentProgramScene CreateScene succeeds, then OBS aborts the same way

The expected result is that removing the last scene fails with "You cannot remove the last scene in the collection." (status 603, NotEnoughResources), as the request handler intends.

Proposed fix and failing test

Fix (in the obs-rust/obs-websocket fork, then a submodule update here, as for #99): start the counter at zero (size_t ret = 0;).

RED test (cmocka, test_ws_scene_count). It builds the plugin's own Obs_NumberHelper.cpp against stubbed libobs calls with a fake main canvas (no libobs startup, no display). It is compiled with -ftrivial-auto-var-init=pattern where the compiler supports it, so the uninitialized counter fails on every run:

  • no scenes: 0;
  • one scene: 1 (the case RemoveScene must refuse);
  • two scenes: 2;
  • groups are not counted;
  • GetCanvasSceneCount() on the main canvas: 3 with three scenes and a group.

All 5 fail today in both libobs lanes, the same way every run.

Activity

  1. rdoupe commented on Oct 13, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: this issue.

    1. RED: test_ws_scene_count (5 cases) builds obs-websocket's scene counter against a fake canvas: with one scene it does not answer 1, because the counter starts uninitialized, so RemoveScene removes the last scene. 5 of 5 fail today.
    2. GREEN: the counter starts at zero (obs-rust/obs-websocket fork), and the submodule here moves to it.
      PR today.
  2. added
    claimed
    on Oct 13, 2026
  3. zackees commented on Oct 13, 2026

    @zackees
    Member

    Claiming.

  4. zackees commented on Oct 13, 2026

    @zackees
    Member

    Releasing my claim: @rdoupe claimed this first (fork PR obs-rust/obs-websocket#5 is open with the fix, and the comment above says test_ws_scene_count is ready). Leaving the claimed label for that work. Do not open a parallel PR.

  5. rdoupe commented on Oct 14, 2026

    @rdoupe
    CollaboratorAuthor

    @timmaclean you reported this in obsproject/obs-studio#10532 and #10533 (removing every scene over obs-websocket, then GetCurrentProgramScene or CreateScene, crashes OBS), so a heads-up: it's fixed here in obs-rust (obs-rust/obs-websocket#5, moved into OBS with the obs-websocket update in this release).

    Cause: the scene counter behind RemoveScene's "at least one scene" check started uninitialized, so with one scene left it did not answer 1 and RemoveScene removed the last scene. The counter now starts at zero, so removing the last scene is refused.

    It's in obs-rust v0.1.0-beta.20261014: https://github.com/obs-rust/obs-studio/releases (Windows, macOS and Linux builds; on Arch it's obs-studio-rust-git in the AUR). obs-rust is an AI-assisted fork of OBS.

    If you get a chance to try it, a reply here on whether RemoveScene now refuses the last scene for you 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

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions