From 346b3ef378378ae6ff0e41eb6d157a8ea69894f5 Mon Sep 17 00:00:00 2001 From: Dallas Groot Date: Sat, 11 Apr 2026 19:28:18 -0700 Subject: [PATCH] quick fix --- iOS/Views/Visualizer/MitsuhaVisualizerView.swift | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/iOS/Views/Visualizer/MitsuhaVisualizerView.swift b/iOS/Views/Visualizer/MitsuhaVisualizerView.swift index 96010a6..aeeefa3 100644 --- a/iOS/Views/Visualizer/MitsuhaVisualizerView.swift +++ b/iOS/Views/Visualizer/MitsuhaVisualizerView.swift @@ -326,9 +326,12 @@ struct MitsuhaVisualizerView: View { // (e.g. on a radio buffer hiccup), causing the next tick to be // deferred by a full interval — the visible "stall" in the wave. TimelineView(.periodic(from: .distantPast, by: tickInterval)) { timeline in - let tickDate = timeline.date Canvas { context, size in - _ = tickDate + // Read timeline.date INSIDE Canvas — this is the critical dependency + // that tells SwiftUI to re-evaluate Canvas on every timeline tick. + // Reading it outside the Canvas closure (as a let) doesn't establish + // the Canvas redraw dependency, causing the occasional stall. + let _ = timeline.date box.resizeIfNeeded(count: config.numberOfPoints, idleAmplitude: Float(settings.idleAmplitude)) guard box.displayLevels.count >= 2 else { return } @@ -378,7 +381,9 @@ struct MitsuhaVisualizerView: View { if !playing { box.levelHistoryBuf.removeAll(keepingCapacity: true) box.historyWriteIdx = 0 - box.peakFollower = 0.01 + // Do NOT reset peakFollower here. Resetting to 0.01 means the + // first resume frame gets normFactor=100x (1/0.01), spiking + // normal levels (~0.5) to 1.0 — the "raise up" on resume. box.lastTickTime = 0 DebugLogger.shared.log( "PAUSE → levelHistoryBuf cleared, lastTickTime reset " + @@ -386,6 +391,9 @@ struct MitsuhaVisualizerView: View { category: "VisDebug", level: .info) } else { box.resumeTickCount = 0 + // Warm-start peakFollower so normFactor begins around 3x not 100x + box.peakFollower = 0.3 + box.lastTickTime = 0 DebugLogger.shared.log( "RESUME → isRenderingActive=\(isRenderingActive) " + "isAppActive=\(isAppActive) isVisible=\(isVisible) " +