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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With