Mysterious app crash with OpenGL

♀尐吖头ヾ 提交于 2019-12-10 13:18:15

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/19379541/mysterious-app-crash-with-opengl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!