syedhali / EZAudio

An iOS and macOS audio visualization framework built upon Core Audio useful for anyone doing real-time, low-latency audio processing and visualizations.
Other
4.94k stars 821 forks source link

EZAudioPlotGL crashing with EXC_BAD_ACCESS with glDrawArrays #320

Closed jasper-chan closed 7 years ago

jasper-chan commented 8 years ago

Hello, I've been trying to figure out what is causing this to happen, but I can't seem to figure it out. If I keep instantiating my VC that uses EZAudio libraries, eventually it'll crash with EXC_BAD_ACCESS inside the function:

- (void)redrawWithPoints:(EZAudioPlotGLPoint *)points
              pointCount:(UInt32)pointCount
              baseEffect:(GLKBaseEffect *)baseEffect
      vertexBufferObject:(GLuint)vbo
       vertexArrayBuffer:(GLuint)vab
            interpolated:(BOOL)interpolated
                mirrored:(BOOL)mirrored
                    gain:(float)gain

more specifically, when it tries to call glDrawArrays. I have attached in this post a backtrace of all threads after it has crashed. Any help would be greatly appreciated!

EZAudio.txt

ewanmellor commented 7 years ago

@jasper-chan Did you ever fix this? I have the same backtrace right now. Thanks.

jasper-chan commented 7 years ago

@ewanmellor Yes I did, but I haven't kept up with updates from EZAudio so I wouldn't be able to give a pull request.

There was essentially a problem with the EAGLContext switching. So in EZAudioPlotGL.m instead of just saying

if (!self.context) { self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; }

We changed it to:

if (![EAGLContext currentContext]) { self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; } else { self.context = [EAGLContext currentContext]; }

ewanmellor commented 7 years ago

I decided to switch to EZAudioPlot rather than EZAudioPlotGL, so I'm just ducking the problem. Thanks for the help nonetheless, @jasper-chan.