EXC_BAD_ACCESS when creating CIContext on iOS8.1 but not 9 or 10
Asked Answered
V

0

8

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?

Vise answered 20/7, 2016 at 17:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.