CG_NUMERICS_SHOW_BACKTRACE究竟做了什么

时间:2018-03-14 11:07:17

标签: ios swift uilabel calayer cgrect

在我的项目中,我遇到了很多崩溃

  

CALayerInvalidGeometry; CALayer界限包含NaN:

但是我无法重现崩溃,只能在Fabric中选择它,因此无法在此处共享代码,因为我无法上传整个项目。

从Fabric我收到以下消息。

  

抬头! CALayerInvalidGeometry; CALayer界限包含NaN:[...]   详细信息:此崩溃可能是由于应用时除以零   转换为视图或图层。设置   Xcode中的'CG_NUMERICS_SHOW_BACKTRACE'环境变量可以提供帮助   找出根本原因。查看以下参考资料以获取更多信息   的信息。

将CG_NUMERICS_SHOW_BACKTRACE设置为YES究竟做了什么?

我可以在项目中搜索哪些可能的原因?只搜索项目中的所有CGRect就足够了吗?

如何在测试应用中创建此崩溃?

我尝试了以下内容来重现它

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

但是只有零误差得分。

这是堆栈跟踪。

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

0 个答案:

没有答案