From 27ed57308f82f96b3942c8f4da60cfbee97e8e05 Mon Sep 17 00:00:00 2001 From: you Date: Thu, 19 Mar 2026 07:02:42 +0000 Subject: [PATCH] Fix VCR scrubber: limit replay to 50 packets from scrub point Root cause: scrub replay was playing through the ENTIRE buffer from scrub point to end (thousands of packets), racing the playhead forward to now. Now caps replay at 50 packets from scrub point, then pauses. Hit LIVE to resume real-time. --- public/live.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/public/live.js b/public/live.js index 1739af34..47a0936f 100644 --- a/public/live.js +++ b/public/live.js @@ -86,6 +86,8 @@ VCR.playhead = -1; VCR.speed = 1; VCR.missedCount = 0; + VCR.scrubEnd = null; + VCR.dragPct = null; vcrSetMode('LIVE'); const prompt = document.getElementById('vcrPrompt'); if (prompt) prompt.classList.add('hidden'); @@ -161,8 +163,9 @@ stopReplay(); function tick() { if (VCR.mode !== 'REPLAY') return; - if (VCR.playhead >= VCR.buffer.length) { - // Caught up — pause instead of auto-resuming live + const endIdx = VCR.scrubEnd != null ? VCR.scrubEnd : VCR.buffer.length; + if (VCR.playhead >= endIdx) { + VCR.scrubEnd = null; vcrSetMode('PAUSED'); return; } @@ -613,6 +616,8 @@ if (dist < minDist) { minDist = dist; closest = i; } }); VCR.playhead = closest; + // Only replay ~50 packets from scrub point, not entire buffer to end + VCR.scrubEnd = Math.min(closest + 50, VCR.buffer.length); startReplay(); }) .catch(() => {});