Apple Silicon M1 上的 iOS 应用程序崩溃 *** -[_UIRegularOverlayScrollerImp setKnobProportion:]、_UIScrollerImp.m:347 中的断言失败
Crash in iOS App on Apple Silicon M1 *** Assertion failure in -[_UIRegularOverlayScrollerImp setKnobProportion:], _UIScrollerImp.m:347
当我访问我的 iOS 应用 的一个视图控制器时,我收到了一个不熟悉的崩溃日志,该应用是在 [=18= 上作为本机应用 构建的]Apple Silicon M1 Mac.
它在模拟器和 iOS 设备上运行良好。
有人知道这是怎么回事吗?
2020-12-16 23:02:39.680945+0100 MyApp[45300:9651291] [AXRuntimeCommon] Unknown client: MyApp
2020-12-16 23:02:40.336674+0100 MyApp[45300:9651291] *** Assertion failure in -[_UIRegularOverlayScrollerImp setKnobProportion:], _UIScrollerImp.m:347
2020-12-16 23:03:10.902600+0100 MyApp[45300:9651291] [General] Invalid parameter not satisfying: !isnan(newKnobProportion)
2020-12-16 23:03:10.907684+0100 MyApp[45300:9651291] [General] (
0 CoreFoundation 0x00000001912a1320 __exceptionPreprocess + 240
1 libobjc.A.dylib 0x0000000190fcfc04 objc_exception_throw + 60
2 CoreFoundation 0x00000001912cc294 -[NSException description] + 0
3 Foundation 0x0000000192084bb4 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 132
4 UIKitCore 0x00000001b39d4224 -[_UIScrollerImp setKnobProportion:] + 256
5 UIKitCore 0x00000001b39d39c4 __54-[UIScrollView _updateScrollerImpsForcingReplacement:]_block_invoke + 272
6 UIKitCore 0x00000001b39d0eec -[UIScrollView _updateScrollerImpsForcingReplacement:] + 2844
7 UIKitCore 0x00000001b3a32370 -[UIScrollView _willMoveToWindow:] + 200
8 UIKitCore 0x00000001b3953268 _makeSubTreePerformSelector + 456
9 UIKitCore 0x00000001b3952384 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 452
10 UIKitCore 0x00000001b39f2eac -[UINavigationTransitionView transition:fromView:toView:] + 608
11 UIKitCore 0x00000001b39f0614 -[UINavigationController _startTransition:fromViewController:toViewController:] + 2736
12 UIKitCore 0x00000001b39ef430 -[UINavigationController _startDeferredTransitionIfNeeded:] + 880
13 UIKitCore 0x00000001b3a17300 -[UINavigationController __viewWillLayoutSubviews] + 168
14 UIKitCore 0x00000001b39fbee0 -[UILayoutContainerView layoutSubviews] + 228
15 UIKit 0x00000001e0605acc -[UILayoutContainerViewAccessibility layoutSubviews] + 52
16 UIKitCore 0x00000001b39a4130 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2552
17 QuartzCore 0x00000001974b41a0 -[CALayer layoutSublayers] + 372
18 QuartzCore 0x00000001974b3ad0 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 524
19 QuartzCore 0x00000001975d7db0 _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 420
20 QuartzCore 0x0000000197492c6c _ZN2CA11Transaction6commitEv + 732
21 UIKitCore 0x00000001b3905724 _afterCACommitHandler + 144
22 CoreFoundation 0x0000000191222df8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
23 CoreFoundation 0x0000000191222c44 __CFRunLoopDoObservers + 576
24 CoreFoundation 0x0000000191221784 CFRunLoopRunSpecific + 684
25 HIToolbox 0x0000000198d2af0c RunCurrentEventLoopInMode + 292
26 HIToolbox 0x0000000198d2abcc ReceiveNextEventCommon + 320
27 HIToolbox 0x0000000198d2aa6c _BlockUntilNextEventMatchingListInModeWithFilter + 76
28 AppKit 0x00000001939f6db0 _DPSNextEvent + 868
29 AppKit 0x00000001939f5730 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1312
30 AppKit 0x00000001939e758c -[NSApplication run] + 600
31 AppKit 0x00000001939b8d74 NSApplicationMain + 1064
32 AppKit 0x0000000193caa6a8 +[NSWindow _savedFrameFromString:] + 0
33 UIKitMacHelper 0x00000001a3dce388 UINSApplicationMain + 1276
34 UIKitCore 0x00000001b38f2a8c UIApplicationMain + 164
35 MyApp 0x000000010009c468 main + 128
36 libdyld.dylib 0x0000000191144f54 start + 4
)
(lldb)
所以我终于解决了这个问题:
崩溃是由于在具有无效框架(包含 Inf
)的 UIView 上调用 sizeToFit
引起的。
有趣的是,这只发生在为 Apple Silicon 构建时 - “我的 Mac(专为 iPad 设计)”- 目标。
我是这样快速解决的:
if (!CGRectIsEmpty(_infoLabel.frame)) { // this sufficed for me to weed out 'bad' rects
[_infoLabel sizeToFit];
}
当我访问我的 iOS 应用 的一个视图控制器时,我收到了一个不熟悉的崩溃日志,该应用是在 [=18= 上作为本机应用 构建的]Apple Silicon M1 Mac.
它在模拟器和 iOS 设备上运行良好。
有人知道这是怎么回事吗?
2020-12-16 23:02:39.680945+0100 MyApp[45300:9651291] [AXRuntimeCommon] Unknown client: MyApp
2020-12-16 23:02:40.336674+0100 MyApp[45300:9651291] *** Assertion failure in -[_UIRegularOverlayScrollerImp setKnobProportion:], _UIScrollerImp.m:347
2020-12-16 23:03:10.902600+0100 MyApp[45300:9651291] [General] Invalid parameter not satisfying: !isnan(newKnobProportion)
2020-12-16 23:03:10.907684+0100 MyApp[45300:9651291] [General] (
0 CoreFoundation 0x00000001912a1320 __exceptionPreprocess + 240
1 libobjc.A.dylib 0x0000000190fcfc04 objc_exception_throw + 60
2 CoreFoundation 0x00000001912cc294 -[NSException description] + 0
3 Foundation 0x0000000192084bb4 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 132
4 UIKitCore 0x00000001b39d4224 -[_UIScrollerImp setKnobProportion:] + 256
5 UIKitCore 0x00000001b39d39c4 __54-[UIScrollView _updateScrollerImpsForcingReplacement:]_block_invoke + 272
6 UIKitCore 0x00000001b39d0eec -[UIScrollView _updateScrollerImpsForcingReplacement:] + 2844
7 UIKitCore 0x00000001b3a32370 -[UIScrollView _willMoveToWindow:] + 200
8 UIKitCore 0x00000001b3953268 _makeSubTreePerformSelector + 456
9 UIKitCore 0x00000001b3952384 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 452
10 UIKitCore 0x00000001b39f2eac -[UINavigationTransitionView transition:fromView:toView:] + 608
11 UIKitCore 0x00000001b39f0614 -[UINavigationController _startTransition:fromViewController:toViewController:] + 2736
12 UIKitCore 0x00000001b39ef430 -[UINavigationController _startDeferredTransitionIfNeeded:] + 880
13 UIKitCore 0x00000001b3a17300 -[UINavigationController __viewWillLayoutSubviews] + 168
14 UIKitCore 0x00000001b39fbee0 -[UILayoutContainerView layoutSubviews] + 228
15 UIKit 0x00000001e0605acc -[UILayoutContainerViewAccessibility layoutSubviews] + 52
16 UIKitCore 0x00000001b39a4130 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2552
17 QuartzCore 0x00000001974b41a0 -[CALayer layoutSublayers] + 372
18 QuartzCore 0x00000001974b3ad0 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 524
19 QuartzCore 0x00000001975d7db0 _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 420
20 QuartzCore 0x0000000197492c6c _ZN2CA11Transaction6commitEv + 732
21 UIKitCore 0x00000001b3905724 _afterCACommitHandler + 144
22 CoreFoundation 0x0000000191222df8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
23 CoreFoundation 0x0000000191222c44 __CFRunLoopDoObservers + 576
24 CoreFoundation 0x0000000191221784 CFRunLoopRunSpecific + 684
25 HIToolbox 0x0000000198d2af0c RunCurrentEventLoopInMode + 292
26 HIToolbox 0x0000000198d2abcc ReceiveNextEventCommon + 320
27 HIToolbox 0x0000000198d2aa6c _BlockUntilNextEventMatchingListInModeWithFilter + 76
28 AppKit 0x00000001939f6db0 _DPSNextEvent + 868
29 AppKit 0x00000001939f5730 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1312
30 AppKit 0x00000001939e758c -[NSApplication run] + 600
31 AppKit 0x00000001939b8d74 NSApplicationMain + 1064
32 AppKit 0x0000000193caa6a8 +[NSWindow _savedFrameFromString:] + 0
33 UIKitMacHelper 0x00000001a3dce388 UINSApplicationMain + 1276
34 UIKitCore 0x00000001b38f2a8c UIApplicationMain + 164
35 MyApp 0x000000010009c468 main + 128
36 libdyld.dylib 0x0000000191144f54 start + 4
)
(lldb)
所以我终于解决了这个问题:
崩溃是由于在具有无效框架(包含 Inf
)的 UIView 上调用 sizeToFit
引起的。
有趣的是,这只发生在为 Apple Silicon 构建时 - “我的 Mac(专为 iPad 设计)”- 目标。
我是这样快速解决的:
if (!CGRectIsEmpty(_infoLabel.frame)) { // this sufficed for me to weed out 'bad' rects
[_infoLabel sizeToFit];
}