learning_ai_common_plat/packages/media-ui/src
saravanakumardb1 b2e45380ec fix(media-ui): plug AudioContext leak + guard <img> against undefined src
Two latent bugs caught in the audit pass:

1. **AudioContext leak in AudioWaveform.**
   The lazy WebAudio decoder constructed an `AudioContext` per
   mount-with-audioUrl and never called `.close()`. Browsers cap the
   total per page (Chrome ~6, Firefox ~6) so a long-lived session that
   remounted waveforms enough times eventually hit
   `InvalidStateError: cannot create AudioContext` and silently
   stopped decoding.
   Fix: wrap `decodeAudioData` in try/finally and `close()` the
   context in the finally. Errors from close() are swallowed (best-
   effort cleanup).

2. **Undefined img src in ImageGenStream.**
   When `status=streaming` arrived before the first
   `snapshot.partialUrl` (very common during the SSE handshake),
   the component rendered <img src={undefined}> which browsers treat
   as a broken-image icon. Same for status=complete + missing
   finalUrl.
   Fix: compute `visibleSrc` once; only mount <img> if a source
   exists, otherwise show 'Waiting for first frame\u2026' placeholder.
   Also removed the dead `revealedAt` state \u2014 the prior 0.95/1
   opacity dance was imperceptible and contributed nothing.

3. **Bonus: AudioWaveform `bars` clamp.**
   `bars={0}` (or negative / fractional) divided by zero on the
   canvas slot math and rendered an empty waveform. Now clamped to
   `Math.max(1, Math.floor(barsProp))`.

Tests: 10 \u2192 12
  AudioWaveform   \u00b7 bars=0 doesn't crash + canvas still renders
  ImageGenStream  \u00b7 streaming without partialUrl shows placeholder
                    instead of <img src={undefined}>
2026-05-27 18:44:50 -07:00
..
__tests__ fix(media-ui): plug AudioContext leak + guard <img> against undefined src 2026-05-27 18:44:50 -07:00
AudioWaveform.tsx fix(media-ui): plug AudioContext leak + guard <img> against undefined src 2026-05-27 18:44:50 -07:00
ImageGenStream.tsx fix(media-ui): plug AudioContext leak + guard <img> against undefined src 2026-05-27 18:44:50 -07:00
index.ts feat(media-ui): @bytelyst/media-ui@0.1.0 — Wave 13.G.1/.2/.4 2026-05-27 17:44:13 -07:00
VideoPlayer.tsx feat(media-ui): @bytelyst/media-ui@0.1.0 — Wave 13.G.1/.2/.4 2026-05-27 17:44:13 -07:00