21

I've migrated the app to iOS 9, and it works as usually, but there three log messages:

<Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
<Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
<Error>: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.

Maybe helps that the next message from Crashlytics is:

[Crashlytics:Crash] Warning: iOS 9 workaround for binary image loading issue in place.

Does anybody know how to fix it?

Mikhail
  • 1,061
  • 2
  • 13
  • 30

2 Answers2

20

This happens when there is a definition of UIViewControllerBasedStatusBarAppearance with false in info.plist.

If you don't need this you can set the key <key>UIViewControllerBasedStatusBarAppearance</key> to true in the file manually or change View controller-based status bar appearance option from Info to YES.

Also, I saw some posts that state there is no problem with this. As far as I know there's no way to set UIViewControllerBasedStatusBarAppearance from code, so I guess we'll have to wait until Apple will fix this issue. You can find more here.

Later Edit: It seems that iOS 9.1 solves this encountered errors. From last stable Xcode, running on iOS 9.1 result in no errors, while 9.0 still has the problems above.

Radu Vlad
  • 1,474
  • 2
  • 21
  • 37
  • Hmm... tried this fix and it hides the error but it still throws an exception. – denvdancsk Sep 29 '15 at 16:08
  • Are you sure the exception is caused by this issue? Can you give more details? – Radu Vlad Sep 30 '15 at 07:53
  • 1
    [might help](http://stackoverflow.com/a/31887785/3577656) and in about mentioned of apple developer, apple staff have said this warning can be avoided for now and is known issue. – Rajal Oct 05 '15 at 09:32
5

Apple has stated you can safely ignore these messages ': CGContextSaveGState: invalid context 0x0. "

Check the various Apple dev forums or support areas.

scottdev
  • 141
  • 2
  • 1
    Yes, you are right, but I think, it is not the best solution. If I can do smth to remove these messages, I prefer to do it. – Mikhail Sep 13 '15 at 09:14