1

Problem: I present a UIAlertController and get a whole slew of CGContext-related error messages in the console. There are three errors that each repeat 15 - 20 times so it looks like the console blew up! These error messages only occur when triggering the Alert in some places in my app - not in others. In all cases, the UIAlertController still displays just fine despite the error warnings. I'm not doing any custom drawing/animation. Nowhere in my code do I use anything to do with CGContext.

I'm using XCode 6.4 and iOS 8. This happens in the simulator and on device (iPad)

Any thoughts on what's causing the error messages and why it would happen in only certain sections of my app?

I looked at these posts but no luck:

invalid context 0x0 under iOS 7.0 and system degradation

CGContext invalid context 0x0

I also tried setting a CGPostError symbolic breakpoint but it just shows me assembly language - nothing useful.

Here are the three CGContext errors that get repeated upon each presentation of UIAlertController:

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

Error: clip: 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.`

Error: CGContextDrawLinearGradient: 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.`

Code used to present UIAlertController. self is a UIViewController. This could be triggered from a button press, or selecting a tableview cell, etc.:

let alert = UIAlertController(title: "TEST", message: "test", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Cancel, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
Community
  • 1
  • 1
paka
  • 143
  • 1
  • 1
  • 6
  • In your code, what is the type of self? Also, you need to update to XCode 7 – 72A12F4E Oct 19 '15 at 21:57
  • self is a UIViewController. one of many since I present alerts in several different places. Had some problems updating to XCode 7 - need to try again I know – paka Oct 19 '15 at 22:07

1 Answers1

0

These errors seem to have stopped once I upgraded to the latest XCode (7.2).

paka
  • 143
  • 1
  • 1
  • 6
  • Not on my XCode. I'm getting the same error and after the error my app becomes strange behavior. – Kingalione Apr 06 '16 at 12:40
  • I was mistaken. Even after updating XCode and Swift, I am still seeing these errors from time to time. They seem to always be triggered when presenting a UIAlertController. Why???? – paka Apr 08 '16 at 16:35