神秘的应用程序崩溃与OpenGL [英] Mysterious app crash with OpenGL

查看:954
本文介绍了神秘的应用程序崩溃与OpenGL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 GPUIImage 库开发iOS相机应用程式。有时,当应用程序在2-3分钟后暂停时,Xcode会在应用程序上指向该方法中的行:

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];
} 

这可能是什么原因导致此崩溃?我有一个很长的相机设置,代码本身是在 GPUImageContext 类。

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?

推荐答案

当应用程序在后台运行时,您根本无法访问OpenGL ES (暂停)。 GPUImage使用OpenGL ES为它做的一切。您必须确保您的应用程序正在使用GPUImage(过滤视频,处理图片)的所有工作都将在您的应用程序完成向后台转换之前完成。

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.

需要监听UIApplicationWillResignActiveNotification或填写相关的委托回调,以便转换到后台,并在其中暂停任何相机捕获(通过相机输入上的 -pauseCameraCapture 方法) )或等待任何处理完成(我相信一个同步分派到GPUImage串行调度队列将照顾这一点)。

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).

相关讨论可以在GitHub问题页面: https://github.com/BradLarson/GPUImage/issues/197 和几个相关问题。

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.

这篇关于神秘的应用程序崩溃与OpenGL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆