diff --git a/app.js b/app.js index b02b03e..b4b47e8 100644 --- a/app.js +++ b/app.js @@ -44,6 +44,7 @@ let selectionBuffer = null; let lastRenderTime = 0; let frameCount = 0, currentFps = 0, lastFpsUpdate = 0; let streamStartTime = 0; +let audioClockOffset = null; // anchors the audio clock so it never jumps backward (issue #7) const CHAR_LUT = new Array(128); for (let i = 0; i < 128; i++) CHAR_LUT[i] = String.fromCharCode(i); @@ -185,6 +186,7 @@ function connectWebSocket() { streamStartTime = performance.now(); lastRenderTime = performance.now(); lastFpsUpdate = lastRenderTime; + audioClockOffset = null; // re-anchor for this stream requestAnimationFrame(renderFrame); }; @@ -267,11 +269,25 @@ function renderFrame(now) { requestAnimationFrame(renderFrame); // ── MASTER CLOCK LOGIC ── + // The audio track is the master clock, BUT it must never jump backward + // (issue #7, the cold-start freeze). On a cold load the