diff --git a/src/components/DebugOverlay.svelte b/src/components/DebugOverlay.svelte index 84dddae..43b6285 100644 --- a/src/components/DebugOverlay.svelte +++ b/src/components/DebugOverlay.svelte @@ -11,6 +11,8 @@ let visible = $state(false); let stats = $state(null); let fps = $state(0); + let drops = $state(0); // main-thread frames >25ms since overlay opened + let worstGap = $state(0); let dlSpeed = $state(0); // bytes/sec of the CURRENT track's stream function onKeydown(e) { @@ -45,9 +47,20 @@ let frames = 0; let fpsWindow = performance.now(); + let prevFrame = performance.now(); + drops = 0; + worstGap = 0; let raf = requestAnimationFrame(function loop() { frames += 1; const now = performance.now(); + // Main-thread frame gap — the jank signal. >25ms = a frame the + // user can feel; count it and remember the worst. + const gap = now - prevFrame; + prevFrame = now; + if (gap > 25) { + drops += 1; + if (gap > worstGap) worstGap = Math.round(gap); + } if (now - fpsWindow >= 500) { fps = Math.round((frames * 1000) / (now - fpsWindow)); frames = 0; @@ -80,7 +93,7 @@ {#if visible} -