Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysterious app crash with OpenGL

I'm using a GPUIImage library for developing an iOS camera app. Sometimes, when the app is suspended after 2-3 minutes the Xcode gives me a crash on the app, pointing to the lines in the method:

- (void)presentBufferForDisplay;
{
    [self.context presentRenderbuffer:GL_RENDERBUFFER];
} 

What might possibly be the reason of this crash? I've got a really long camera set up and the code itself is in the GPUImageContext class. What I might be doing wrong here?

like image 538
Sergey Grischyov Avatar asked Oct 15 '13 10:10

Sergey Grischyov


1 Answers

You can't access OpenGL ES at all when your application is running in the background (suspended). GPUImage uses OpenGL ES for everything it does. You have to make sure that all work your application is doing with GPUImage (filtering video, processing an image) is done before your application completes its transition to the background.

You need to listen for the UIApplicationWillResignActiveNotification or fill out the related delegate callbacks for the transition to the background, and in there pause any camera capture (via the -pauseCameraCapture method on your camera input) or wait for any processing to finish (I believe a synchronous dispatch into the GPUImage serial dispatch queue will take care of this).

Related discussion for this can be found on the GitHub issues page here: https://github.com/BradLarson/GPUImage/issues/197 and in several related issues.

like image 196
Brad Larson Avatar answered Nov 09 '22 11:11

Brad Larson