2015-02-09 60 views
0

我得到這個錯誤BSXPCMessage received error for message: Connection interrupted顯示出來,只要我爲圖像創建一個我將允許用戶編輯。但是,雖然接受的答案(https://stackoverflow.com/a/26268910/2939977)確實可以消除錯誤消息,但它將CPU使用率激增至不可用的級別,並導致UI變得非常不連貫(一旦kCIContextUseSoftwareRenderer標誌被設置爲YES,CPU使用率從50%到大約150%),因爲我的過濾器連接到滑塊並且性能至關重要。CIContext和iOS8中的BSXPCMessage錯誤錯誤

我試過以下apple documentation here創建一個EAGL context來創建我的CIContext,我將顏色空間設置爲null

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卻發現了其他一些問題,當它來到的圖像縮放,導致我刪除它,然後往下走CIFilter路線。

任何建議或幫助,將不勝感激:)

+0

試試這個,http://stackoverflow.com/a/32578781/3411787 – 2015-09-15 06:05:36

回答

0

如果你要創建一個CIContext有:

[CIContext contextWithEAGLContext:options:] 

,那麼你應該使用直接繪製成背景:

[cictx drawImage:inRect:fromRect:] 

這將比創建CGImageRef並將其傳遞給UIImageView快得多。

+0

感謝您的提示大衛...什麼是採取CIContext並顯示給用戶(當前查看UIImage)的最佳方式他們正在使用滑塊?看起來大多數情況是通過CGImage將其推入UIImage。有沒有更高效的方法? – 2015-02-10 04:37:39

+0

請參閱https://developer.apple.com/library/ios/samplecode/CIFunHouse/Introduction/Intro.html – 2015-02-10 21:27:32