Repository navigation
obs-websocket: Keep Parallel batch results in request order - #1074
Merged
Merged
Conversation
obs-websocket answers a RequestBatch with one result per request, and the protocol layer labels results[i] with the requestType and requestId of requests[i]. With executionType Parallel, each request runs as its own thread-pool task and RequestBatchHandler appends its result when it finishes, so the results come back in completion order. A batch with a slow request first (a full-size GetSourceScreenshot) and fast ones after it returns every result under another request's requestType and requestId: the screenshot is labelled GetInputList, and so on (upstream obsproject/obs-websocket#1317). Clients that match results by requestId, as the protocol documents, get the wrong data. Serial batches are in request order. test_ws_batch_order builds the plugin's RequestBatchHandler.cpp with RequestHandler stubbed: each request sleeps for its delay and answers with its own requestType and tag. Three Parallel cases fail (a slow request first, eight requests finishing in reverse order, a failed request in the middle); an empty Parallel batch and a SerialRealtime batch pass. Qt Core and nlohmann_json only, no libobs startup, no display. Refs obs-rust#813. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moves the submodule to the fork fix "requesthandler: Keep Parallel batch results in request order". RequestBatchHandler appended each Parallel request's result when its thread-pool task finished, so the protocol layer, which labels results[i] with requests[i]'s requestType and requestId, attached most results to the wrong request (upstream obsproject/obs-websocket#1317). Each task now writes its result at its request's index, so Parallel results come back in request order, as serial batches already do. test_ws_batch_order passes 5 of 5. Fixes obs-rust#813. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zackees
enabled auto-merge
October 16, 2026 10:39
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 #813
What and why
obs-websocket now returns a Parallel request batch's results in request order, so each result carries its own request's
requestTypeandrequestId. Clients that match results byrequestId, as the protocol documents, get the right data again.executionType: 2(Parallel) runs each request as its own thread-pool task. Inplugins/obs-websocket/src/requesthandler/RequestBatchHandler.cppeach task didresults.push_back(requestResult)(line 217) when it finished, so the vector came back in completion order.WebSocketServer_Protocol.cpp(lines 336-339) then labelsresults[i]withrequests[i]'srequestTypeandrequestId. With a slow request first (a full-sizeGetSourceScreenshot) and quick ones after it, every result went out under another request's label.requesthandler: Keep Parallel batch results in request order), gives the results vector one slot per request, has each task write its result at its request's index, and waits for a finished count instead of the vector's size. This PR moves the submodule to it.GetSourceScreenshotandGetSourceFilterList.Reproduced in release v0.1.0-beta.20261014 (AppImage, headless: private Xvfb, private HOME,
dbus-run-session,--multi), 1920x1080 canvas with one colour source, sending a batch of a full-size PNGGetSourceScreenshot,GetVersion,GetSceneList,GetStatsandGetInputList20 times per mode:RED → GREEN
test/cmocka: Add failing test for Parallel request batch result order, with the submodule at master's pin f9e2a95 (the fork before the fix).test_ws_batch_orderbuilds the plugin'sRequestBatchHandler.cpp(plus itsRequest,RequestBatchRequest,RequestResultandCompatsources) withRequestHandlerstubbed: each request sleeps for a given delay and answers with its own requestType and a tag. Batches run on a realQThreadPool. 3 of 5 fail in both lanes:test_parallel_slow_first(the upstream batch shape: the screenshot's slot holds a quick request's result, e.g."GetStats" != "GetSourceScreenshot"),test_parallel_reverse_finish(eight requests finishing in reverse order) andtest_parallel_failure_keeps_slot(a failed request in the middle keeps its slot).test_parallel_emptyand the controltest_serial_realtime_orderpass. Qt Core and nlohmann_json only, no libobs startup, no display; built where both are found, not on Windows (like the othertest_ws_*tests).plugins/obs-websocketfrom f9e2a95 to 2542c6a9f (the merge of requesthandler: Keep Parallel batch results in request order obs-websocket#13; forward only). 5 of 5 withENABLE_RUST_LIBOBSOFF and ON, also withDISPLAYunset; with the fix the result order no longer depends on timing. Full OBS build (frontend + obs-websocket) in both lanes. Full ctest -j8 (private Xvfb, systemlibobs-openglmasked, TMPDIR unset), rebased on master 673f76f: 261/262 in each lane. The one failure in both lanes istest_text_freetype2_bundled_font(from text-freetype2: Default to the bundled JetBrainsMono Nerd Font #1016, not touched here): on a machine with JetBrainsMono Nerd Font installed, fontconfig picks the system copy over the bundled file. clang-format, gersemi andci/test_registration.pyclean.Checklist
master-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.
🤖 Generated with Claude Code