3

I've seen this problem around but no one seems to have a general solution, at to mine. My 3 errors go as

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

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

My app still runs and works perfectly fine. But i want to know if i should be concerned or worried about this.

FYI, im running Xcode 5.0.1 and the app is set for iOS 7. My libraries on the viewcontroller that causes the errors to pop-up are:

In the .h
#import <UIKit/UIKit.h>
#import "Event.h"
#import <MessageUI/MessageUI.h>
#import <EventKit/EventKit.h>
#import <EventKitUI/EventKitUI.h>

In the .m
#import "EventDetailsViewController.h"
#import "XMLReader.h"
#import <Twitter/Twitter.h>
#import "AppDelegate.h"
#import "FBShareViewController.h"
#import <MapKit/MapKit.h>

Thanks

G_Money
  • 318
  • 7
  • 22
  • You need to do some debugging to find out what you're trying to draw before a context exists for you to draw into. – Wain Nov 08 '13 at 20:14
  • 2
    See http://stackoverflow.com/questions/19599266/invalid-context-0x0-under-ios-7-0-and-system-degradation. Bottom line, there is a known iOS7 issue that causes this. If you're not seeing this under iOS6, then that may be the problem. Otherwise, it can be result from Core Graphics functions when not within a context that is established within `drawRect` or between calls that begin/end context, such as `UIGraphicsBeginImageContext` and `UIGraphicsEndImageContext`. – Rob Nov 08 '13 at 20:40

2 Answers2

1

If you are trying to get a UIImage from a UIView, make sure your UIView has a proper frame set. It shouldn't be 0 in height or in width.

AndroC
  • 4,758
  • 2
  • 46
  • 69
0

Taking @Rob advice, I went and looked for any methods like that, and sadly enough, I had a drawRect method being called. I commented it out, ran the code, and viola, ran without any errors. Looks like it doesn't create a new context on the fly or is something that has to be taken care of on our end.

Dustin.php
  • 11
  • 6
G_Money
  • 318
  • 7
  • 22