8000 fix(preview): hold last-good frame to hide black flash on seek/wrap by johannboehme · Pull Request #17 · johannboehme/tk-1 · GitHub
[go: up one dir, main page]

Skip to content

fix(preview): hold last-good frame to hide black flash on seek/wra 8000 p - #17

Merged
johannboehme merged 1 commit into
mainfrom
claude/zen-lumiere-caa39c
May 2, 2026
Merged

johannboehme merged 1 commit into
mainfrom
claude/zen-lumiere-caa39c

Conversation

@johannboehme
Copy link
Copy Markdown
Owner

Summary

  • Pro-Layer Frame-Cache im PreviewRuntime: hält das letzte erfolgreich gerenderte <video>-Frame als ImageBitmap, gedrosselt auf 100ms/Layer
  • Während ein <video> mid-seek ist (seeking || readyState < 2) und der Cam in-range, reicht der Runtime das gehaltene Bitmap als fallback durch — Backend zeichnet das Bitmap statt der leeren <video>, der schwarze Background-Clear schlägt nicht mehr durch
  • Out-of-range-Layer bleiben korrekt schwarz; Cam-Removal evictet + closet die gecachten Bitmaps

Why

Beim Scrub und Loop-Wrap setzt VideoElementPool.syncSlot video.currentTime = sourceT. Der Decoder braucht 1–3 Frames bis seeked feuert; in der Lücke liefert drawImage(<video>) empty/transparent pixel und der unconditional Background-fillStyle="#000" (canvas2d) bzw. clearValue: { r:0,g:0,b:0,a:1 } (webgpu) flasht durch. Das brach das Instrument-Gefühl beim Loopen.

Architektur

  • LayerSource.video um optionales fallback?: ImageBitmap + preferFallback?: boolean erweitert
  • Cache-Owner: PreviewRuntime (geteilt für alle drei Backends — DRY, kein Backend-Lifecycle-Coupling)
  • Neue VideoElementPool.isInRange(clipId, masterT) damit der Runtime „Cam außerhalb [0, dur)" (→ Schwarz korrekt) von „Cam seekt" (→ Hold) unterscheidet
  • Backends canvas2d, webgpu, webgl2 honorieren alle drei preferFallback in ihren Source-to-Texture-Pfaden

Test plan

  • npm test (unit) — 667/667 grün, inkl. 5 neue Cache-Tests + 5 neue isInRange-Tests
  • npm run test:browser (render slice isoliert) — 70/70 grün, inkl. 2 neue pixel-level Canvas2D-Fallback-Tests
  • Manuell im Browser:
    • Loop-Wrap: kein schwarzer Flash beim Sprung an Loop-Start
    • Manueller Scrub: Bild „klebt" am letzten gültigen Frame statt zu blinken
    • Multi-Cam Cut: kein Stale-Frame der alten Cam in den Cut der neuen
    • Out-of-range Lücke: Schwarz korrekt, kein falscher Hold
    • WebGPU + Canvas2D-Backend beide getestet

🤖 Generated with Claude Code

Scrubbing the playhead and looping back to the start both trigger a
1–3 frame window where `<video>.currentTime = newT` is set but the
decoder hasn't produced a frame yet. drawImage(<video>) returned
empty/transparent pixels and the unconditional black background-clear
flashed through, breaking the instrument feel of the loop.

PreviewRuntime now snapshots each ready video layer into a per-layerId
ImageBitmap (throttled to 100ms/layer) and hands it to the backend as a
fallback while the element is mid-seek and the cam is in-range. All
three backends honour preferFallback in their source-to-texture path.
Out-of-range layers stay black (correct empty state); cam removal
evicts and closes cached bitmaps to prevent leaks.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@johannboehme
johannboehme merged commit d06ef70 into main May 2, 2026
1 check passed
@johannboehme
johannboehme deleted the claude/zen-lumiere-caa39c branch May 2, 2026 19:14
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

0