I’m having a crash happens when reloadData() gets called in a custom SelfSizedTableView ,
any idea why? and how to resolve it?
SelfSizedTableView:
import UIKit
open class SelfSizedTableView: UITableView {
open override func reloadData() {
super.reloadData()
self.invalidateIntrinsicContentSize()
self.layoutIfNeeded()
}
open override var intrinsicContentSize: CGSize {
setNeedsLayout()
layoutIfNeeded()
return CGSize(
width: contentSize.width,
height: contentSize.height
)
}
}
Stacktrace:
Crashed: com.apple.main-thread
0 CoreAutoLayout 0x17d38 object_table_insert_and_return_old_value_if_replaced + 96
1 CoreAutoLayout 0x8324 NSISObjectTableInsert + 72
2 CoreAutoLayout 0x80b0 -[NSISEngine startObservingChangesForVariable:] + 76
3 UIKitCore 0x373e2c _UILayoutItemSetUpVariableObservation + 144
4 UIKitCore 0x2aae18 _UILayoutItemCreateAndObserveVariableWithValueRestriction + 104
5 UIKitCore 0x518fc4 -[UIView nsli_boundsWidthVariable] + 48
6 UIKitCore 0x34b7e8 -[UIView(AdditionalLayoutSupport) nsli_lowerAttribute:intoExpression:withCoefficient:forConstraint:onBehalfOfLayoutGuide:] + 2860
7 UIKitCore 0x566e50 -[UIView(AdditionalLayoutSupport) nsli_lowerAttribute:intoExpression:withCoefficient:forConstraint:] + 316
8 CoreAutoLayout 0xbb50 -[NSLayoutConstraint _lowerIntoExpression:reportingConstantIsRounded:] + 76
9 CoreAutoLayout 0xdee8 -[NSLayoutConstraint _addToEngine:mutuallyExclusiveConstraints:] + 136
10 UIKitCore 0x1cd270 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 368
11 CoreAutoLayout 0x7bac -[NSISEngine withBehaviors:performModifications:] + 80
12 UIKitCore 0x1badd0 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 528
13 UIKitCore 0x3980f4 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 188
14 UIKitCore 0x1cd1b8 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 184
15 CoreAutoLayout 0x7bac -[NSISEngine withBehaviors:performModifications:] + 80
16 UIKitCore 0x1badd0 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 528
17 UIKitCore 0x3980f4 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 188
18 UIKitCore 0x1cd1b8 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 184
19 CoreAutoLayout 0x7bac -[NSISEngine withBehaviors:performModifications:] + 80
20 UIKitCore 0x1badd0 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 528
21 UIKitCore 0x3980f4 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 188
22 UIKitCore 0x45ae68 -[UIView(AdditionalLayoutSupport) _initializeHostedLayoutEngine] + 208
23 UIKitCore 0x1da868 -[UIView _layoutEngine_windowDidChange] + 120
24 UIKitCore 0x29ebbc -[UIView(Internal) _didMoveFromWindow:toWindow:] + 276
25 UIKitCore 0x29ee48 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 928
26 UIKitCore 0x1cb998 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 136
27 CoreAutoLayout 0x7bac -[NSISEngine withBehaviors:performModifications:] + 80
28 UIKitCore 0x2576e4 -[UIView(Hierarchy) _postMovedFromSuperview:] + 780
29 UIKitCore 0x179ca4 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 2148
30 UIKitCore 0x38ec30 -[UITableView _addSubview:positioned:relativeTo:] + 104
31 UIKitCore 0x168d68 -[UIScrollView _addContentSubview:atBack:] + 376
32 UIKitCore 0x18d4e8 -[UITableView _addContentSubview:atBack:] + 248
33 UIKitCore 0x189e70 __53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke + 1744
34 UIKitCore 0x1632d0 +[UIView(Animation) performWithoutAnimation:] + 96
35 UIKitCore 0x3f4664 -[UITableView _configureCellForDisplay:forIndexPath:] + 244
36 UIKitCore 0x27010c -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 1916
37 UIKitCore 0x45a858 -[UITableView _updateVisibleCellsForRanges:createIfNecessary:] + 700
38 UIKitCore 0x293f04 -[UITableView _updateVisibleCellsNow:] + 1464
39 UIKitCore 0x16c484 -[UITableView layoutSubviews] + 436
40 UIKitCore 0x17c1d0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2556
41 QuartzCore 0x3d520 CA::Layer::layout_if_needed(CA::Transaction*) + 528
42 UIKitCore 0x1dd8b0 -[UIView(Hierarchy) layoutBelowIfNeeded] + 556
43 Drops 0x78e68 SelfSizedTableView.reloadData() + 15 (SelfSizedTableView.swift:15)
44 Drops 0x78eb8 #objc SelfSizedTableView.reloadData() + 4365668024 (<compiler-generated>:4365668024)
45 UIKitCore 0x16c300 -[UITableView layoutSubviews] + 48
46 UIKitCore 0x17c1d0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2556
47 QuartzCore 0x3d520 CA::Layer::layout_if_needed(CA::Transaction*) + 528
48 UIKitCore 0x1dd8b0 -[UIView(Hierarchy) layoutBelowIfNeeded] + 556
49 Drops 0x78f6c SelfSizedTableView.intrinsicContentSize.getter + 19 (SelfSizedTableView.swift:19)
50 Drops 0x78ef4 #objc SelfSizedTableView.intrinsicContentSize.getter + 4365668084 (<compiler-generated>:4365668084)
51 UIKitCore 0x19cae8 -[UIView _generateContentSizeConstraints] + 56
52 UIKitCore 0x24beac -[UIView _updateContentSizeConstraints] + 268
53 UIKitCore 0x2f6440 -[UIView(AdditionalLayoutSupport) _updateSystemConstraints] + 124
54 UIKitCore 0x35aaac -[UIView(AdditionalLayoutSupport) _sendUpdateConstraintsIfNecessaryForSecondPass:] + 480
55 UIKitCore 0x17f5a0 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 996
56 UIKitCore 0x17f480 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 708
57 UIKitCore 0x17f480 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 708
58 CoreAutoLayout 0x7bac -[NSISEngine withBehaviors:performModifications:] + 80
59 UIKitCore 0x4f6720 -[UIView(AdditionalLayoutSupport) _recursiveUpdateConstraintsIfNeededCollectingViews:forSecondPass:] + 120
60 UIKitCore 0x17f480 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 708
61 UIKitCore 0x1e494c __100-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededWithViewForVariableChangeNotifications:]_block_invoke + 84
62 UIKitCore 0x25c954 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededWithViewForVariableChangeNotifications:] + 160
63 UIKitCore 0x314fd8 -[UIView(AdditionalLayoutSupport) _systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:hasIntentionallyCollapsedHeight:] + 224
64 UIKitCore 0x272668 -[UITableViewCell systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:] + 656
65 UIKitCore 0x331148 -[UITableView _heightForCell:atIndexPath:] + 400
66 UIKitCore 0x18a120 __53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke + 2432
67 UIKitCore 0x1632d0 +[UIView(Animation) performWithoutAnimation:] + 96
68 UIKitCore 0x3f4664 -[UITableView _configureCellForDisplay:forIndexPath:] + 244
69 UIKitCore 0x27010c -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 1916
70 UIKitCore 0x44a10c -[UITableView _createPreparedCellForRowAtIndexPath:willDisplay:] + 88
71 UIKitCore 0x534d90 -[UITableView _heightForRowAtIndexPath:] + 152
72 UIKitCore 0x1cab54 -[UISectionRowData heightForRow:inSection:canGuess:] + 208
73 UIKitCore 0x16ee8c -[UITableViewRowData heightForRow:inSection:canGuess:adjustForReorderedRow:] + 252
74 UIKitCore 0x237c54 -[UITableViewRowData rectForRow:inSection:heightCanBeGuessed:] + 332
75 UIKitCore 0x16c890 -[UITableViewRowData rectForGlobalRow:heightCanBeGuessed:] + 108
76 UIKitCore 0x277eb0 -[UITableView _prefetchCellAtGlobalRow:aboveVisibleRange:] + 264
77 UIKitCore 0x1c52f4 __48-[UITableView _configureCellPrefetchingHandlers]_block_invoke + 56
78 UIKitCore 0x170804 -[_UITableViewPrefetchContext updateVisibleIndexRange:withContentOffset:] + 2392
79 UIKitCore 0x42db08 -[UITableView _updateCycleIdleUntil:] + 188
80 UIKitCore 0x17e2b8 ___UIUpdateCycleNotifyIdle_block_invoke + 704
81 libdispatch.dylib 0x63094 _dispatch_call_block_and_release + 24
82 libdispatch.dylib 0x64094 _dispatch_client_callout + 16
83 libdispatch.dylib 0x45858 _dispatch_main_queue_drain + 888
84 libdispatch.dylib 0x454d0 _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 36
85 CoreFoundation 0x4e0d4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
86 CoreFoundation 0xb5f8 __CFRunLoopRun + 2544
87 CoreFoundation 0x1e250 CFRunLoopRunSpecific + 572
88 GraphicsServices 0x1988 GSEventRunModal + 160
89 UIKitCore 0x4e5a94 -[UIApplication _run] + 1080
90 UIKitCore 0x27efd4 UIApplicationMain + 336
91 libswiftUIKit.dylib 0x27ee4 UIApplicationMain(_:_:_:_:) + 100
92 Drops 0x1249a0 static UIApplicationDelegate.main() + 4366371232 (<compiler-generated>:4366371232)
93 Drops 0x124928 static AppDelegate.$main() + 25 (<compiler-generated>:25)
94 Drops 0x1263e8 main + 26 (AppDelegate.swift:26)
95 ??? 0x1036b44d0 (Missing)
Update your tableView in main thread. Ui should be always executed in main thread
DispatchQueue.main.async {
self.invalidateIntrinsicContentSize()
self.layoutIfNeeded()
}
Related
Over the last week, I've noticed a lot of -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 1256 crashes on iPhone 14 Pro devices running iOS 16.1.1.
The tableView where this problem originates has a constant number of rows and sections, so the datasource is never modified.
The crashes are also being reported to Crashlytics and Sentry, but never make it into the Apple Organizer.
Any idea what's going on? How can I resolve this issue?
Crashed: com.apple.main-thread
0 App 0x90e74 SettingsViewController.tableView(_:cellForRowAt:) + 4374285940 (SettingsViewController.swift:4374285940)
1 App 0x91210 #objc SettingsViewController.tableView(_:cellForRowAt:) + 4374286864 (<compiler-generated>:4374286864)
2 UIKitCore 0x14beec -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 1256
3 UIKitCore 0x11f844 -[UITableView _updateVisibleCellsForRanges:createIfNecessary:] + 596
4 UIKitCore 0x59350 -[UITableView _updateVisibleCellsNow:] + 1088
5 UIKitCore 0x58e44 -[UITableView layoutSubviews] + 148
6 UIKitCore 0x5020 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1980
7 QuartzCore 0x99ec CA::Layer::layout_if_needed(CA::Transaction*) + 500
8 UIKitCore 0xd21dc -[UIView(Hierarchy) layoutBelowIfNeeded] + 292
9 UIKitCore 0x3dc0c -[UINavigationController _layoutViewController:] + 816
10 UIKitCore 0x3d8d8 -[UINavigationController _layoutTopViewControllerLookForNested:] + 436
11 UIKitCore 0x1506dc -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 892
12 UIKitCore 0x150324 -[UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:] + 296
13 UIKitCore 0x14f8e4 -[UINavigationTransitionView _cleanupTransition] + 536
14 UIKitCore 0x14f634 +[UIView(UIViewAnimationWithBlocks) conditionallyAnimate:withAnimation:layout:completion:] + 136
15 UIKitCore 0x1a8c0c -[UINavigationTransitionView transition:fromView:toView:] + 1612
16 UIKitCore 0x1a8270 -[UINavigationController _startTransition:fromViewController:toViewController:] + 2104
17 UIKitCore 0x1a6fb4 -[UINavigationController _startDeferredTransitionIfNeeded:] + 608
18 UIKitCore 0x1a6604 -[UINavigationController __viewWillLayoutSubviews] + 96
19 UIKitCore 0x1a6568 -[UILayoutContainerView layoutSubviews] + 172
20 UIKitCore 0x5020 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1980
21 QuartzCore 0x99ec CA::Layer::layout_if_needed(CA::Transaction*) + 500
22 QuartzCore 0x1d0a0 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 148
23 QuartzCore 0x2e5b0 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 456
24 QuartzCore 0x635ec CA::Transaction::commit() + 652
25 QuartzCore 0x4c8cc CA::Transaction::flush_as_runloop_observer(bool) + 88
26 UIKitCore 0x504b44 _UIApplicationFlushCATransaction + 52
27 UIKitCore 0x652740 _UIUpdateSequenceRun + 84
28 UIKitCore 0xc99fd0 schedulerStepScheduledMainSection + 172
29 UIKitCore 0xc9919c runloopSourceCallback + 92
30 CoreFoundation 0xd5f54 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
31 CoreFoundation 0xe232c __CFRunLoopDoSource0 + 176
32 CoreFoundation 0x66210 __CFRunLoopDoSources0 + 244
33 CoreFoundation 0x7bba8 __CFRunLoopRun + 836
34 CoreFoundation 0x80ed4 CFRunLoopRunSpecific + 612
35 GraphicsServices 0x1368 GSEventRunModal + 164
36 UIKitCore 0x3a23d0 -[UIApplication _run] + 888
37 UIKitCore 0x3a2034 UIApplicationMain + 340
38 App 0x8020 main + 41 (AppDelegate.swift:41)
39 ??? 0x1aa7e0960 (Missing)
I discovered that there was a forced unwrapping deep inside my codebase. I would encourage you to search for any forced unwrapping.
let bottomOffset = bottomView.contentOffset.y
let currentOffset = overlayScrollView?.contentOffset.y ?? CGFloat(0)
let totalOffset = (bottomOffset + currentOffset) > 0 ? (bottomOffset + currentOffset) : 0
bottomView.contentOffset.y = 0
overlayScrollView?.contentOffset.y = totalOffset
I am facing several crashes of type EXC_BAD_ACCESS KERN_PROTECTION_FAILURE in app on this line
overlayScrollView?.contentOffset.y = totalOffset
Initially, I thought this is happening because KVO is not being handled properly, that might be message is being sent to deallocated object and observer is not removed.
Moved to new KVO keyPathBased APIs which removed overhead of removing observer. But still this issue is happening. This issue is not reproducible at all on my end.
0 QuartzCore 0x1a42bb938 CA::Layer::writable_state(CA::Transaction*) + 490
1 QuartzCore 0x1a42bba74 CA::Layer::end_change(CA::Transaction*, unsigned int, objc_object*, objc_object*) + 32
2 QuartzCore 0x1a42c4a04 CA::Layer::set_position(CA::Vec2<double> const&, bool) + 312
3 QuartzCore 0x1a42b2dbc -[CALayer setPosition:] + 48
4 QuartzCore 0x1a42b3450 -[CALayer setFrame:] + 424
5 UIKitCore 0x1a3e28df0 -[UIView(Geometry) setFrame:] + 472
6 UIKitCore 0x1a3dcf4b4 -[UIScrollView _layoutHorizontalScrollIndicatorWithBounds:effectiveInset:contentOffset:fraction:additionalInset:cornerAdjust:showing:recalcSize:verticalIndicatorFrame:] + 1320
7 UIKitCore 0x1a3dce89c -[UIScrollView _adjustScrollerIndicators:alwaysShowingThem:] + 1288
8 UIKitCore 0x1a3dbabfc -[UIScrollView setContentOffset:] + 1208
9 UIKitCore 0x1a3b46ed4 -[UITableView setContentOffset:] + 284
10 Foundation 0x1a236dbd8 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] + 560
11 Foundation 0x1a22b2600 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] + 68
12 Foundation 0x1a2369614 _NSSetPointValueAndNotify + 300
13 App 0x10488393c partial apply for closure #2 in PageBaseViewController.updatePanView(view:index:) + 540 (PageBaseViewController.swift:540)
14 App 0x1048822d8 partial apply for thunk for #escaping #callee_guaranteed (#guaranteed ZScrollView, #in_guaranteed NSKeyValueObservedChange<CGPoint>) -> () + 4369375960 (<compiler-generated>:4369375960)
15 libswiftFoundation.dylib 0x1a48d6a50 closure #1 in _KeyValueCodingAndObserving.observe<A>(_:options:changeHandler:) + 320
16 libswiftFoundation.dylib 0x1a48d9cc4 specialized NSKeyValueObservation.Helper._swizzle_me_observeValue(forKeyPath:of:change:context:) + 1268
17 libswiftFoundation.dylib 0x1a48d6494 #objc NSKeyValueObservation.Helper._swizzle_me_observeValue(forKeyPath:of:change:context:) + 192
18 Foundation 0x1a236bd70 NSKeyValueNotifyObserver + 288
19 Foundation 0x1a236e188 NSKeyValueDidChange + 324
20 Foundation 0x1a236dc14 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] + 620
21 Foundation 0x1a22b2600 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] + 68
22 Foundation 0x1a2369614 _NSSetPointValueAndNotify + 300
23 UIKitCore 0x1a3b386b0 -[UITableView _restoreOrAdjustContentOffsetWithRowCount:initialContentInsetTop:] + 352
24 UIKitCore 0x1a3b27a50 -[UITableView _updateVisibleCellsNow:] + 3552
25 UIKitCore 0x1a3b27a78 -[UITableView _updateVisibleCellsNow:] + 3592
26 UIKitCore 0x1a3b27a78 -[UITableView _updateVisibleCellsNow:] + 3592
27 UIKitCore 0x1a3b27a78 -[UITableView _updateVisibleCellsNow:] + 3592
28 UIKitCore 0x1a3b27a78 -[UITableView _updateVisibleCellsNow:] + 3592
29 UIKitCore 0x1a3b27a78 -[UITableView _updateVisibleCellsNow:] + 3592
30 UIKitCore 0x1a3b27a78 -[UITableView _updateVisibleCellsNow:] + 3592
31 UIKitCore 0x1a3b27a78 -[UITableView _updateVisibleCellsNow:] + 3592
32 UIKitCore 0x1a3b27a78 -[UITableView _updateVisibleCellsNow:] + 3592
33 UIKitCore 0x1a3b27a78 -[UITableView _updateVisibleCellsNow:] + 3592
34 UIKitCore 0x1a3b27a78 -[UITableView _updateVisibleCellsNow:] + 3592
35 UIKitCore 0x1a3b44938 -[UITableView layoutSubviews] + 356
36 UIKitCore 0x1a3e44910 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2544
37 QuartzCore 0x1a42b96dc -[CALayer layoutSublayers] + 288
38 QuartzCore 0x1a42bfe64 CA::Layer::layout_if_needed(CA::Transaction*) + 544
39 QuartzCore 0x1a42cb424 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 140
40 QuartzCore 0x1a4213c20 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 500
41 QuartzCore 0x1a423e970 CA::Transaction::commit() + 668
42 UIKitCore 0x1a39752c0 _afterCACommitHandler + 140
43 CoreFoundation 0x1a102d418 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
44 CoreFoundation 0x1a1027a48 __CFRunLoopDoObservers + 588
45 CoreFoundation 0x1a1027fe4 __CFRunLoopRun + 1012
46 CoreFoundation 0x1a10276a8 CFRunLoopRunSpecific + 572
47 GraphicsServices 0x1b76d7570 GSEventRunModal + 160
48 UIKitCore 0x1a3945370 -[UIApplication _run] + 1052
49 UIKitCore 0x1a394a8ec UIApplicationMain + 164
50 App 0x10460b944 main + 15 (main.m:15)
51 libdyld.dylib 0x1a0d06140 start + 4
I'm using this code to create top right bar button and perform a action in ios objective C.
UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:#selector(addAppliance)];
self.navigationItem.rightBarButtonItem = anotherButton;
But showing this error
Terminating app due to uncaught exception 'NSInternalInconsistencyException',`reason: 'Unsupported style: 4'
First throw call stack:
(
0 CoreFoundation 0x00007fff23e3cf0e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff50ba89b2 objc_exception_throw + 48
2 CoreFoundation 0x00007fff23e3cc88
+[NSException raise:format:arguments:] + 88
3 Foundation 0x00007fff258b8bd2
-[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
+ 191
4 UIKitCore
0x00007fff48d70f87 +[_UIBarButtonItemData standardItemDataForStyle:]
+ 539
5 UIKitCore
0x00007fff4828b26f -[_UIButtonBarButtonVisualProviderIOS _
computeTextAttributes] + 216
6 UIKitCore
0x00007fff4828b173 -[_UIButtonBarButtonVisual
ProviderIOS _computeTextAttributesForBarButtonItem:]
+ 371
7 UIKitCore
0x00007fff4828eef7 -[_UIButtonBarButtonVisual
ProviderIOS configureButton:fromBarButtonItem:] + 223
8 UIKitCore
0x00007fff4828ce8d -[_UIButtonBarButtonVisual
ProviderIOS configureButton:withAppearanceDelegate:fromBarItem:]
+ 114
9 UIKitCore
0x00007fff4828796f -
[_UIButtonBarButton _configureFromBarItem:appearanceDelegate
:isBackButton:] + 83
10 UIKitCore
0x00007fff4828750b -[_UIButtonBarButton configureFromBarItem:withAppearanceDelegate:] + 53
11 UIKitCore
0x00007fff48283a27 -[_UIButtonBar _updatedViewForBarButtonItem:withView:]
+ 456
12 UIKitCore
0x00007fff48281d02 __32-[_UIButtonBar _newGroupLayout:]_block_invoke + 82
13 UIKitCore
0x00007fff48291708 -[_UIButtonBarItemLayout _updateItemView] + 53
14 UIKitCore
0x00007fff48291ce9 -[_UIButtonBarItemLayout _configure] + 39
15 UIKitCore
0x00007fff482907a5 -[_UIButtonBarLayout configure] + 51
16 UIKitCore
0x00007fff48290908 -[_UIButtonBarLayout addLayoutViews:] + 49
17 UIKitCore
0x00007fff48293dd3 -[_UIButtonBarItemGroupLayout _iterateConfiguredLayouts:]
+ 228
18 UIKitCore
0x00007fff48293eaf -[_UIButtonBarItemGroupLayout _addLayoutViews:]
+ 111
19 UIKitCore
0x00007fff4829086c -
[_UIButtonBarLayout
addLayoutViews:layoutGuides:constraintsToActivate:
constraintsToDeactivate:] + 111
20 UIKitCore 0x00007fff48282424 -[_UIButtonBar _layoutBar] + 1768
21 UIKitCore 0x00007fff4828637e -[_UIButtonBarStackView updateConstraints] + 48
22 UIKitCore 0x00007fff490b0afa -[UIView(AdditionalLayoutSupport) _sendUpdateConstraintsIfNecessaryForSecondPass:] + 489
23 UIKitCore 0x00007fff490b10c8 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 1187
24 UIKitCore 0x00007fff490b0f62 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 829
25 Foundation 0x00007fff25aa5778 -[NSISEngine withBehaviors:performModifications:] + 84
26 UIKitCore 0x00007fff490b186a __100-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededWithViewForVariableChangeNotifications:]_block_invoke + 85
27 UIKitCore 0x00007fff490b0077 -[UIView(AdditionalLayoutSupport) _withUnsatisfiableConstraintsLoggingSuspendedIfEngineDelegateExists:] + 104
28 UIKitCore 0x00007fff490b13c5 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededWithViewForVariableChangeNotifications:] + 154
29 UIKitCore 0x00007fff490b22e4 -[UIView(AdditionalLayoutSupport) _updateConstraintsAtEngineLevelIfNeededWithViewForVariableChangeNotifications:] + 393
30 UIKitCore 0x00007fff4917e9f1 -[UIView(Hierarchy) layoutBelowIfNeeded] + 1334
31 UIKitCore 0x00007fff4830a32d -[_UINavigationBarTransitionContextPush _prepareContentView] + 204
32 UIKitCore 0x00007fff4830c36d -[_UINavigationBarTransitionContextPush prepare] + 106
33 UIKitCore 0x00007fff4831bd7c -[_UINavigationBarVisualProviderModernIOS _performAnimationWithTransitionCompletion:transition:] + 2221
34 UIKitCore 0x00007fff482bd813 -[UINavigationBar _pushNavigationItem:transitionAssistant:] + 568
35 UIKitCore 0x00007fff482bcf76 -[UINavigationBar _pushNavigationItemUsingCurrentTransition:] + 366
36 UIKitCore 0x00007fff482bd0e2 -[UINavigationBar pushNavigationItem:animated:] + 179
37 UIKitCore 0x00007fff482b7523 -[UINavigationBar _performUpdatesIgnoringLock:] + 45
38 UIKitCore 0x00007fff482bd1d9 -[UINavigationBar _pushNavigationItem:transition:] + 133
39 UIKitCore 0x00007fff48549776 __71-[UINavigationController pushViewController:transition:forceImmediate:]_block_invoke + 457
40 UIKitCore 0x00007fff485498ed __71-[UINavigationController pushViewController:transition:forceImmediate:]_block_invoke.1801 + 114
41 UIKitCore 0x00007fff48544c46 __98-[UINavigationController _shouldSkipHostedRefreshControlUpdateSchedulingDeferredUpdateIfNecessary]_block_invoke + 16
42 UIKitCore 0x00007fff485467ef -[UINavigationController _startDeferredTransitionIfNeeded:] + 1348
43 UIKitCore 0x00007fff48547954 -[UINavigationController __viewWillLayoutSubviews] + 150
44 UIKitCore 0x00007fff48528924 -[UILayoutContainerView layoutSubviews] + 217
45 UIKitCore 0x00007fff49193678 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2478
46 QuartzCore 0x00007fff2b4c6398 -[CALayer layoutSublayers] + 255
47 QuartzCore 0x00007fff2b4cc523 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 523
48 QuartzCore 0x00007fff2b4d7bba _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 80
49 QuartzCore 0x00007fff2b420c04 _ZN2CA7Context18commit_transactionEPNS_11TransactionEd + 324
50 QuartzCore 0x00007fff2b4545ef _ZN2CA11Transaction6commitEv + 649
51 UIKitCore 0x00007fff48c84fc8 _UIApplicationFlushRunLoopCATransactionIfTooLate + 104
52 UIKitCore 0x00007fff48d32ab0 __handleEventQueueInternal + 7506
53 UIKitCore 0x00007fff48d28fb9 __handleHIDEventFetcherDrain + 88
54 CoreFoundation 0x00007fff23da0d31 _CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION_ + 17
55 CoreFoundation 0x00007fff23da0c5c __CFRunLoopDoSource0 + 76
56 CoreFoundation 0x00007fff23da0434 __CFRunLoopDoSources0 + 180
57 CoreFoundation 0x00007fff23d9b02e __CFRunLoopRun + 974
58 CoreFoundation 0x00007fff23d9a944 CFRunLoopRunSpecific + 404
59 GraphicsServices 0x00007fff38ba6c1a GSEventRunModal + 139
60 UIKitCore 0x00007fff48c8b9ec UIApplicationMain + 1605
61 GasChecker 0x000000010099e5b7 main + 55
62 libdyld.dylib 0x00007fff51a231fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I hope someone is able to help me out here. For a weeks I am seeing this exception in my app:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'index out of bounds for arranged subview: index = 5 expected to be less than or equal to 4'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23e3cf0e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff50ba89b2 objc_exception_throw + 48
2 CoreFoundation 0x00007fff23e3cd4c +[NSException raise:format:] + 188
3 UIKitCore 0x00007fff49095fa8 -[UIStackView insertArrangedSubview:atIndex:] + 161
4 UIKitCore 0x00007fff48282ac1 -[_UIButtonBar _layoutBar] + 3461
5 UIKitCore 0x00007fff4828637e -[_UIButtonBarStackView updateConstraints] + 48
6 UIKitCore 0x00007fff490b0afa -[UIView(AdditionalLayoutSupport) _sendUpdateConstraintsIfNecessaryForSecondPass:] + 489
7 UIKitCore 0x00007fff490b10c8 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 1187
8 UIKitCore 0x00007fff490b0f62 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 829
9 Foundation 0x00007fff25aa5778 -[NSISEngine withBehaviors:performModifications:] + 84
10 UIKitCore 0x00007fff490b12de -[UIView(AdditionalLayoutSupport) _recursiveUpdateConstraintsIfNeededCollectingViews:forSecondPass:] + 112
11 UIKitCore 0x00007fff490b0f62 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 829
12 Foundation 0x00007fff25aa5778 -[NSISEngine withBehaviors:performModifications:] + 84
13 UIKitCore 0x00007fff490b12de -[UIView(AdditionalLayoutSupport) _recursiveUpdateConstraintsIfNeededCollectingViews:forSecondPass:] + 112
14 UIKitCore 0x00007fff490b0f62 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 829
15 UIKitCore 0x00007fff490b0f62 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 829
16 UIKitCore 0x00007fff490b0f62 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 829
17 UIKitCore 0x00007fff490b0f62 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 829
18 UIKitCore 0x00007fff490b0f62 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 829
19 Foundation 0x00007fff25aa5778 -[NSISEngine withBehaviors:performModifications:] + 84
20 UIKitCore 0x00007fff490b12de -[UIView(AdditionalLayoutSupport) _recursiveUpdateConstraintsIfNeededCollectingViews:forSecondPass:] + 112
21 UIKitCore 0x00007fff490b0f62 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 829
22 UIKitCore 0x00007fff490b0f62 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 829
23 UIKitCore 0x00007fff490b0f62 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 829
24 Foundation 0x00007fff25aa5778 -[NSISEngine withBehaviors:performModifications:] + 84
25 UIKitCore 0x00007fff490b186a __100-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededWithViewForVariableChangeNotifications:]_block_invoke + 85
26 UIKitCore 0x00007fff490b0077 -[UIView(AdditionalLayoutSupport) _withUnsatisfiableConstraintsLoggingSuspendedIfEngineDelegateExists:] + 104
27 UIKitCore 0x00007fff490b13c5 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededWithViewForVariableChangeNotifications:] + 154
28 UIKitCore 0x00007fff490a1390 -[UIWindow(UIConstraintBasedLayout) _updateConstraintsIfNeededWithViewForVariableChangeNotifications:] + 92
29 UIKitCore 0x00007fff490b22e4 -[UIView(AdditionalLayoutSupport) _updateConstraintsAtEngineLevelIfNeededWithViewForVariableChangeNotifications:] + 393
30 UIKitCore 0x00007fff4917f21b -[UIView(Hierarchy) _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 272
31 UIKitCore 0x00007fff49193678 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2478
32 QuartzCore 0x00007fff2b4c6398 -[CALayer layoutSublayers] + 255
33 QuartzCore 0x00007fff2b4cc523 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 523
34 QuartzCore 0x00007fff2b4d7bba _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 80
35 QuartzCore 0x00007fff2b420c04 _ZN2CA7Context18commit_transactionEPNS_11TransactionEd + 324
36 QuartzCore 0x00007fff2b4545ef _ZN2CA11Transaction6commitEv + 649
37 QuartzCore 0x00007fff2b454f81 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 79
38 CoreFoundation 0x00007fff23da0127 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
39 CoreFoundation 0x00007fff23d9abde __CFRunLoopDoObservers + 430
40 CoreFoundation 0x00007fff23d9b12a __CFRunLoopRun + 1226
41 CoreFoundation 0x00007fff23d9a944 CFRunLoopRunSpecific + 404
42 GraphicsServices 0x00007fff38ba6c1a GSEventRunModal + 139
43 UIKitCore 0x00007fff48c8b9ec UIApplicationMain + 1605
44 MyApp 0x00000001012dd63b main + 75
45 libdyld.dylib 0x00007fff51a231fd start + 1
46 ??? 0x0000000000000001 0x0 + 1
)
I can not find out what the root cause it. Because _UIButtonBarStackView is mentioned I assume that it has something to do with a UINavigationBar UIBarButtons. It seems to happen when I dismiss a modally presented UINavigationController, but I am not sure.
It also looks like it started to happen with iOS 13.4.1, because I can't find any crash report with any older version.
Anyone might know what's going on here?
Found out the cause: I was adding the same UIBarButtonItem again to navigationItem.rightBarButtonItems. Apple seems to raise exceptions about that since iOS 13.4.1(-ish).
This crash happens in a UINavigationController for three times (present and dismiss consequently for 2 times after the first open).
I made a debug by using breakpoints and I figured that it happens in the presented ViewController after the viewWillAppear finish and before the viewWillLayoutSubviews.
However, it didn't stop between my lines of code so I can't detect the cause of the error.
Happens in IOS 12 ONLY (Works fine in IOS 13)
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Expression 0 + 0.0291667*0 + 0.00277778*369 unable to find variable UIWindow:0x7fb745603f60.minX{id: 21963} in engine 0x0'
*** First throw call stack:
(
0 CoreFoundation 0x000000011709929b __exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000116635735 objc_exception_throw + 48
2 CoreFoundation 0x0000000117099022 +[NSException raise:format:arguments:] + 98
3 Foundation 0x0000000112f5bc10 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166
4 Foundation 0x000000011317221b -[NSISLinearExpression addVariable:coefficient:] + 341
5 UIKitCore 0x000000011ccb8166 -[UIView(AdditionalLayoutSupport) nsli_lowerAttribute:intoExpression:withCoefficient:forConstraint:onBehalfOfLayoutGuide:] + 3120
6 UIKitCore 0x000000011ccb7527 -[UIView(AdditionalLayoutSupport) nsli_lowerAttribute:intoExpression:withCoefficient:forConstraint:] + 289
7 Foundation 0x000000011317e0d3 -[NSLayoutConstraint _lowerIntoExpression:reportingConstantIsRounded:] + 96
8 Foundation 0x000000011317a3e8 -[NSLayoutConstraint _containerGeometryDidChange] + 117
9 UIKitCore 0x000000011cca33fa _UIViewEnumerateConstraints + 710
10 UIKitCore 0x000000011ccb10bc __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 315
11 Foundation 0x000000011316555a -[NSISEngine withBehaviors:performModifications:] + 110
12 UIKitCore 0x000000011ccb0f5a __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 572
13 UIKitCore 0x000000011ccb0ce6 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 217
14 UIKitCore 0x000000011ccb1056 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 213
15 Foundation 0x000000011316555a -[NSISEngine withBehaviors:performModifications:] + 110
16 UIKitCore 0x000000011ccb0f5a __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 572
17 UIKitCore 0x000000011ccb0ce6 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 217
18 UIKitCore 0x000000011ccb1056 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 213
19 Foundation 0x000000011316555a -[NSISEngine withBehaviors:performModifications:] + 110
20 UIKitCore 0x000000011ccb0f5a __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 572
21 UIKitCore 0x000000011ccb0ce6 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 217
22 UIKitCore 0x000000011ccb1056 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 213
23 Foundation 0x000000011316555a -[NSISEngine withBehaviors:performModifications:] + 110
24 UIKitCore 0x000000011ccb0f5a __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 572
25 UIKitCore 0x000000011ccb0ce6 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 217
26 UIKitCore 0x000000011ccb1056 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 213
27 Foundation 0x000000011316555a -[NSISEngine withBehaviors:performModifications:] + 110
28 UIKitCore 0x000000011ccb0f5a __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 572
29 UIKitCore 0x000000011ccb0ce6 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 217
30 UIKitCore 0x000000011d1d6075 -[UIScrollView _switchToLayoutEngine:] + 106
31 UIKitCore 0x000000011ccb1056 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 213
32 Foundation 0x000000011316555a -[NSISEngine withBehaviors:performModifications:] + 110
33 UIKitCore 0x000000011ccb0f5a __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 572
34 UIKitCore 0x000000011ccb0ce6 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 217
35 UIKitCore 0x000000011ccafd4d -[UIView(AdditionalLayoutSupport) _initializeHostedLayoutEngine] + 209
36 UIKitCore 0x000000011cca1712 -[UIView(UIConstraintBasedLayout) _layoutEngine_windowDidChange] + 130
37 UIKitCore 0x000000011d4da793 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 170
38 UIKitCore 0x000000011d4da9ab -[UIView(Internal) _didMoveFromWindow:toWindow:] + 706
39 UIKitCore 0x000000011d4cd091 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 151
40 UIKitCore 0x000000011d4ccf70 -[UIView(Hierarchy) _postMovedFromSuperview:] + 804
41 UIKitCore 0x000000011d4dd9a5 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1951
42 UIKitCore 0x000000011d0d17f1 -[UINavigationTransitionView transition:fromView:toView:] + 627
43 UIKitCore 0x000000011d0b63a6 -[UINavigationController _startTransition:fromViewController:toViewController:] + 3189
44 UIKitCore 0x000000011d0b6857 -[UINavigationController _startDeferredTransitionIfNeeded:] + 896
45 UIKitCore 0x000000011d0b7bac -[UINavigationController __viewWillLayoutSubviews] + 150
46 UIKitCore 0x000000011d04363f -[UILayoutContainerView layoutSubviews] + 217
47 UIKitCore 0x000000011d4e4015 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1441
48 QuartzCore 0x0000000114fb6d3d -[CALayer layoutSublayers] + 175
49 QuartzCore 0x0000000114fbbbf7 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 395
50 QuartzCore 0x0000000114f34aa6 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 342
51 QuartzCore 0x0000000114f6bc2a _ZN2CA11Transaction6commitEv + 576
52 UIKitCore 0x000000011cdf48f5 _afterCACommitHandler + 268
53 CoreFoundation 0x0000000116ffc037 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
54 CoreFoundation 0x0000000116ff64ce __CFRunLoopDoObservers + 430
55 CoreFoundation 0x0000000116ff6b61 __CFRunLoopRun + 1537
56 CoreFoundation 0x0000000116ff6221 CFRunLoopRunSpecific + 625
57 GraphicsServices 0x000000011c65e1dd GSEventRunModal + 62
58 UIKitCore 0x000000011cdcb115 UIApplicationMain + 140
59 Almtaar 0x000000010d43a1ab main + 75
60 libdyld.dylib 0x0000000118e83551 start + 1
61 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException