From 03a216f510f361afda92688c423f0ab1377f22b9 Mon Sep 17 00:00:00 2001 From: Blaze Date: Fri, 27 Sep 2024 08:30:44 +0200 Subject: [PATCH 1/2] Remove async set --- Sources/Waveform/Renderer.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Waveform/Renderer.swift b/Sources/Waveform/Renderer.swift index e324145..f82c357 100644 --- a/Sources/Waveform/Renderer.swift +++ b/Sources/Waveform/Renderer.swift @@ -143,7 +143,7 @@ class Renderer: NSObject, MTKViewDelegate { commandBuffer.commit() } - func set(samples: SampleBuffer, start: Int, length: Int) async { + func set(samples: SampleBuffer, start: Int, length: Int) { self.start = start self.length = length if samples === self.samples { From 202b5a900aecc28cf9bff563bb1acab4191c4796 Mon Sep 17 00:00:00 2001 From: Blaze Date: Fri, 27 Sep 2024 08:33:08 +0200 Subject: [PATCH 2/2] Remove redundant Task --- Sources/Waveform/Waveform.swift | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/Sources/Waveform/Waveform.swift b/Sources/Waveform/Waveform.swift index c923d20..279438b 100644 --- a/Sources/Waveform/Waveform.swift +++ b/Sources/Waveform/Waveform.swift @@ -59,12 +59,7 @@ public struct Waveform: NSViewRepresentable { public func updateNSView(_ nsView: NSViewType, context: Context) { let renderer = context.coordinator.renderer renderer.constants = constants - Task { - await renderer.set(samples: samples, - start: start, - length: length) - nsView.setNeedsDisplay(nsView.bounds) - } + renderer.set(samples: samples, start: start, length: length) nsView.setNeedsDisplay(nsView.bounds) } } @@ -121,12 +116,7 @@ public struct Waveform: UIViewRepresentable { public func updateUIView(_ uiView: UIViewType, context: Context) { let renderer = context.coordinator.renderer renderer.constants = constants - Task { - await renderer.set(samples: samples, - start: start, - length: length) - uiView.setNeedsDisplay() - } + renderer.set(samples: samples, start: start, length: length) uiView.setNeedsDisplay() } }