src.nth.io/

summaryrefslogtreecommitdiff
path: root/main/display.h
diff options
context:
space:
mode:
authorLuke Hoersten <[email protected]>2026-06-21 11:01:29 -0500
committerLuke Hoersten <[email protected]>2026-06-21 11:01:29 -0500
commit1ce49d3646046a18e03f7befbe5e3f59a1febd49 (patch)
tree562aa82fcf78ce39721f4e2a2830197b47ba0016 /main/display.h
parent391d9130187e8f5fe7faacb6c0d3ea6660be832f (diff)
scrypted: unified shutdown-cleaner array covers streams + listeners + timers
Scrypted's Scripts sandbox doesn't release a previous load's resources before constructing a new Provider instance, so anything long-lived survives a re-paste. Previously we hand-rolled cleanup via two separate globalThis hooks: __viewportListenerCleaners (camera event listeners) and __viewportRegisterInterval (the 5-minute re-register timer). Anything else — in-flight ffmpeg children, TCP sockets to the firmware, the per-stream stats interval — leaked across reloads. Visible symptom: re-pasting the script during an active stream left the old stream's ffmpeg + socket running against a dead Provider instance, accumulating across reloads until the host was restarted. Unify all cleanup into one globalThis array, __viewportShutdownCleaners, that every long-lived resource pushes onto. The next start() snapshots and drains it before doing anything else. Resources covered: - 5-minute re-register interval (clearInterval) - Every camera + child-device event listener (reg.removeListener) - Every in-flight stream's AbortController (abort.abort, which the existing abort listeners chain into socket.destroy() + ffmpeg SIGTERM + clearInterval on the stats logger) Each cleanup is removed from the array when the resource naturally ends (stream timeout / stopStream), so the list stays compact across many stream cycles rather than growing forever. Snapshot-before-walk avoids the iteration-skip bug where a stream abort fires its abort listener, which splices the closure out of the same array we're iterating. Snapshot the array, clear the original, then walk the snapshot. Doesn't address the 'Unknown' status panel in Scrypted Scripts UI — that's a separate cosmetic issue (we don't implement a lifecycle interface that reports running state).
Diffstat (limited to 'main/display.h')
0 files changed, 0 insertions, 0 deletions