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
audit gap: obs-websocket GetStats/threads and remaining capture plugins not yet read for polling #1285
plugins/obs-websocket (submodule empty in the audit checkout): GetStats and its stats and event threads. Check how often they sample CPU, memory, disk and render stats, which thread they run on, and whether many clients or high event subscription rates multiply the work.
linux-pipewire, linux-capture, mac-capture, vlc-video, decklink and text-freetype2 were only grepped for loop patterns (nothing found apart from os_event_try exits in mac-window-capture and the ffmpeg muxers), not read in depth.
To do: read them with the same criteria as #1273 (busy-spin / ~0 interval, UI-thread work, error-path spins) and file sub-issues for anything found.
Claiming the obs-websocket part only (GetStats, the stats and event threads, and how many clients or high event subscription rates multiply the work). The capture plugins in this issue stay open for someone else. Plan: read the code with the #1273 criteria (busy-spin or ~0 interval, UI-thread work, error-path spins), post the findings here, and open a sub-issue for each real finding.
Findings for the obs-websocket part (submodule at 0d663ee). I read it with the #1273 criteria. There is no busy-spin and no ~0 interval. I found three problems: one UI-thread deadlock, one pool stall on a hung disk path, and one data race in GetStats. I did not reproduce them, the evidence is from reading the code.
1. Server Stop() on the UI thread can deadlock (UI stall). WebSocketServer::Stop() calls _threadPool.waitForDone() and then waits in a 10 ms sleep loop until _sessions is empty (WebSocketServer.cpp:202-206). It runs on the UI thread when the settings dialog restarts the server (SettingsDialog.cpp:218) and at module unload (obs-websocket.cpp:141). Three requests wait on the UI thread from a pool thread with obs_queue_task(OBS_TASK_UI, ..., true): SetStudioModeEnabled (RequestHandler_Ui.cpp:70), SetCurrentSceneCollection and SetCurrentProfile (RequestHandler_Config.cpp:167, 259). The frontend runs those tasks with a blocking queued connection (OBSApp.cpp.hpp:1247). If one of these requests is in flight when Stop() starts, the pool thread waits for the UI thread and the UI thread waits for the pool, so OBS hangs. Also, the sleep loop reads _sessions.size() without _sessionMutex.
Possible fix: do not wait for the pool on the UI thread (stop on a worker and finish from a callback), or make these requests use a non-blocking UI task and reply from it.
2. GetStats queries free disk space on every call (pool stall). ObjectHelper::GetStats() calls os_get_free_disk_space() on the recording path for every request (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 path each call blocks one pool thread. Clients that poll GetStats every second fill the pool (default size = ideal thread count). Event broadcasts use the same pool (WebSocketServer_Protocol.cpp:362), so all requests and events stop too.
Possible fix: read the cached value from #1282 (#1336) when it is available, and report null or the last value while no fresh value exists.
3. GetStats CPU usage: one shared state, no lock.
All clients share one os_cpu_usage_info_t (obs-websocket.cpp:64). os_cpu_usage_info_query() writes its "last" fields on every call, without a lock, and requests run in parallel on the pool. Two clients polling at the same time cause a data race (C: platform-nix.c.h:100; Rust: obs-util/src/ffi/platform_nix.rs:453 makes a &mut from the shared pointer, which is UB when two threads do it). Even without the race, each client gets the CPU usage since the last call from any client, not since its own last call. With times() at 100 Hz, two calls within 10 ms return 0.0.
Possible fix: a mutex around the query in obs-websocket, or a CPU usage value per session.
No problem found:
Volume meters: one handler shared by all clients (reference counted), created only while at least one client subscribes to InputVolumeMeters. It waits 50 ms on a condition variable and stops at once. More clients do not multiply the work.
Event broadcast: each event is serialized at most once per encoding (JSON, MessagePack), not once per client.
The settings dialog session table updates every 1 s only while the dialog is open.
The Sleep request is available only in batches, by design.
The server thread runs asio and blocks, it does not spin.
I will open a sub-issue for each of 1, 2 and 3 unless you prefer to keep them here.
Claiming the capture plugins part only (linux-pipewire, linux-capture, mac-capture, vlc-video, decklink, text-freetype2); @vpacher's obs-websocket part is done (#1344-#1346, thanks). I'm reading them with the #1273 criteria; findings become sub-issues of #1273.
Claim bot:@zackees, this is already claimed by vpacher. Pick something else or offer help here; once the claim goes stale, comment Taking over stale claim from @vpacher.
Capture plugins part done (linux-pipewire, linux-capture, mac-capture, vlc-video, decklink, text-freetype2), read at origin/master with the #1273 criteria. No busy-spin and no ~0 interval. Three findings, filed as sub-issues of #1273:
linux-pipewire's portal code calls g_dbus_proxy_new_sync and g_bus_get_sync on the GLib main thread and caches nothing on failure, so each screencast reconnect attempt (every 30 s in the slow phase) repeats the blocking call.
Cross-reference: #1344 (blocking OBS_TASK_UI tasks can deadlock obs-websocket Stop()) is closed as an upstream limitation of the preserved C++ plugin, not a Rust OBS defect. The deadlock is between the plugin's pool thread and its own Stop() on the UI thread; every fix would either modify the frozen plugin or leave a queued task pointing at a caller stack frame that has already unwound. Keeping it here so a future upstream fix is picked up when the plugin is next re-synced.
Activity
vpacher commentedon Oct 17, 2026
Claiming the obs-websocket part only (GetStats, the stats and event threads, and how many clients or high event subscription rates multiply the work). The capture plugins in this issue stay open for someone else. Plan: read the code with the #1273 criteria (busy-spin or ~0 interval, UI-thread work, error-path spins), post the findings here, and open a sub-issue for each real finding.
vpacher commentedon Oct 17, 2026
Findings for the obs-websocket part (submodule at 0d663ee). I read it with the #1273 criteria. There is no busy-spin and no ~0 interval. I found three problems: one UI-thread deadlock, one pool stall on a hung disk path, and one data race in
GetStats. I did not reproduce them, the evidence is from reading the code.1. Server
Stop()on the UI thread can deadlock (UI stall).WebSocketServer::Stop()calls_threadPool.waitForDone()and then waits in a 10 ms sleep loop until_sessionsis empty (WebSocketServer.cpp:202-206). It runs on the UI thread when the settings dialog restarts the server (SettingsDialog.cpp:218) and at module unload (obs-websocket.cpp:141). Three requests wait on the UI thread from a pool thread withobs_queue_task(OBS_TASK_UI, ..., true):SetStudioModeEnabled(RequestHandler_Ui.cpp:70),SetCurrentSceneCollectionandSetCurrentProfile(RequestHandler_Config.cpp:167, 259). The frontend runs those tasks with a blocking queued connection (OBSApp.cpp.hpp:1247). If one of these requests is in flight whenStop()starts, the pool thread waits for the UI thread and the UI thread waits for the pool, so OBS hangs. Also, the sleep loop reads_sessions.size()without_sessionMutex.Possible fix: do not wait for the pool on the UI thread (stop on a worker and finish from a callback), or make these requests use a non-blocking UI task and reply from it.
2.
GetStatsqueries free disk space on every call (pool stall).ObjectHelper::GetStats()callsos_get_free_disk_space()on the recording path for every request (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 path each call blocks one pool thread. Clients that pollGetStatsevery second fill the pool (default size = ideal thread count). Event broadcasts use the same pool (WebSocketServer_Protocol.cpp:362), so all requests and events stop too.Possible fix: read the cached value from #1282 (#1336) when it is available, and report
nullor the last value while no fresh value exists.3.
GetStatsCPU usage: one shared state, no lock.All clients share one
os_cpu_usage_info_t(obs-websocket.cpp:64).os_cpu_usage_info_query()writes its "last" fields on every call, without a lock, and requests run in parallel on the pool. Two clients polling at the same time cause a data race (C:platform-nix.c.h:100; Rust:obs-util/src/ffi/platform_nix.rs:453makes a&mutfrom the shared pointer, which is UB when two threads do it). Even without the race, each client gets the CPU usage since the last call from any client, not since its own last call. Withtimes()at 100 Hz, two calls within 10 ms return0.0.Possible fix: a mutex around the query in obs-websocket, or a CPU usage value per session.
No problem found:
InputVolumeMeters. It waits 50 ms on a condition variable and stops at once. More clients do not multiply the work.Sleeprequest is available only in batches, by design.I will open a sub-issue for each of 1, 2 and 3 unless you prefer to keep them here.
vpacher commentedon Oct 17, 2026
Sub-issues: 1 → #1344, 2 → #1345, 3 → #1346. The obs-websocket part of this audit is done; the capture plugins listed above are still open.
zackees commentedon Oct 17, 2026
Claiming the capture plugins part only (linux-pipewire, linux-capture, mac-capture, vlc-video, decklink, text-freetype2); @vpacher's obs-websocket part is done (#1344-#1346, thanks). I'm reading them with the #1273 criteria; findings become sub-issues of #1273.
github-actions commentedon Oct 17, 2026
Claim bot: @zackees, this is already claimed by
vpacher. Pick something else or offer help here; once the claim goes stale, commentTaking over stale claim from @vpacher.zackees commentedon Oct 17, 2026
Capture plugins part done (linux-pipewire, linux-capture, mac-capture, vlc-video, decklink, text-freetype2), read at origin/master with the #1273 criteria. No busy-spin and no ~0 interval. Three findings, filed as sub-issues of #1273:
video_tickmakes 1-2 blocking X round trips per frame underobs_enter_graphics().Minor notes, not filed:
g_dbus_proxy_new_syncandg_bus_get_syncon the GLib main thread and caches nothing on failure, so each screencast reconnect attempt (every 30 s in the slow phase) repeats the blocking call.xcb_shm_get_imageround trip has the same X-latency exposure as linux-capture: XComposite video_tick does blocking X round trips per frame under the graphics lock #1356, but that is the capture's basic design.Checked and fine:
os_statper second per source.find_windowthrottled to 500 ms, the window-capture worker on an event, and SCK enumeration only at create/update.With @vpacher's obs-websocket part (#1344-#1346) this covers the whole issue.
zackees commentedon Oct 17, 2026
Both parts of the audit gap are read; findings are sub-issues of #1273.
zackees commentedon Oct 27, 2026
Cross-reference: #1344 (blocking OBS_TASK_UI tasks can deadlock obs-websocket Stop()) is closed as an upstream limitation of the preserved C++ plugin, not a Rust OBS defect. The deadlock is between the plugin's pool thread and its own
Stop()on the UI thread; every fix would either modify the frozen plugin or leave a queued task pointing at a caller stack frame that has already unwound. Keeping it here so a future upstream fix is picked up when the plugin is next re-synced.