ios - 当应用程序在后台时防止 GPU 访问 Core Image 的正确方法

标签 ios core-image

我遇到了来自客户的崩溃,回溯如下:

0   libGPUSupportMercury.dylib          0x3542ae2e gpus_ReturnNotPermittedKillClient + 10
1   IMGSGX543RC2GLDriver                0x30bbf5e5 SubmitPacketsIfAny + 245
2   GLEngine                            0x32f827db glFinish_Exec + 167
3   CoreImage                           0x31fb85b7 CI::GLESContext::recursive_render(CI::Node const*, CGRect, bool) + 219
4   CoreImage                           0x31fbb351 CI::GLESContext::render(CI::Node*,     CGRect) + 41
5   CoreImage                           0x31fc2901 CI::image_get_cgimage(CI::Context*, CI::Image*, CGRect, CGColorSpace*, CI::PixelFormat) + 1313
6   CoreImage                           0x31fa8427 -[CIContext createCGImage:fromRect:format:colorSpace:] + 487
7   CoreImage                           0x31fa81e9 -[CIContext createCGImage:fromRect:] + 89
8   App                                 0x0013c9db -[PZTiledImageLayer drawInContext:] (PZTiledImageLayer.m:129)

这是由于应用程序在后台时访问 GPU(不允许)。

导致这次崩溃的代码是这样的:

if([UIApplication sharedApplication].applicationState == UIApplicationStateActive)
{
    cg_image = [self.imageContext createCGImage:im fromRect:rclip];
}

这意味着应用在我检查之后更改状态,但在 GPU 在 Core Image API 中访问之前。

使用此 Core Image API 时,应用程序后台状态的正确处理方式是什么?

最佳答案

如果这是在后台线程上发生的,您可以尝试将其移至主线程。这样这个函数的执行就不会与 AppDelegate 回调交织

- (void)applicationDidEnterBackground:(UIApplication *)application

你可以在那里实现一些信号而不用担心并发。

关于ios - 当应用程序在后台时防止 GPU 访问 Core Image 的正确方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17782492/

相关文章:

iphone - 如何将没有标签栏的普通 UIViewController 转换为有标签栏的 UIViewController

iOS 相机面部追踪 (Swift 3 Xcode 8)

objective-c - 如何在 CIImage 上画线/弧?

ios - Swift iOS 实时对视频应用滤镜?

avfoundation - 使 CIContext.render(CIImage, CVPixelBuffer) 与 AVAssetWriter 一起工作

ios - 具有自定义 Metal 内核的核心图像过滤器不起作用

ios - Swift 中具有/不同单元格类型的可重用数据源

ios - 调整UITextView的大小不遵守约束

ios - 如何减少 iOS 应用程序的 Core ML 模型?

ios - 使用嵌套上下文时如何自动设置核心数据关系