invalid context 0x0 under iOS 7.0 and system degra

2019-01-02 19:18发布

I've read as many search results I could find on this dreaded problem, unfortunatelly, each one seems to focus on a specific function call.

My problem is that I get the same error from multiple functions, which I am guessing are being called back from functions that I use.

To make matters worse, the actual code is within a custom private framework which is being imported in another project, and as such, debugging isn't as simple?

Can anyone point me to the right direction? I have a feeling I'm calling certain methods wrongly or with bad context, but the output from xcode is not very helpful at this point.

: CGContextSetFillColorWithColor: 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.

: CGContextSetStrokeColorWithColor: 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.

CGContextSaveGState: 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.

: CGContextSetFlatness: 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.

: CGContextAddPath: 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.

: CGContextDrawPath: 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.

: CGContextRestoreGState: 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.

: CGContextGetBlendMode: 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.

Those errors may occur when a custom view is presented, or one of its inherited classes. At which point they spawn multiple times, until the keyboard won't provide any input. Touch events are still registered, but system slows down, and eventually may lead to unallocated object errors.

EDIT #1: I do have access to the framework being imported, but I do not see anything weird in the classes which causing the issue.

EDIT #2: I just received an email that iOS 7.1 has been released for developers. I'm curious to see if this goes away, or become worse, or can be solved.

26条回答
永恒的永恒
2楼-- · 2019-01-02 19:58

In my case i've got these errors in this code:

CAShapeLayer *shapeLayer = [CAShapeLayer layer];
UIBezierPath *path;

path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(0, 0)];
[path addLineToPoint:CGPointMake(size*2, 0)];
[path addLineToPoint:CGPointMake(size, size*2)];
[path closePath];
[path fill];

shapeLayer.path = path.CGPath;
shapeLayer.strokeColor = [[UIColor blackColor] CGColor];
shapeLayer.fillColor = color;
shapeLayer.lineWidth = width;

[self addSublayer:shapeLayer];

after some thoughts and test I detect the problem - it was this call:

[path fill];

as I detect - in my code this call is not necessary, because of filling will be done by other way - so I simply remove it.

查看更多
墨雨无痕
3楼-- · 2019-01-02 19:58

Got this error as I had set

textfield.delegate = self

Without implementing any of the delegate routines. Removing that line solved the problem for me

查看更多
看风景的人
4楼-- · 2019-01-02 20:01

Uninstall the app from simulator and run again

查看更多
何处买醉
5楼-- · 2019-01-02 20:03

I had this same issue and I forgot to import QuartzCore/QuartzCore.h, This solved my issue with these errors.

    #import <QuartzCore/QuartzCore.h>
查看更多
倾城一夜雪
6楼-- · 2019-01-02 20:04

I was getting this error because I was using a UIColor object as an attribute in an NSAttributedString dictionary that was being used in a CATextLayer object. I changed the dictionary to hold a CGColorRef and the error went away.

[wordAttributes setObject:(id)[UIColor whiteColor].CGColor forKey:(NSString*)kCTForegroundColorAttributeName];
查看更多
皆成旧梦
7楼-- · 2019-01-02 20:05

I got the error with the code

UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:pointA];
[path addLineToPoint:pointB];
[path addLineToPoint:pointC];
[[UIColor colorWithHexString:@"EFEFEF"] set];
[path fill];
[path closePath];

CAShapeLayer *triangle = [CAShapeLayer layer];
triangle.fillColor = [UIColor colorWithHexString:@"EFEFEF"].CGColor;
triangle.path = path.CGPath;

return triangle;

and after removed the code

[[UIColor colorWithHexString:@"EFEFEF"] set];
[path fill];

The world became silent

查看更多
登录 后发表回答