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
frontend: blocking OBS_TASK_UI tasks can deadlock obs-websocket Stop() (fix in Rust OBS, plugin unchanged) #1344
WebSocketServer::Stop() calls _threadPool.waitForDone() and then waits in a 10 ms sleep loop until _sessions is empty (plugins/obs-websocket/src/websocketserver/WebSocketServer.cpp:202-206). It runs on the UI thread:
when the settings dialog restarts the server (src/forms/SettingsDialog.cpp:218),
at module unload (src/obs-websocket.cpp:141).
Three requests wait for the UI thread from a pool thread with obs_queue_task(OBS_TASK_UI, ..., true):
The frontend runs these tasks with a blocking queued connection (frontend/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: OBS hangs. Found by reading the code, not reproduced yet.
Also: the sleep loop reads _sessions.size() without _sessionMutex.
Fix: do not wait for the pool on the UI thread (stop on a worker and finish from a callback), or let these requests use a non-blocking UI task and reply from it.
Test: a request handler that blocks on a UI task while Stop() is called from the UI thread; Stop() must return and the UI event loop must keep processing events.
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: Server Stop() on the UI thread can deadlock with requests that wait for the UI thread[/-][+]frontend: blocking OBS_TASK_UI tasks can deadlock obs-websocket Stop() (fix in Rust OBS, plugin unchanged)[/+]on Oct 25, 2026
Our side of the cycle is ui_task_handler (frontend/OBSApp.cpp.hpp:1225). For wait == true from a pool thread, it runs task(param) on the UI thread through WaitConnection(), which is a blocking queued call. The other side, Stop() looping on the UI thread until the sessions drain, is inside the frozen plugin.
A timed wait in the handler is unsafe. The three requests pass param pointing at the caller's stack and read results back from it after the call (SetCurrentProfile, SetCurrentSceneCollection, SetStudioModeEnabled). If the handler returned on a timeout, the request thread would unwind while the task stays queued. The task would then run later on a dangling param, which turns a hang into a use-after-free.
Running the task on the calling thread is also out. These tasks touch Qt widgets and frontend state that live on the UI thread.
The settings-dialog restart path (SettingsDialog.cpp:218) happens entirely inside the plugin: the plugin's dialog calls the plugin's Stop(). Rust OBS has no hook in between.
The module-unload path:obs_shutdown → obs_module_unload → Stop() runs from the frontend's shutdown. The frontend can't drain in-flight websocket requests: there's no API for it, and the plugin owns the pool.
Conclusion
I found no Rust OBS-side change that removes this deadlock without either modifying the plugin, which AGENTS.md forbids, or making blocking UI tasks unsafe. I recommend closing this as an upstream limitation of obs-websocket and noting it on #1285.
If a maintainer sees a lever I missed, reopen with it. One idea: a frontend-side "UI thread is in shutdown" flag that rejects new blocking UI tasks before obs_shutdown. It would only narrow the unload window, though: a request already waiting would still deadlock. I'll release this claim if nobody objects within a day.
Closing as an upstream limitation of the frozen obs-websocket plugin, per the investigation above: the deadlock is entirely between the plugin's own pool thread (blocking obs_queue_task(OBS_TASK_UI, ..., true)) and its own Stop() on the UI thread, and every Rust OBS-side lever either modifies the plugin (AGENTS.md forbids it) or turns the hang into a use after free on the requests' stack param.
Noted on #1285 as an accepted limitation. If a maintainer sees a lever I missed, reopen with it.
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: Server Stop() on the UI thread can deadlock with requests that wait for the UI thread[/-][+]frontend: blocking OBS_TASK_UI tasks can deadlock obs-websocket Stop() (fix in Rust OBS, plugin unchanged)[/+]zackees commentedon Oct 25, 2026
Claiming: investigation
I read the code; I haven't reproduced it.
Findings
ui_task_handler(frontend/OBSApp.cpp.hpp:1225). Forwait == truefrom a pool thread, it runstask(param)on the UI thread throughWaitConnection(), which is a blocking queued call. The other side,Stop()looping on the UI thread until the sessions drain, is inside the frozen plugin.parampointing at the caller's stack and read results back from it after the call (SetCurrentProfile,SetCurrentSceneCollection,SetStudioModeEnabled). If the handler returned on a timeout, the request thread would unwind while the task stays queued. The task would then run later on a danglingparam, which turns a hang into a use-after-free.SettingsDialog.cpp:218) happens entirely inside the plugin: the plugin's dialog calls the plugin'sStop(). Rust OBS has no hook in between.obs_shutdown→obs_module_unload→Stop()runs from the frontend's shutdown. The frontend can't drain in-flight websocket requests: there's no API for it, and the plugin owns the pool.Conclusion
I found no Rust OBS-side change that removes this deadlock without either modifying the plugin, which AGENTS.md forbids, or making blocking UI tasks unsafe. I recommend closing this as an upstream limitation of obs-websocket and noting it on #1285.
If a maintainer sees a lever I missed, reopen with it. One idea: a frontend-side "UI thread is in shutdown" flag that rejects new blocking UI tasks before
obs_shutdown. It would only narrow the unload window, though: a request already waiting would still deadlock. I'll release this claim if nobody objects within a day.zackees commentedon Oct 27, 2026
Closing as an upstream limitation of the frozen obs-websocket plugin, per the investigation above: the deadlock is entirely between the plugin's own pool thread (blocking
obs_queue_task(OBS_TASK_UI, ..., true)) and its ownStop()on the UI thread, and every Rust OBS-side lever either modifies the plugin (AGENTS.md forbids it) or turns the hang into a use after free on the requests' stackparam.Noted on #1285 as an accepted limitation. If a maintainer sees a lever I missed, reopen with it.