Skip to content

Fix OBS icons stuck on error after OBS restart#38

Open
f1nalspace wants to merge 1 commit into
StreamController:mainfrom
f1nalspace:sakura-fixes
Open

Fix OBS icons stuck on error after OBS restart#38
f1nalspace wants to merge 1 commit into
StreamController:mainfrom
f1nalspace:sakura-fixes

Conversation

@f1nalspace

Copy link
Copy Markdown

Problem

When OBS is closed and reopened, the action icons (Record, Stream, etc.)
stay stuck on the error triangle and never recover. The error is shown
correctly while OBS is gone, but the icon does not return to normal once
OBS is reachable again — the page has to be reloaded to recover.

Root cause

Three combined defects (found via logging the connection state across the
frontend and the separate backend process):

  1. Tick crash on empty response — when OBS closes, a websocket request
    returns an empty datain, so status.datain["outputActive"] raised
    KeyError, crashing the action tick instead of showing the error cleanly.

  2. Unreliable disconnect signalOBSController.connected stayed True
    because on_disconnect does not reliably fire on a hard OBS shutdown, so
    reconnection was never triggered. The library's own authreconnect also
    competed with the plugin and left the connection in an inconsistent state.

  3. Error overlay never clearedshow_error() sets a persistent overlay
    that is only removed by hide_error(). Only ToggleStream called
    hide_error(); every other action left the triangle on top of the normal
    icon even after the connection recovered.

Changes

  • backend/backend.py: new build_status_dict() — returns None on a
    missing/empty response and marks the connection as lost (no more KeyError).
  • backend/OBSController.py: disable the library auto-reconnect
    (authreconnect=0) and add teardown_existing_connection() for clean
    reconnects.
  • OBSActionBase.py: throttled try_reconnect_if_disconnected() driven from
    the tick loop.
  • All status actions: call hide_error() in the success path so the error
    overlay clears once OBS is reachable again.

Testing

Verified live: closing OBS shows the error icon; reopening OBS recovers the
correct status icon automatically within a few seconds, no page reload needed.

When OBS is closed and reopened, the action icons stayed on the error
triangle and never recovered. Three combined defects:

1. backend.py: an empty websocket response (OBS closed) caused
   KeyError on status.datain[...] which crashed the action tick.
   Add build_status_dict() which returns None on a missing/empty
   response and marks the connection as lost (no crash).

2. OBSController.py: the obs-websocket "connected" flag was not a
   reliable disconnect signal (on_disconnect did not always fire),
   so reconnection never triggered. Disable the library's competing
   auto-reconnect (authreconnect=0) and add teardown_existing_connection()
   for a clean reconnect.

3. OBSActionBase.py + actions: drive a throttled reconnect from the
   tick loop (try_reconnect_if_disconnected), and call hide_error()
   in each status success path so the persistent error overlay is
   cleared once OBS is reachable again (only ToggleStream did this
   before, which is why recording/others stayed stuck).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant