Reputation: 1279
My app started crashing randomly during launch with below error. Sometimes it starts and sometimes it crashes. How can I investigate this bug? Any help appreciated
2021-06-21 09:44:44.940545+0200 APP[18897:3547429] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to insert row 2 into section 0, but there are only 2 rows in section 0 after the update'
*** First throw call stack:
(
0 CoreFoundation 0x00000001186ebfba __exceptionPreprocess + 242
1 libobjc.A.dylib 0x0000000118595ff5 objc_exception_throw + 48
2 CoreFoundation 0x00000001186ebde3 +[NSException raise:format:] + 0
3 Foundation 0x000000010ffa88e7 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
4 UIKitCore 0x00000001245098a3 -[UITableView _endCellAnimationsWithContext:] + 9269
5 UIKitCore 0x0000000124524ff7 -[UITableView endUpdatesWithContext:] + 116
6 UIKitCore 0x00000001245251c9 -[UITableView _performBatchUpdates:withContext:completion:] + 253
7 UIKitCore 0x00000001245252af -[UITableView performBatchUpdates:completion:] + 97
8 SwiftUI 0x000000011527a801 $s7SwiftUI25UpdateCoalescingTableView33_BFB370BA5F1BADDC9D83021565761A49LLC19performBatchUpdates_10completionyyycSg_ySbcSgtF + 378
9 SwiftUI 0x000000011527a8da $s7SwiftUI25UpdateCoalescingTableView33_BFB370BA5F1BADDC9D83021565761A49LLC19performBatchUpdates_10completionyyycSg_ySbcSgtFTo + 175
10 SwiftUI 0x000000011527d31d $s7SwiftUI19ListCoreCoordinator33_BFB370BA5F1BADDC9D83021565761A49LLC17updateUITableView_2to11transactionySo0mN0C_xAA11TransactionVtF14performUpdatesL_yyAA0cD10DataSourceRzAA16SelectionManagerR_0V5ValueQy_AORtzr0_lF + 1594
11 SwiftUI 0x0000000115623652 $sIg_Ieg_TR + 12
12 SwiftUI 0x0000000115623668 $sIeg_IyB_TR + 14
13 UIKitCore 0x0000000124856bb9 +[UIView(Animation) performWithoutAnimation:] + 84
14 SwiftUI 0x000000011527dc6f $s7SwiftUI19ListCoreCoordinator33_BFB370BA5F1BADDC9D83021565761A49LLC17updateUITableView_2to11transactionySo0mN0C_xAA11TransactionVtFyycfU_ + 467
15 SwiftUI 0x0000000115166eb7 $sIeg_ytIegr_TR + 12
16 SwiftUI 0x00000001152851cf $sIeg_ytIegr_TRTA + 17
17 SwiftUI 0x000000011528899f $sIeg_ytIegr_TRTA.42 + 9
18 SwiftUI 0x0000000115150ec4 $s7SwiftUI6UpdateO3endyyFZ + 433
19 SwiftUI 0x0000000114fa83fd $sSo9NSRunLoopC7SwiftUIE14flushObserversyyFZ + 148
20 SwiftUI 0x0000000114fa8367 $sSo9NSRunLoopC7SwiftUIE11addObserveryyyycFZySo05CFRunbF3RefaSg_So0gB8ActivityVSvSgtcfU_yyXEfU_ + 9
21 SwiftUI 0x0000000114fa35fe $ss5Error_pIgzo_ytsAA_pIegrzo_TR95$sSo9NSRunLoopC7SwiftUIE11addObserveryyyycFZySo05CFRunbF3RefaSg_So0gB8ActivityVSvSgtcfU_yyXEfU_Tf3npf_n + 14
22 libswiftObjectiveC.dylib 0x0000000119a9603e $s10ObjectiveC15autoreleasepool8invokingxxyKXE_tKlF + 46
23 SwiftUI 0x0000000114fa8356 $sSo9NSRunLoopC7SwiftUIE11addObserveryyyycFZySo05CFRunbF3RefaSg_So0gB8ActivityVSvSgtcfU_ + 35
24 SwiftUI 0x0000000114fa8459 $sSo9NSRunLoopC7SwiftUIE11addObserveryyyycFZySo05CFRunbF3RefaSg_So0gB8ActivityVSvSgtcfU_To + 43
25 CoreFoundation 0x0000000118658d31 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
26 CoreFoundation 0x0000000118653542 __CFRunLoopDoObservers + 541
27 CoreFoundation 0x0000000118653af5 __CFRunLoopRun + 1129
28 CoreFoundation 0x00000001186531a7 CFRunLoopRunSpecific + 567
29 GraphicsServices 0x000000011c844d85 GSEventRunModal + 139
30 UIKitCore 0x000000012430c4df -[UIApplication _run] + 912
31 UIKitCore 0x000000012431139c UIApplicationMain + 101
32 1A-Client 0x000000010485fb5b main + 75
33 libdyld.dylib 0x0000000119e1cbbd start + 1
34 ??? 0x0000000000000001 0x0 + 1
)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to insert row 2 into section 0, but there are only 2 rows in section 0 after the update'
terminating with uncaught exception of type NSException
CoreSimulator 772.1 - Device: iPhone 12 (6C4D1499-EBAC-4ED6-9C38-7DB0EB0C63E9) - Runtime: iOS 14.5 (18E182) - DeviceType: iPhone 12
Upvotes: 2
Views: 489
Reputation: 1279
I've fixed this crash by forcing section rewrite on every view refresh. It looks not optimal but the problems seems to be problem with SwiftUI view update cycle
Section {
content()
}
.id(UUID())
Upvotes: 2