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.
I got it when I mistyped the image name in activityImage method in UIActivity subclass
Typing the right image solved it for me.
make sure the size.width or size.height is not 0,
you can add symbol breakpoint to CGPostError to check
I got this error in the drawInContext(..) method of my custom CALayer implementation. UIBezierPath tries to use the UIGraphicsGetCurrentContext() which is nil by default in a custom layer. The online documentation explains this very clearly -
Here's the code that finally worked with my comments inline (Swift code, but the solution is the same regardless)
Like others whom have commented here I was getting this warning when I did any of the following:
On a blank text field: Double tapping, touch and hold, long single tap.
This seems to only affect iOS 7.0.3
I discovered a work around, the warning will not be triggered if your pasteboard is not NULL.
So I did the following in textFieldDidBeginEditing:
I tested this out in simulator for iOS 7.0.3 on the iphone 4s, 5 and 5s and no longer receive the warning. I also tested this out in simulator for iOS 8 on the iphone 6 and 6 plus but I don't believe iOS 8 is affected.
Went through two days of frustration before discovering this work around so I really hope my answer helps those of you who are having the same issue.
This is hacky but it worked for me.
I set up the
UIImageView
in theUITableViewCell
'sinit
, give it a size and constraints.Then in my view controller's
cellForRowAtIndexPath
I do this:And that avoids the error, then below that in the function I set the actual image for that
UIImageView
. The code above is a good defaultOthers will ask you to post the code where you access a core graphics context, but I doubt that's the issue. These invalid context 0x0 error messages are common and easy to reproduce in iOS 7. In fact, I can reproduce the error using storyboard with zero code. I drag a UITextField onto the canvas in IB, run the app, and double tap inside the text field.
In many situations, it's hard for me to take the invalid context 0x0 error messages seriously. I don't know if your situation warrants greater concern (I agree with Rob Napier that it's worth investigating, especially if you are explicitly using a graphics context).
In my own projects, I'm hoping that many of these errors magically disappear some day (but that day did not come with 7.0.3).
Update: After installing Xcode 5.1 and targeting iOS 7.1, I can no longer reproduce the error by double tapping inside an empty text field.