【发布时间】:2015-04-09 12:51:21
【问题描述】:
每当我为要允许用户编辑的图像创建CIContext 时,都会出现此错误BSXPCMessage received error for message: Connection interrupted。这个错误可以在像这样的其他 stackoverflow 问题上找到 - BSXPCMessage received error for message: Connection interrupted on CIContext with iOS 8
然而,虽然接受的答案 (https://stackoverflow.com/a/26268910/2939977) 确实可以消除错误消息,但它会使 CPU 使用率飙升到无法使用的水平,并使 UI 变得非常不稳定(一旦@987654327,CPU 使用率从 50% 上升到大约 150% @ 标志设置为 YES),因为我的过滤器附加到滑块并且性能至关重要。
我尝试按照apple documentation here 创建一个EAGL context 来创建我将颜色空间设置为null 的CIContext。
EAGLContext *myEAGLContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
NSDictionary *options = @{ kCIContextWorkingColorSpace : [NSNull null] };
imageContext = [CIContext contextWithEAGLContext:myEAGLContext options:options];
这会创建没有错误消息的过滤器,并且性能要好得多万岁!但是,一旦用户使用编辑选项来调整图像,我就会在第一次调整时得到BSXPCMessage received error for message: Connection interrupted。我再也没有看到错误消息,它似乎根本不影响输出。
[filter setValue:@(contrast) forKey:@"inputContrast"];
[filter setValue:@(color) forKey:@"inputSaturation"];
CIImage *outputImage = [filter outputImage];
CGImageRef cgimg = [imageContext createCGImage:outputImage fromRect:[outputImage extent]];
UIImage *newImage = [UIImage imageWithCGImage:cgimg scale:1 orientation:UIImageOrientationRight];
transitionImage.image = newImage;
CGImageRelease(cgimg);
如果您想知道我确实从 GPUImage 开始,因为在滑块上使用过滤器时性能更好,但发现它在图像缩放方面存在一些其他问题,导致我将其删除并向下移动 @987654335 @路线。
任何建议或帮助将不胜感激:)
【问题讨论】: