当app在后台时,使用Core Image阻止GPU访问的正确方法

rse*_*bbe 5 core-image ios

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

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)
Run Code Online (Sandbox Code Playgroud)

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

导致此崩溃的代码是:

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

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

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

rob*_*e_c 0

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

- (void)applicationDidEnterBackground:(UIApplication *)application
Run Code Online (Sandbox Code Playgroud)

您可以在那里实现一些信号,而不必担心并发性。