I have very large graphic Mac app and now I receive a lot of the following messages in Console on 10.9 GM.
<Error>: Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API. This is a serious error and contributes 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.
I noticed that these messages appear in debugger after calling [NSApp nextEventMatchingMask: untilDate inMode: dequeue] but I think the reasons are in some other places. But I have too many places where I use Cocoa Graphics. I didn't receive this kind of message before 10.9.
How to detect where NaN is passing to CoreGraphics API?
I was getting this error when I was foolishly retaining an NSPopover for future use.
It seems
popover.showRelativeToRect(_:)
is all you need to do, and then you can forget about it.so you should get an exception at that point, so an exception breakpoint should work...
here are things to look out for...
you may have messed up a method signature... ie
gets messed up in a subclass
or you have some bad math(s) that emit a NaN...
there are a couple of ways to detect a NaN... c99 introduced
isnan()
also the ieee float trick of
(f != f)
will be true for NaNI found the problem. It's dividing by zero at some point that leads to NSAffineTransform with NaN elements in the matrix. For some reasons compiler and OS passed this situation before 10.9.
After much digging around, I've found you can set a symbolic breakpoint on "CGPostError" in Xcode, and that will give you a stack trace.