Repository navigation
Description
Upstream obs-websocket bug, reported by wesbos in obsproject/obs-websocket#1317 (September 2025, still open, no reply): a RequestBatch with executionType: 2 (Parallel) returns results whose requestType and requestId belong to other requests, so a client that matches results by requestId (as the protocol documents) reads the wrong data. The reporter saw it with GetSourceScreenshot and GetSourceFilterList. Still present in this fork (submodule at obs-rust/obs-websocket 547f5ea).
Location
plugins/obs-websocket/src/requesthandler/RequestBatchHandler.cppProcessRequestBatch(), Parallel branch (lines 205-229): each request runs as its own thread-pool task, and each task doesparallelResults.results.push_back(requestResult)(line 217) when it finishes. The batch waits until the vector holds one result per request and returns it, so the results are in completion order.src/websocketserver/WebSocketServer_Protocol.cpplines 336-339 then build the response withConstructRequestResult(resultsVector[i], requests[i]): resultigets therequestTypeandrequestIdof requesti.- The two serial modes (SerialRealtime, SerialFrame) append in request order, so they are right. Only Parallel is affected.
Class
Wrong output from a documented request (results attached to the wrong request). No crash.
How it is reached
Any Parallel batch whose requests do not finish in the order they were sent, for example a full-size GetSourceScreenshot followed by quick requests:
{"op": 8, "d": {"requestId": "b", "executionType": 2, "requests": [
{"requestType": "GetSourceScreenshot", "requestId": "shot", "requestData": {"sourceName": "Scene", "imageFormat": "png", "imageWidth": 1920, "imageHeight": 1080}},
{"requestType": "GetVersion", "requestId": "ver"},
{"requestType": "GetSceneList", "requestId": "scenes"},
{"requestType": "GetStats", "requestId": "stats"},
{"requestType": "GetInputList", "requestId": "inputs"}]}}The result labelled shot/GetSourceScreenshot holds another request's data (for example the scene list), and the PNG comes back under a quick request's label (for example inputs/GetInputList).
Reproduced in the current release
v0.1.0-beta.20261014 AppImage, headless (private Xvfb, private HOME, dbus-run-session, --multi), 1920x1080 canvas with one colour source, the batch above sent 20 times per mode:
| Build | SerialRealtime (0) | Parallel (2) |
|---|---|---|
| v0.1.0-beta.20261014 | 0 of 20 batches mislabelled | 20 of 20 batches mislabelled |
| Stock OBS 32.2.2 (Arch) | 10 of 10 batches mislabelled |
Proposed fix and failing test
Fix (in the obs-rust/obs-websocket fork, then a submodule bump here): give the results vector one slot per request up front and have each task write its result at its request's index; the batch waits for a finished count instead of the vector's size. Parallel results then come back in request order, as serial batches already do. Nothing that works today changes: a Parallel batch is wrong today whenever its requests finish out of order, and serial batches are untouched.
RED test (cmocka, test_ws_batch_order): builds the plugin's RequestBatchHandler.cpp with RequestHandler stubbed (each request sleeps for a given delay and answers with its own requestType and a tag), runs batches on a real QThreadPool and checks that results[i] belongs to requests[i]. A slow request first, eight requests finishing in reverse order, and a failed request in the middle all fail today; an empty Parallel batch and a SerialRealtime batch pass. Qt Core and nlohmann_json only, no libobs startup, no display.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Oct 15, 2026
Claiming: this issue.
test_ws_batch_orderbuilds obs-websocket'sRequestBatchHandler.cppwith the request handler stubbed and runs Parallel batches whose requests finish out of order: today the results come back in completion order, so 3 of 5 cases fail.Fork PR today; the obs-studio PR follows once it merges.
rdoupe commentedon Oct 15, 2026
Fork PR is up: obs-rust/obs-websocket#13 (f418629, Parallel batch results in request order). The obs-studio PR with the regression test and the submodule bump follows once it merges.
rdoupe commentedon Oct 16, 2026
Status: the obs-websocket half, obs-rust/obs-websocket#13, has passed CI and is waiting for review. It has been open since this morning. The obs-studio PR, with the RED test and the submodule bump, goes up as soon as it merges.
zackees commentedon Oct 16, 2026
obs-rust/obs-websocket#13 is reviewed and merged as 2542c6a. @rdoupe the obs-studio PR (test_ws_batch_order RED, then the plugins/obs-websocket bump to 2542c6a or later on obs-websocket master) can go up now.
obs-websocket: Keep Parallel batch results in request order (obs-rust…
rdoupe commentedon Oct 16, 2026
@wesbos you reported this in obsproject/obs-websocket#1317: in a Parallel
RequestBatch, results come back labelled with the wrongrequestType/requestId. Heads-up that it's fixed here in obs-rust. The fix is in obs-rust/obs-websocket#13, and #1074 moved obs-rust to it. Both merged today with a regression test.Cause: a Parallel batch runs each request as its own thread-pool task, and each task appended its result when it finished. The results array came back in completion order, but obs-websocket labels
results[i]withrequests[i]'s type and id. So a slow request first (like your full-sizeGetSourceScreenshot) shifted every label. Now each task writes its result at its own request's index, so results come back in request order, as serial batches already do. In our release, a batch of a screenshot plus four quick requests came back mislabelled 20 of 20 times, and stock OBS 32.2.2 did the same 10 of 10 times. With the fix it was 0 of 20.Workaround on stock OBS: use
executionType0 (SerialRealtime), which came back correctly labelled 20 of 20 times in our release.It will be in the next obs-rust daily release after 0.1.0-beta.20261014: https://github.com/obs-rust/obs-studio/releases (Windows, macOS and Linux builds; on Arch it's
obs-studio-rust-gitin the AUR). obs-rust is an AI-assisted fork of OBS.If you get a chance to try it, a reply here on whether your Parallel batches match up now would really help.