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.
For me, the answer was that I was unnecessarily releasing the graphics context in
drawRect:
. Throwing a symbolic breakpoint on CGPostError pointed me to the culprit.I had this problem in a UITextField when I held the touch over a blank field with just placeholder text. I used the following work-around to eliminate blank fields:
In my case I was having this warning when creating a resible image with cap insets. The problem was that I wasn't leaving at least 1 pixel in the "uncapped" area.
I have the same problem. In my project, i have try to create a textField and add it to my pdf file. Old Code:
After solved this problem,the code changed :
I found the solution at UIColor SetFill doesn't work. And Thanks the helper.
I have had cases where the context returned from
UIGraphicsGetCurrentContext()
isNULL
, and if you try using it for anything this message appears. It is the view's responsibility to push a context usingUIGraphicsPushContext
prior to callingdrawRect:
, if you calldrawRect:
directly instead of[view setNeedsDisplay]
you risk the context not being set yet. My hunch is that prior to iOS 7 the context was pushed for the view oninit
, and now on iOS 7 the context isn't pushed until the first timedrawRect:
is about to be called. I suspect some UIKit code is callingdrawRect:
directly and this is why there are issues with some code even when no custom drawing is being done.Solutions (if doing custom drawing):
drawRect:
directly, use[view setNeedsDisplay]
or if you need immediate drawing use[view.layer draw]
drawRect:
get the context but don't use it outside the body of this if statementif (context) {<do drawing here>}
I was creating UIImage from context using below code:
Thus I was getting the error.
So I removed the Derived Data content, restarted my XCode. And it worked.