How to detect where NaN is passing to CoreGraphics API on Mac OS X 10.9

前端 未结 5 576
一个人的身影
一个人的身影 2021-01-31 08:04

I have very large graphic Mac app and now I receive a lot of the following messages in Console on 10.9 GM.

: Error: this application, or a library i         


        
相关标签:
5条回答
  • 2021-01-31 08:26

    The habit of creating lazy UIView's with a .zero frame played against me when doing it for a PDFView.

    This

    var pdfView = PDFView(frame: .zero)
    

    will generate lots of the same logs from the question. The reason I used .zero, is because later I set up the view with constraints. This proved to be a problem. The solution was to use an arbitrary, non-zero frame when initializing the PDFView.

    var pdfView = PDFView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
    

    Now the issue is gone.

    0 讨论(0)
  • 2021-01-31 08:38

    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.

    0 讨论(0)
  • 2021-01-31 08:51

    I 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.

    0 讨论(0)
  • 2021-01-31 08:51

    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

    -(float)myHeight
    {
        return 56.0;
    }
    

    gets messed up in a subclass

    -(int)myHeight
    {
        return 42;
    }
    

    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 NaN

    0 讨论(0)
  • 2021-01-31 08:53

    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.

    0 讨论(0)
提交回复
热议问题