You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
libobs: os_get_free_disk_space can block obs-websocket pool threads on a hung share (fix in Rust OBS, plugin unchanged) #1345
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.
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.
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
The function is already ours.os_get_free_disk_space is exported from Rust (rust/obs-util/src/ffi/platform_{nix,cocoa,windows}.rs, listed in rust-exports.d), so a fix on the Rust OBS side doesn't touch the plugin.
obs-websocket's GetStats, which calls it once per request on a QThreadPool thread.
The stall is the unbounded statvfs / GetDiskFreeSpaceEx. Each GetStats against a hung share parks one pool thread. Once the pool is full, every request and event stops.
Proposed fix (Rust, obs-util, all three hosts)
Make os_get_free_disk_space(dir) bounded:
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.
Fresh result arrives in time: return it and cache it for that path.
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.
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.
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.
Activity
zackees commentedon Oct 25, 2026
Triage: the fix this issue proposes is inside
plugins/obs-websocket, which AGENTS.md freezes: "Preserve the existing C++ OBS WebSocket plugin inplugins/obs-websocketas 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
[-]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)[/+]zackees commentedon Oct 25, 2026
Claiming: investigation
Findings
os_get_free_disk_spaceis exported from Rust (rust/obs-util/src/ffi/platform_{nix,cocoa,windows}.rs, listed inrust-exports.d), so a fix on the Rust OBS side doesn't touch the plugin.disk-space-monitor) and also uses the function for the record-start check.GetStats, which calls it once per request on aQThreadPoolthread.statvfs/GetDiskFreeSpaceEx. EachGetStatsagainst a hung share parks one pool thread. Once the pool is full, every request and event stops.Proposed fix (Rust, obs-util, all three hosts)
Make
os_get_free_disk_space(dir)bounded: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
GetStatsanswers within the deadline and the pool never fills.Decision needed
UINT64_MAXor the deadline value. My default is 0, because callers already treat it as unknown.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.
obs-util: Bound os_get_free_disk_space with a per-path deadline (GREEN)
obs-util: Bound os_get_free_disk_space so a hung share can't stall ob…
zackees commentedon Oct 25, 2026
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.rsif a maintainer wants different ones. Not yet verified against a real hung NAS.