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.
These sorts of errors are historically the result of calling Core Graphics functions when not within a context that is established within
drawRect
or between calls likeUIGraphicsBeginImageContext
andUIGraphicsEndImageContext
(or other UIKit functions like that which begin and end a context).Having said that, though, bilobatum is correct that this particular sequence of errors can be a result of that iOS 7 bug he references in his answer. If not seeing these errors in your iOS6 targets, or if after a quick scan of this private framework you don't find any suspect Core Graphics calls, it may just be this iOS 7 bug. Good catch, bilobatum!
For me I was getting this error because I was releasing the the CGContextRef as shown below:
Removing the release solved the issue
Straight Answer : The problem is because you have used Core graphics elements like CGContext etc in other than
- (void)drawRect:(CGRect)rect
this method.Now kindly move your code to this method. And it will strop giving you warnings/Errors.
If the error occurs when you are using UIBezierPath and set color for stroke or fill, put the set color code in drawRect function rather than other places.
In some cases you may need to include the line
#import <QuartzCore/QuartzCore.h>
.Turning off autolayout in the affected view causes this error to go away in some cases where you're placing and moving UI elements (especially custom ones which are drawn programmatically) within a view. I was using JVFloatLabeledTextField when I discovered this symptom.