I am getting exc_bad_access on the line CIContext *context = [CIContext contextWithOptions:nil];
I have enabled zombies and checked with instruments: No luck.
The full code is:
- (UIImage *) doBinarize:(UIImage *)sourceImage withThreshold:(float)threshold {
UIImage *newImage;
if (sourceImage){
CIContext *context = [CIContext contextWithOptions:nil];
CIImage *image = [[CIImage alloc] initWithImage:sourceImage];
CIImage *cImg = [self AdaptiveThresholdFilter:image withThreshold:threshold];
CIImage *ciImage = cImg;
CGImageRef cgImage = [context createCGImage:ciImage fromRect:CGRectMake(0, 0, sourceImage.size.width, sourceImage.size.height)];
newImage = [UIImage imageWithCGImage:cgImage];
CGImageRelease(cgImage);
} else {
return nil;
}
return newImage;
}
However I find almost wherever I put the CIContext contextWithOptions line the app will crash there.
This is on iOS8.1, iPhone 5C. It should be noted that there is no issue on iOS9 or iOS10.
Any suggestions?