ios – CIContext坏访问崩溃

ios – CIContext坏访问崩溃,第1张

概述我写了一个模糊图像的功能,但是100个用户中有1个遇到了这种崩溃.我无法复制它,无法调试它. 这是崩溃日志: Thread : Crashed: com.apple.root.background-qos0 libGPUSupportMercury.dylib 0x296fb8fe gpus_ReturnNotPermittedKillClient 1 libGPUSupport 我写了一个模糊图像的功能,但是100个用户中有1个遇到了这种崩溃.我无法复制它,无法调试它.

这是崩溃日志:

Thread : Crashed: com.apple.root.background-qos0  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;   }
解决方法 在实例化CIContext之前,尝试将EAGLContext的当前上下文设置为nil

[EAGLContext setCurrentContext:nil];CIContext *context = [CIContext contextWithOptions:nil];CIImage *inputimage = [CIImage imageWithCGImage:theImage.CGImage];
总结

以上是内存溢出为你收集整理的ios – CIContext坏访问崩溃全部内容,希望文章能够帮你解决ios – CIContext坏访问崩溃所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1060909.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-25
下一篇2022-05-25

发表评论

登录后才能评论

评论列表(0条)

    保存