AudioKit / AudioKitUI

Controls and Visualization for AudioKit apps
MIT License
187 stars 52 forks source link

Random "Index Out of range" crash in FloatPlot #69

Open lucarocchi opened 1 year ago

lucarocchi commented 1 year ago

macOS Version(s) Used to Build

macOS 13 Ventura, macOS 12 Monterey

Xcode Version(s)

Xcode 14

Description

I'm working on an iOS app that uses NodeOutputView Randomly I get this "Index Out of range" as you can see in the screen shot

Crash Logs, Screenshots or Other Attachments (if applicable)

Screenshot 2022-12-10 alle 19 24 32 Screenshot 2022-12-07 alle 17 41 54
NickCulbertson commented 1 year ago

My guess would be that samples[j + 1] is out of range. It would be helpful to put

print("samples")
print(samples.count)
print(j+i)
print("resampled")
print(resampled.count)
print(i)

before that line to see if that is the crash. Can you make a simple example project to recreate the issue?

NickCulbertson commented 1 year ago

samples[min(j + 1, samples.count)] might work if the index is too high, but I'm not really sure what that line is doing.

emurray2 commented 1 year ago
Quoted reply > ### macOS Version(s) Used to Build > > macOS 13 Ventura, macOS 12 Monterey > > ### Xcode Version(s) > > Xcode 14 > > ### Description > > I'm working on an iOS app that uses NodeOutputView > Randomly I get this "Index Out of range" as you can see in the screen shot > > ### Crash Logs, Screenshots or Other Attachments (if applicable) > > Screenshot 2022-12-10 alle 19 24 32 > Screenshot 2022-12-07 alle 17 41 54 >

It's difficult to debug this without knowing the size of bufferSampleCount, but everything else looks fine.

Try following the stack trace in the debugger. Xcode will show the error on every instruction leading up to where the error actually occurred.

If you can pin it down to happening on a line of code involving NodeOutputView, I also recommend writing an example to demonstrate the bug as Nick mentioned.

Edit: Looking at this with a fresh set of eyes, now I can see how this involves FloatPlot on line 115. Going to see if I can investigate further when I get another chance. Where are the samples coming from? I'm guessing some sort of Node?

JonL-iOS commented 1 year ago

I have experienced this bug as well. I use NodeOutputView, and sometimes it would crash with an error similar to the above.

@emurray2, I saw you asking about buffer size...I noticed that for NodeOutputView, the default buffer is 1024. I had been using a buffer of 150. I'm still testing, but so far It seems that changing the buffer to 1024 has eliminated the crashes.

lucarocchi commented 1 year ago

I don't think buffer size matters i have experienced it also with default buffer size or 2048

emurray2 commented 1 year ago

I don't think buffer size matters i have experienced it also with default buffer size or 2048

What I've noticed when I got this error is the node I was using was not stereo, and I was trying to access a buffer which was not there.

You may want to double check the node format or wherever the data inside FloatPlot is coming from.

But definitely make an example project if you can with 1 node and the FloatPlot demonstrating the bug. You could even try using different nodes and see if you get the same effect.