Skip to content

libobs: os_get_free_disk_space can block obs-websocket pool threads on a hung share (fix in Rust OBS, plugin unchanged) #1345

Closed

Description

@vpacher

Part of #1285 (#1273). B, worker pool, can stall.

ObjectHelper::GetStats() calls os_get_free_disk_space() on the recording path for every request (plugins/obs-websocket/src/utils/Obs_ObjectHelper.cpp:40). This is the same call as #1282, but it runs on a pool thread, not the UI thread.

On a hung network share or NAS each call blocks one pool thread. Clients that poll GetStats every second (for example Companion) fill the pool (QThreadPool, default size = ideal thread count). Event broadcasts use the same pool (src/websocketserver/WebSocketServer_Protocol.cpp:362), so all requests and events stop too. Found by reading the code, not reproduced yet.

Fix: read the cached free-space value from #1282 (PR #1336) when it is available, and report null (or the last value with its age) while no fresh value exists. Do not query the disk in the request.

Test: an injected free-space function that blocks; GetStats must return at once, and other requests must still be answered.

Activity

  1. zackees commented on Oct 25, 2026

    @zackees
    Member

    Triage: the fix this issue proposes is inside plugins/obs-websocket, which AGENTS.md freezes: "Preserve the existing C++ OBS WebSocket plugin in plugins/obs-websocket as a compatibility check for Rust OBS. Do not port it to Rust or modify it to accommodate the Rust implementation. ... Fix compatibility failures in Rust OBS." Any fix has to be on the Rust OBS side (libobs / frontend), with the plugin unchanged. Retitling it to say so, and /investigate: what is needed is a Rust OBS-side fix that removes the stall or deadlock without touching the plugin, if one exists; otherwise close it as an upstream limitation.

    /investigate

  2. changed the title [-]obs-websocket: GetStats queries free disk space on every call and can stall the request pool on a hung path[/-] [+]libobs: os_get_free_disk_space can block obs-websocket pool threads on a hung share (fix in Rust OBS, plugin unchanged)[/+] on Oct 25, 2026
  3. added
    needs-investigation
    on Oct 25, 2026
  4. zackees commented on Oct 25, 2026

    @zackees
    Member

    Claiming: investigation

    Findings

    Proposed fix (Rust, obs-util, all three hosts)

    Make os_get_free_disk_space(dir) bounded:

    1. One query per path at a time. A call starts the platform query on a helper thread and waits up to a short deadline, for example 200 ms.
    2. Fresh result arrives in time: return it and cache it for that path.
    3. Deadline passes, or a query for that path is already in flight: return the path's last cached value right away, and start no new thread. The hung query keeps its one helper thread until the OS gives up.
    4. No cached value yet: return 0, which callers already handle as "unknown or nonexistent" (record-disk-space.h).

    For a responsive volume, the result is unchanged. A hung share costs one helper thread per path instead of one pool thread per request, so GetStats answers within the deadline and the pool never fills.

    Decision needed

    • What to return when there is no cached value. 0 matches today's "path does not exist" answer, but an obs-websocket client would briefly see 0 free space on a hung share. The alternatives are UINT64_MAX or the deadline value. My default is 0, because callers already treat it as unknown.
    • The deadline value. My default is 200 ms.

    If those defaults are fine, I'll take it: RED is a Tier 1 test with an injected blocking query (calls return within the deadline, and only one helper thread runs per path), then GREEN.

  5. added a commit that references this issue on Oct 25, 2026
    ce3b801
  6. zackees commented on Oct 25, 2026

    @zackees
    Member

    Fixed by #2341, using the defaults above: a 200 ms deadline, and 0 before the first value. Both are constants in rust/obs-util/src/bounded_free_space.rs if a maintainer wants different ones. Not yet verified against a real hung NAS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

needs-investigation

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions