In my project I'm getting a lot of crashes for
CALayerInvalidGeometry; CALayer bounds contains NaN:
but I am not able to reproduce the crash and only pick it up in Fabric so it's not possible to share the code here as I can't upload my entire project.
From Fabric I get the following message.
Heads Up! CALayerInvalidGeometry; CALayer bounds contains NaN: [...] Details: This crash is likely due to a division by zero when applying a transform to a view or layer. Setting the 'CG_NUMERICS_SHOW_BACKTRACE' environment variable in Xcode can help pinpoint the root cause. Check out the references below for more details.
What exactly does setting CG_NUMERICS_SHOW_BACKTRACE to YES do?
What can I search for in my project as likely causes of it? Is it enough to just search for all CGRect in the projects?
How could I create this crash in a test app?
I tried the following to reproduce it
var bounds: CGRect = CGRect(x: 0, y: 0, width: 0, height: 0)
let int = apiToken != nil ? 0 : 5
bounds.size = CGSize(width: 5/int, height: 5)
self.bounds = bounds
but just got a division by zero error.
Here is the stack trace.
Fatal Exception: CALayerInvalidGeometry
0 CoreFoundation 0x1856b7d38 __exceptionPreprocess
1 libobjc.A.dylib 0x184bcc528 objc_exception_throw
2 CoreFoundation 0x1856b7c80 -[NSException initWithCoder:]
3 QuartzCore 0x18969d8ac CA::Layer::set_bounds(CA::Rect const&, bool)
4 QuartzCore 0x18968f730 -[CALayer setBounds:]
5 UIKit 0x18f1ee7ec __27-[_UILabelLayer setBounds:]_block_invoke
6 UIKit 0x18f1ee588 -[_UILabelLayer _setFrameOrBounds:settingAction:]
7 UIKit 0x18f1ee798 -[_UILabelLayer setBounds:]
8 QuartzCore 0x18968fe28 -[CALayer setFrame:]
9 UIKit 0x18f1ee6fc __26-[_UILabelLayer setFrame:]_block_invoke
10 UIKit 0x18f1ee588 -[_UILabelLayer _setFrameOrBounds:settingAction:]
11 UIKit 0x18f1ee6a8 -[_UILabelLayer setFrame:]
12 UIKit 0x18eac0818 -[UIView(Geometry) setFrame:]
13 UIKit 0x18eacfd54 -[UILabel setFrame:]
14 UIKit 0x18f64cacc -[_UITAMICAdaptorView layoutSubviews]
15 UIKit 0x18eac4000 -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
16 QuartzCore 0x1896950b4 -[CALayer layoutSublayers]
17 QuartzCore 0x189699194 CA::Layer::layout_if_needed(CA::Transaction*)
18 QuartzCore 0x189607f24 CA::Context::commit_transaction(CA::Transaction*)
19 QuartzCore 0x18962e340 CA::Transaction::commit()
20 QuartzCore 0x18962f180 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*)
21 CoreFoundation 0x18565f8b8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
22 CoreFoundation 0x18565d270 __CFRunLoopDoObservers
23 CoreFoundation 0x18565d82c __CFRunLoopRun
24 CoreFoundation 0x18557e2d8 CFRunLoopRunSpecific
25 GraphicsServices 0x18740ff84 GSEventRunModal
26 UIKit 0x18eb2a880 UIApplicationMain
27 ProjectName 0x1001efe98 main (AppDelegate.swift:21)
28 libdyld.dylib 0x1850a256c start