Skip to content

bug: obs-websocket: a Parallel request batch returns each result under another request's requestType and requestId (upstream obs-websocket#1317) #813

Closed

Description

@rdoupe

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.cpp ProcessRequestBatch(), Parallel branch (lines 205-229): each request runs as its own thread-pool task, and each task does parallelResults.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.cpp lines 336-339 then build the response with ConstructRequestResult(resultsVector[i], requests[i]): result i gets the requestType and requestId of request i.
  • 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.

Activity

  1. rdoupe commented on Oct 15, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: this issue.

    1. RED: test_ws_batch_order builds obs-websocket's RequestBatchHandler.cpp with 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.
    2. GREEN: in the obs-rust/obs-websocket fork, each Parallel task writes its result at its request's index; the submodule here moves to that fix.
      Fork PR today; the obs-studio PR follows once it merges.
  2. added
    claimed
    on Oct 15, 2026
  3. rdoupe commented on Oct 15, 2026

    @rdoupe
    CollaboratorAuthor

    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.

  4. rdoupe commented on Oct 16, 2026

    @rdoupe
    CollaboratorAuthor

    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.

  5. zackees commented on Oct 16, 2026

    @zackees
    Member

    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.

  6. rdoupe commented on Oct 16, 2026

    @rdoupe
    CollaboratorAuthor

    @wesbos you reported this in obsproject/obs-websocket#1317: in a Parallel RequestBatch, results come back labelled with the wrong requestType/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] with requests[i]'s type and id. So a slow request first (like your full-size GetSourceScreenshot) 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 executionType 0 (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-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 your Parallel batches match up now 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