diff options
| author | Luke Hoersten <[email protected]> | 2026-06-20 11:54:14 -0500 |
|---|---|---|
| committer | Luke Hoersten <[email protected]> | 2026-06-20 11:54:14 -0500 |
| commit | 28f39bf5102ef398b6e91fdf61e7583c99d7252c (patch) | |
| tree | 140c2dc96ee37d507afcaa0a0b18338f6ec60ced /main/display.c | |
| parent | 16f4c5be220756808747bfb47739733d3f107634 (diff) | |
scrypted: kill listener leak across script reloads + one-line sent-vs-painted log
#1 — Camera listener leak
Same Scripts-sandbox lifecycle gap that bit us with setInterval (fixed
in 521de7e): cam.listen() returns an EventListenerRegister with a
removeListener() method. The listener is held on the camera plugin's
side, not the script's, so when the old Provider instance gets GC'd
on script reload its registrations stay live with a dead callback.
Field symptom: after re-pasting the script N times, every camera
event arrives N times in handleCameraEvent. Today the streamStarting
guard catches sequential dupes, but two callbacks firing on the same
event within the JS microtask window both check streamStarting
BEFORE either has added their nativeId, both proceed, two
pushSnapshots launch in parallel. They race for the firmware
decoder lock — one paints, one gets 503 — and the user perceives
sharp-fighting-with-itself as "snapshot quality is bad again."
Fix: same globalThis trick as the setInterval. Push a remover
closure onto G.__viewportListenerCleaners every time attachListener
fires; at start() of the new Provider instance, drain the array
calling each remover before creating fresh listeners. Idempotent
across reloads.
#2 — Unified sent-vs-painted log
The user asked: "do we have an understanding in the logging/
instrumentation what the FPS of the stream output is from scrypted
out is vs the actual rendered FPS once the stream is loaded?"
Both numbers existed but in separate log lines (skipLogger every 10s
+ fwPoller every 5s, interleaved in the console). Folded the /state
poll into the 10s skipLogger so there's ONE line per window with
sent fps + painted fps side-by-side plus the gap explicitly labeled:
stream "kitchen": sent=24.2fps painted=22.8fps (fw-skipped=1.4fps,
drops=0) 4.58MB/s sent / 4.29MB/s painted |
socket.write p50=0ms p95=1ms max=5ms backpressured=true |
recv=27776/37237/44470us dec=5788/5991/6626us
paint=30/36/46us idle=164/588/11383us | g2g=142ms
fw-skipped = (sent − painted), how many frames per second the
firmware's FIONREAD skip dropped to keep the panel on the freshest
frame. The g2g value is now meaningful per-frame thanks to the
firmware-side live-update we landed last commit.
Drops the separate fwPoller; one comprehensive log per 10s window.
Diffstat (limited to 'main/display.c')
0 files changed, 0 insertions, 0 deletions
