Skip to content

requesthandler: Save the collection after changes - #12

Merged
zackees merged 1 commit into
obs-rust:masterfrom
vpacher:fix/save-scene-collection
Oct 16, 2026
Merged

zackees merged 1 commit into
obs-rust:masterfrom
vpacher:fix/save-scene-collection

Conversation

@vpacher

@vpacher vpacher commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Description

After a request that changes the scene collection succeeds, RequestHandler::ProcessRequest() now queues obs_frontend_save() for the UI thread (obs_queue_task(OBS_TASK_UI, ..., false)). The list of requests is in the new src/requesthandler/SceneCollectionChanges.h: the requests that change scenes, inputs, filters, scene items or transitions, plus SetSourcePrivateSettings.

  • Scene switches (SetCurrentProgramScene, SetCurrentPreviewScene, TriggerStudioModeTransition) are not in the list. The UI does not save on a scene switch either.
  • Profile, config and output requests are not in the list. They store their data through their own code.
  • The task does not wait. OBSBasic::SaveProject() defers the write, so a burst of requests results in one save.

Motivation and Context

Fixes obs-rust/obs-studio#811. SetInputVolume, SetInputSettings, SetSceneItemTransform and similar requests changed only the live state. The change was on disk only after the next save, so a crash or a hard stop lost it. A change in the OBS UI saves at once. Upstream obsproject/obs-websocket master has the same code.

How Has This Been Tested?

Tested OS(s): Debian 13 (headless Xorg, OBS started by a systemd unit).

  • test_ws_save_changes in obs-rust/obs-studio (draft PR, RED commit a8dcfd4): sends requests through ProcessRequest against real libobs and counts the queued UI tasks. RED: a successful SetInputVolume queues 0 tasks (1 expected); GREEN with this commit: 3 of 3 pass.
  • End to end with the full app: the scene collection JSON has the new value 2 s after SetInputVolume, while OBS keeps running, and the value survives kill -9 and a restart.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have read the Contributing Guidelines.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • My code is not on master or a release/* branch.
  • The code has been tested.
  • I have included updates to all appropriate documentation: none needed (no protocol change).

🤖 Generated with Claude Code

Requests that change scenes, inputs, filters, scene items or
transitions (SetInputVolume, SetInputSettings, SetSceneItemTransform,
...) changed only the live state. The change was on disk only after the
next save, so a crash or a hard stop lost it. A change in the OBS UI
saves at once.

After a request from an explicit list succeeds, ProcessRequest now
queues obs_frontend_save() for the UI thread without waiting.
OBSBasic::SaveProject() defers the write, so a burst of requests results
in one save. Scene switches are not in the list: the UI does not save on
a scene switch either.

Fixes obs-rust/obs-studio#811

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vpacher
vpacher force-pushed the fix/save-scene-collection branch from 82cf737 to fe628a3 Compare October 16, 2026 11:09

@zackees zackees left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed. One commit on top of master 2542c6a (ahead 1, behind 0, includes #13). Hook sits after a successful handler in ProcessRequest, so batches get it too. Scene switches excluded as described. obs_frontend_save is already available via RequestHandler.h. Behaviour is covered by test_ws_save_changes in obs-rust/obs-studio#812 (RED a8dcfd4). Code Quality is only waiting for first-contribution approval; master has no protection, merging.

@zackees
zackees merged commit f06b040 into obs-rust:master Oct 16, 2026
vpacher added a commit to vpacher/obs-studio that referenced this pull request Oct 16, 2026
Move plugins/obs-websocket to f06b040 (obs-rust/obs-websocket#12):
after a successful request that changes the scene collection
(SetInputVolume, SetInputSettings, SetSceneItemTransform, ...), the
request handler queues obs_frontend_save() for the UI thread without
waiting. Before, these changes stayed in memory until a clean exit, and
a crash or a hard stop lost them. Scene switches are not saved, as in
the UI.

GREEN for obs-rust#811 (RED f8974ca: a successful SetInputVolume queued 0 UI
tasks). With the same fix commit (82cf737, identical to the merged
change) test_ws_save_changes passed 3 of 3 locally on Debian 13; the
PR CI runs it on this commit.

Fixes obs-rust#811.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vpacher added a commit to vpacher/obs-studio that referenced this pull request Oct 16, 2026
* test/cmocka: Test that websocket changes are saved

test_ws_save_changes compiles the plugin request handlers from the
submodule against real libobs and the frontend API library. It sends
requests through RequestHandler::ProcessRequest and counts the tasks
queued for the UI thread, where the save runs.

RED for obs-rust#811: a successful SetInputVolume queues 0 tasks; 1 (the save)
is expected. GetInputVolume and a failed SetInputVolume queue none and
pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* obs-websocket: Save the collection after changes

Move plugins/obs-websocket to f06b040 (obs-rust/obs-websocket#12):
after a successful request that changes the scene collection
(SetInputVolume, SetInputSettings, SetSceneItemTransform, ...), the
request handler queues obs_frontend_save() for the UI thread without
waiting. Before, these changes stayed in memory until a clean exit, and
a crash or a hard stop lost them. Scene switches are not saved, as in
the UI.

GREEN for obs-rust#811 (RED f8974ca: a successful SetInputVolume queued 0 UI
tasks). With the same fix commit (82cf737, identical to the merged
change) test_ws_save_changes passed 3 of 3 locally on Debian 13; the
PR CI runs it on this commit.

Fixes obs-rust#811.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@vpacher
vpacher deleted the fix/save-scene-collection branch October 17, 2026 06:34
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.

bug: obs-websocket: requests that change the scene collection do not save it, so a crash or hard stop loses them

2 participants