IOS 8 error 0x0 invalid CGContext lot

My application unexpectedly got a lot of errors like this:

<Error>: CGContextSetInterpolationQuality: invalid context 0x0. This is a serious error. 
This application, or a library it uses, is using an invalid context  and is thereby contributing  
to an overall degradation of system stability and reliability. This notice is a courtesy: please  
fix this problem. It will become a fatal error in an upcoming update.

      

etc. for CGContextDrawImage, CGBitmapContextCreateImage, etc.

I'm clearly doing something serious, but I'm not sure what. I am using the below code which I adapted for someone else for my application. It basically resizes the image to fit the device.

The code seems to be working fine and my application is doing what is expected, but I'm not sure what is causing the errors, which seem to be quite serious. Can anyone see something obvious in my code that might be causing these errors?

-(UIImage *)resizeImage:(NSString *)imageName {

    UIImage *originalImage = [UIImage imageNamed:imageName];
    CGRect newRect = CGRectIntegral(CGRectMake(0, 0, originalImage.size.width * myScalingFactor, originalImage.size.height * myScalingFactor));
    CGImageRef imageRef = originalImage.CGImage;
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();

    CGContextRef bitmap = CGBitmapContextCreate(
                                                NULL,
                                                newRect.size.width,
                                                newRect.size.height,
                                                8,
                                                (newRect.size.width * 4),
                                                colorSpace,
                                                kCGImageAlphaPremultipliedLast
                                                );

    CGColorSpaceRelease(colorSpace);
    CGContextSetInterpolationQuality(bitmap, 3);
    CGContextDrawImage(bitmap, newRect, imageRef);
    CGImageRef newImageRef = CGBitmapContextCreateImage(bitmap);
    UIImage *newImage = [UIImage imageWithCGImage:newImageRef];
    CGContextRelease(bitmap);
    CGImageRelease(newImageRef);

    return newImage;
}

      

+3


source to share


2 answers


CGContextSetInterpolationQuality: invalid context 0x0.

means that the parameter context

passed to CGContextSetInterpolationQuality

was a null pointer (hence memory address 0x0).



To avoid this, you must check if it returns CGBitmapContextCreate

NULL

. This can happen if you specified an invalid width / height (or zero).

+11


source


Edit. Aug 2017
This is probably no good advice. I don't delete it for the sake of posterity. I can't remember the circumstances that this happened, so it's hardly worth it.


This is a mistake I just learned to ignore.
It is quite difficult to make it serious when even iOS suffers from this error a lot. If you plug your device into your Mac and look at the debug console, you will see that Springboard is also logging these errors all the time. In the screenshot below, I was just changing the brightness of the screen, which sent the device's console to overdrive. enter image description here



Unfortunately this clutters up the console when debugging, but according to this thread, this is an iOS issue and can be ignored.

Edit
I'm not sure why I keep giving in for this answer. I have cited my source which shows that Apple explicitly admits that this is an OS issue. If anyone else feels the need to downgrade, please tell me where I went wrong. Greetings.enter image description here

-2


source







All Articles