Matt54 / AudioVisualizerAK5

11 stars 1 forks source link

Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan nan] #2

Open dsmailes opened 3 years ago

dsmailes commented 3 years ago

I can't seem to track this error down. My guess is perhaps that some aspect of the CALayer position is being initialised before AudioKit is ready to process the volume. Any ideas?

Matt54 commented 3 years ago

Have you altered my code? Does the app have microphone access? I think I saw this before I had audio data being pushed into the view.

I haven't updated this repo in awhile, but I do vaguely remember this issue. I have been furthering this visualizer in the following repo: https://github.com/AudioKit/AudioKitUI

The idea of AudioKitUI is to provide views such as this for the community to be able to use and customize to their liking. The visualizer from my repo here is called FFTView in AudioKitUI.

If you look at FFTView.swift inside the function "updateAmplitudes(_ fftFloats: [Float])" the following lines of code were added:

var fftData = fftFloats for index in 0 ..< fftData.count { if fftData[index].isNaN { fftData[index] = 0.0 } }

I think these may have been what resolved the error you are running into.

dsmailes commented 3 years ago

No alterations. It also doesn't happen every single launch; sometimes everything starts up fine. I'll take a look at the suggestion and see if that fixes it. Thanks.

Edit: that seems to have fixed it. Thanks.