Skip to content

obs-websocket: Save the scene collection after changes - #812

Merged
zackees merged 2 commits into
obs-rust:masterfrom
vpacher:fix/ws-save-changes
Oct 16, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
vpacher:fix/ws-save-changes

Conversation

@vpacher

@vpacher vpacher commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #811

What and why

obs-websocket requests that change the scene collection (SetInputVolume, SetInputSettings, SetSceneItemTransform, ...) did not save it. A crash or a hard stop lost every websocket change since the last save. A change in the OBS UI saves at once.

The fix is in the fork: obs-rust/obs-websocket#12. This PR adds the test and, once #12 has merged, moves the submodule pointer. Draft until then.

RED → GREEN

  • RED commit: a8dcfd4. test_ws_save_changes compiles the plugin's request handlers (RequestHandler.cpp, RequestHandler_*.cpp, rpc, utils) from the submodule against real libobs and the frontend API library. It registers a dummy input, sets a counting UI task handler and sends requests through RequestHandler::ProcessRequest (runs under xvfb-run; skips without a display). 1 of 3 fails: a successful SetInputVolume queues 0 UI tasks, 1 (the save) expected. Guards pass: GetInputVolume and a failed SetInputVolume queue none.
  • GREEN: follows after requesthandler: Save the collection after changes obs-websocket#12 merges (submodule moved to the merge commit). With the fix commit locally: 3 of 3 pass.

Seam: the plugin's globals from obs-websocket.cpp (config, event handler, server, vendor API) and obs_current_module() are stubbed in the test; the requests it sends do not call them. Without a frontend, obs_frontend_save() does nothing, so the test counts the queued UI task instead.

Checklist

  • Base is master (or the description starts with a Stacked: note)
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): none
  • Intentional differences from C listed in the parity test header and rust/README.md (ports): not a port

Notes:

  • clang-format 22.1.3 and gersemi 0.25.0 were run on the changed files. The full ./lint and the local gate were not run.

🤖 Generated with Claude Code

@zackees

zackees commented Oct 16, 2026

Copy link
Copy Markdown
Member

@vpacher @rdoupe: how the pieces fit. #812 (save the scene collection, issue #811) and #813 (Parallel batch results out of order) are two separate bugs in obs-websocket, not duplicates. They touch different code (#812 the request handlers that change state, #813 RequestBatchHandler.cpp), so neither supersedes the other and they should stay separate PRs.

#812 is waiting on its fork half, obs-rust/obs-websocket#12, which is still open and has not merged. Next step for #812: get #12 reviewed and merged, then move the plugins/obs-websocket pointer here to that merge commit (forward only, onto a commit that is on obs-websocket master) and mark this PR ready for the GREEN run. Note that obs-websocket master has moved: #13 merged just now (2542c6a), so please rebase #12 and check the pointer is based on current master before bumping.

For rdoupe's #813: obs-rust/obs-websocket#13 is merged as 2542c6a. The obs-studio PR with the RED test and the submodule bump to 2542c6a can go up now. If both land, the second one to merge will need to take the pointer from current master and keep the other's commit in its history. No change to this PR's content is needed from the #13 merge.

@vpacher

vpacher commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

@zackees thanks for sorting out #812 vs #813. Done: obs-rust/obs-websocket#12 is rebased onto current master (2542c6a, #13). No conflicts, and the commit itself is unchanged (git range-diff: identical, only the base moved). #13 only changes how Parallel batch results are stored, and batches still go through ProcessRequest, so the save hook behaves the same there.

The Code Quality run on #12 is still waiting for workflow approval (first contribution to obs-websocket). Once #12 has merged, I'll move the plugins/obs-websocket pointer here to the merge commit (forward only) and mark this PR ready for the GREEN run.

@zackees

zackees commented Oct 16, 2026

Copy link
Copy Markdown
Member

@vpacher obs-rust/obs-websocket#12 is reviewed and squash-merged. obs-websocket master is now f06b0403995158485582b993dde2545398e386bd. It contains #12 and #13 (compare 2542c6a...f06b040: ahead 1, behind 0), and 2542c6a is what obs-studio master points at today.

What to do on this PR:

  1. Rebase onto current obs-studio master.
  2. Set plugins/obs-websocket to f06b0403995158485582b993dde2545398e386bd (full SHA, no other pointer). Check the staged diff shows only that one submodule line plus your test files.
  3. Push it as a GREEN commit after the RED commit a8dcfd4. The PR has no pointer change yet, so it is still RED as it stands.
  4. Mark it ready once that commit is up. Add the ci-full label, since a plugin submodule move needs the full OBS builds green before merge.

The RED part is in place (a8dcfd4, test_ws_save_changes). Merging waits for the GREEN commit and a full green CI Gate. I am not merging it while it is a draft.

vpacher and others added 2 commits October 16, 2026 15:11
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>
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
vpacher force-pushed the fix/ws-save-changes branch from a8dcfd4 to c9663a7 Compare October 16, 2026 13:13
@vpacher
vpacher marked this pull request as ready for review October 16, 2026 13:15
@vpacher
vpacher requested a review from zackees as a code owner October 16, 2026 13:15
@vpacher

vpacher commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

@zackees done, following your steps:

  1. Rebased onto current master (0e8ec1a).
  2. plugins/obs-websocket set to f06b0403995158485582b993dde2545398e386bd. The GREEN commit changes only that one submodule line; the test files are in the RED commit.
  3. RED f8974ca (test only), GREEN c9663a7 (pointer move).

Verified locally on this exact branch (Debian 13, Qt 6.8.2, ENABLE_RUST_LIBOBS=ON, under xvfb-run, cmocka output read directly so a display skip cannot pass silently):

  • RED f8974ca (pointer 2542c6a): 1 of 3 fail, set_input_volume_queues_save: "SetInputVolume queued 0 UI tasks, expected 1 (the save)".
  • GREEN c9663a7 (pointer f06b040): 3 of 3 pass.

Marking it ready now. I can't add labels, so could you please add ci-full for the full OBS builds?

@zackees zackees added the ci-full Run every CI job on this PR, including the release-gating OBS app builds and Flatpak label Oct 16, 2026
@zackees
zackees enabled auto-merge October 16, 2026 13:16
@zackees
zackees added this pull request to the merge queue Oct 16, 2026
Merged via the queue into obs-rust:master with commit 2f39af9 Oct 16, 2026
27 checks passed
@vpacher
vpacher deleted the fix/ws-save-changes branch October 16, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-full Run every CI job on this PR, including the release-gating OBS app builds and Flatpak

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