quick fix
This commit is contained in:
parent
282eb5d80c
commit
346b3ef378
1 changed files with 11 additions and 3 deletions
|
|
@ -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) " +
|
||||
|
|
|
|||
Loading…
Reference in a new issue