Smooth realtime display frame pacing

This commit is contained in:
Mikei386
2026-08-05 16:35:09 +02:00
parent afcceec986
commit a8e9729b3a
3 changed files with 32 additions and 16 deletions
+8 -2
View File
@@ -2698,14 +2698,20 @@ async function loop(now){
const currentAudioSeq = Math.max(currentMetricsSeq, currentVisualsSeq, currentXySeq);
const audioDirty = currentAudioSeq > lastRenderedAudioSeq;
const shouldRenderFrame =
audioOk ||
renderDirty ||
audioDirty ||
!audioOk ||
style === 'options-panel' ||
style === 'recorder' ||
renderStyle === 'clock';
if (elapsed >= target){
lastFrameTime = now - (elapsed % targetMs);
// With live audio, requestAnimationFrame itself is the display clock. An
// additional exact 60 Hz comparison occasionally rejected a real 60 Hz
// frame because of fractional timestamp jitter, creating 33 ms pauses in
// otherwise smooth peak decay. Only throttle the disconnected state.
const frameDue = audioOk || elapsed >= target;
if (frameDue){
lastFrameTime = audioOk ? now : now - (elapsed % targetMs);
try{
updateRect();
meterHitRects.length = 0;