Waveform icon indicating copy to clipboard operation
Waveform copied to clipboard

Fatal error: Index out of range on setting the `selectedSamples`

Open heyaibek opened this issue 1 year ago • 2 comments

Hey 👋🏻 I'm getting Fatal error: Index out of range exception on setting the selectedSamples range like so:

Waveform(
  generator: generator,
  selectedSamples: $selectedSamples,
  selectionEnabled: .constant(true)
)
.foregroundColor(.white)
.onAppear {
  selectedSamples = 0 ..< Int(generator.audioBuffer.frameLength)
}

What could be the issue?

heyaibek avatar Jan 18 '24 22:01 heyaibek

Hey @heyaibek, did you manage to figure this one out?

pixlwave avatar Feb 29 '24 08:02 pixlwave

Hey @pixlwave 👋🏻 I've noticed that the crash happens when selection is enabled by constant value like selectionEnabled: .constant(true). In your demo project, however, it depends on the toggle value to enable/disable the selection. So, I just put the same mechanism in my code. But I'm afraid that this bug should be fixed 😛

heyaibek avatar Feb 29 '24 14:02 heyaibek