hud-8: keep the libass loop alive across XR entry; auto dual/mono subtitles

ADDENDUM 9 — two independent defects found on device.

1. VR subtitles froze on whatever line was on screen when the session started.
   Jellyfin 12.x renders with SubtitlesOctopus, which starts ONE long-lived rAF
   loop when the video loads; entering immersive-vr stops native rAF and destroys
   the callback still pending in the native scheduler, and because the instance's
   rafId stays non-zero it is never restarted (measured live: rafId=1150 native,
   oneshotState.eventStart frozen ~7 min behind the playhead, zero oneshot-render
   requests). The broker now ALWAYS queues rAF (native driver outside XR, rVFC +
   50 ms idle fallback inside), keeps exactly one native callback in flight, and
   no longer clears the queue at session start. A first version re-armed during
   the drain and doubled the driver every frame, freezing the page; that is now
   fixed and locked down by a Node harness (maxConcurrentNative = 1 over 300
   frames, self-rescheduling loop survives a simulated session start).

2. Only dual-eye ASS subtitles worked; a normal subtitle (e.g. the CN SRT track)
   is centred across the whole 2:1 frame and was cut at the eye seam because the
   HUD always sampled the left half. state.subLayout ('auto'|'dual'|'mono',
   default auto, persisted, panel row) plus per-sample detection: seam ink -> mono,
   one half only -> dual/mono, both halves with an empty seam -> column-profile
   copy test. Dual-eye is NOT a pixel mirror (same text at mirrored positions, no
   glyph flip): measured dual copy distance 0.02-0.08 vs mono 1.00, seam ink
   0 vs 50. M.eyeW (half for dual, full for mono) replaces the hard-coded halfW.

Docs: INTERFACES.md ADDENDUM 9, HANDOFF.md §13 (including the Jellyfin service
worker cache trap that made the first deploy look like a no-op).

The final build was not re-checked in the headset: the device left the worn state
mid-verification and the browser could not be relaunched. Verified on device: the
loop survives XR (rafId in the plugin range, eventStart tracking, subUploads 4->7
over 20 s in VR) and the layout metrics above; the final decision wiring is
covered by the offline suites.
This commit is contained in:
2026-10-12 16:32:25 +08:00
parent 7f751b7eee
commit 164d692791
6 changed files with 697 additions and 114 deletions
+2 -1
View File
@@ -11,7 +11,7 @@
var NS = window.__JFVR = window.__JFVR || {};
NS.version = 'hud-7'; // hud-7 = ADDENDUM 8b (live picture pan: transform/space, hold-to-drag, tap-to-reset)
NS.version = 'hud-8'; // hud-8 = ADDENDUM 9 (rAF broker always-on so the libass loop survives XR entry; auto dual/mono subtitle layout)
NS.__core = true;
/* ------------------------------------------------------------------ *
@@ -51,6 +51,7 @@
subtitles: true,
ctlLock: false, // ADDENDUM 7: control-bar lock badge (per VR session)
subMode: 'hud', // 'hud' | 'sphere' | 'off'
subLayout: 'auto', // ADDENDUM 9: 'auto' | 'dual' | 'mono' subtitle layout
subAlpha: 'premultiplied', // 'premultiplied' | 'straight'
subOpacity: 0.85, // 0..1, applied to the subtitle layer live
// y is the quad CENTRE; negative = below eye level. -0.42 keeps the strip