-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Hi 👋🏻
While working on a Client's App, Firebase reported a weird crash that is caused by FormViewController trying to remove some rows from a section that does contain anything, when actually it says the opposite.
The trace starts here in the Client's app code:
if !self.feedSection.isEmpty {
self.feedSection.removeAll()
}
where feedSection is Eureka.Section.
The .isEmpty property states that the section is not empty, so the App proceeds to remove the content. Then, it crashes at FormViewController.rowsHaveBeenRemoved(_:at:) with the following message:
attempt to delete row 4 from section 0 which only contains 0 rows before the update
Here you go the stack trace I got from Firebase:
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x827cc __exceptionPreprocess
1 libobjc.A.dylib 0x172e4 objc_exception_throw
2 Foundation 0x80f8d8 _userInfoForFileAndLine
3 UIKitCore 0x354630 -[UITableView _endCellAnimationsWithContext:]
4 UIKitCore 0x388f78 -[UITableView endUpdatesWithContext:]
5 Pan 0x51de70 FormViewController.rowsHaveBeenRemoved(_:at:) + 733 (Core.swift:733)
6 Pan 0x55ed00 specialized Section.KVOWrapper.observeValue(forKeyPath:of:change:context:) + 94 (Section.swift:94)
7 Pan 0x555dd8 @objc Section.KVOWrapper.observeValue(forKeyPath:of:change:context:) (<compiler-generated>)
8 Foundation 0x1a72c NSKeyValueNotifyObserver
9 Foundation 0x1a420 NSKeyValueDidChange
10 Foundation 0x11d17c -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:]
11 Foundation 0x11cd98 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:]
12 Foundation 0x11c22c _NSSetObjectValueAndNotify
13 Pan 0x55f784 specialized Section.removeAll(keepingCapacity:) + 78 (Section.swift:78)
Steps To Reproduce
Sadly, I was not able to reproduce it myself 😞 but it is constantly crashing according to Firebase: 207 crash events affecting 206 users in the last week since today.
Expected behavior
I would have expected the .isEmpty function to work as intended, so the App does not tries to remove rows if the section is already empty. Also, I would have expected the SDK to check the section's content before updating it.
Having a look, I have seen that there are no checks done before the Form updates the TableView in FormViewController.rowsHaveBeenRemoved(_:at:).
Versions
- Device: iPhone 13
- OS: iOS 18.1.1
- Eureka Version: 5.5.0
- Xcode version: 15.4
Additional context
Just in case it helps, the % of free RAM according to Firebase is 160.43 MB.