我编写了一个模糊图像的功能,但是100个用户中有1个遇到了这种崩溃。我无法复制它,也无法调试它。
这是崩溃日志:
Thread : Crashed: com.apple.root.background-qos
0 libGPUSupportMercury.dylib 0x296fb8fe gpus_ReturnNotPermittedKillClient
1 libGPUSupportMercury.dylib 0x296fc3cb gpusSubmitDataBuffers
2 libGPUSupportMercury.dylib 0x296fc249 gldCreateContext
3 GLEngine 0x252ff93b gliCreateContextWithShared
4 OpenGLES 0x253dbab3 -[EAGLContext initWithAPI:properties:] + 406
5 CoreImage 0x2303ba8b ___ZN2CI11can_use_gpuEv_block_invoke + 142
6 libdispatch.dylib 0x307107a7 _dispatch_client_callout + 22
7 libdispatch.dylib 0x307113eb dispatch_once_f + 62
8 CoreImage 0x2303b9fb CI::can_use_gpu() + 98
9 CoreImage 0x22fb9b79 +[CIContext contextWithOptions:] + 188
10 Test 0x0016121b
-[NewRestaurantViewController blur:]
12 libdispatch.dylib 0x307107bb _dispatch_call_block_and_release + 10
13 libdispatch.dylib 0x30719dab _dispatch_root_queue_drain + 866
14 libdispatch.dylib 0x3071acd7 _dispatch_worker_thread3 + 94
15 libsystem_pthread.dylib 0x30871e31 _pthread_wqthread + 668
以下是我的模糊功能:
- (UIImage *)blur:(UIImage*)theImage{
if(theImage == nil){
return theImage;
}
// create our blurred image
CIContext *context = [CIContext contextWithOptions:nil];
CIImage *inputImage = [CIImage imageWithCGImage:theImage.CGImage];
// setting up Gaussian Blur (we could use one of many filters offered by Core Image)
CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"];
[filter setDefaults];
[filter setValue:inputImage forKey:@"inputImage"];
[filter setValue:[NSNumber numberWithFloat:10.0f] forKey:@"inputRadius"];
CIImage *result = [filter valueForKey:@"outputImage"];
// CIGaussianBlur has a tendency to shrink the image a little,
// this ensures it matches up exactly to the bounds of our original image
CGImageRef cgImage = [context createCGImage:result fromRect:[inputImage extent]];
UIImage *returnImage = [UIImage imageWithCGImage:cgImage];//create a UIImage for this function to "return" so that ARC can manage the memory of the blur... ARC can't manage CGImageRefs so we need to release it before this function "returns" and ends.
CGImageRelease(cgImage);//release CGImageRef because ARC doesn't manage this on its own.
return returnImage;
}
答案 0 :(得分:6)
在实例化EAGLContext
CIContext
的当前上下文设置为nil
[EAGLContext setCurrentContext:nil];
CIContext *context = [CIContext contextWithOptions:nil];
CIImage *inputImage = [CIImage imageWithCGImage:theImage.CGImage];