'invalid context 0x0' after Migration to iOS 9

Mikhail picture Mikhail · Sep 12, 2015 · Viewed 8.1k times · Source

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?

Answer

Radu Vlad picture Radu Vlad · Sep 14, 2015

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.