Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash with SingleSectionTableViewDiffCalculator #97

Open
r00li opened this issue Mar 11, 2019 · 0 comments
Open

Crash with SingleSectionTableViewDiffCalculator #97

r00li opened this issue Mar 11, 2019 · 0 comments

Comments

@r00li
Copy link

r00li commented Mar 11, 2019

Hi!
We have started receiving some Crashlytics crash reports in our production app recently. And they all point to some bizarre issue with Dwifft. Now the app has 2k daily active users and the crash happened only 4 times now, so it is not terribly common. None of the QA teams have been able to reproduce it and neither have I. However it happened to three different users.

The crash always happens when setting new rows for the Dwifft SingleSectionTableViewDiffCalculator. We are using the latest version of Dwifft available via Cocoapods.

Basically this is what we get:

Fatal Exception: NSInternalInconsistencyException
attempt to insert row 20 into section 0, but there are only 10 rows in section 0 after the update

Part of the stack trace:

Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 0x1becc1ea4 __exceptionPreprocess
1  libobjc.A.dylib                0x1bde91a50 objc_exception_throw
2  CoreFoundation                 0x1bebd7a2c +[_CFXNotificationTokenRegistration keyCallbacks]
3  Foundation                     0x1bf6c61d0 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
4  UIKitCore                      0x1ec19e150 -[UITableView _endCellAnimationsWithContext:]
5  UIKitCore                      0x1ec1b70a0 -[UITableView endUpdates]
6  Dwifft                         0x101669340 TableViewDiffCalculator.processChanges(newState:diff:) (Dwifft+UIKit.swift:45)
7  Dwifft                         0x101668cdc specialized AbstractDiffCalculator.sectionedValues.setter (AbstractDiffCalculator.swift:78)
8  Dwifft                         0x10166a308 specialized SingleSectionTableViewDiffCalculator.rows.setter (<compiler-generated>)
9  Dwifft                         0x101669be8 SingleSectionTableViewDiffCalculator.rows.setter (<compiler-generated>)

This is how dwifft is configured:

    private var dataModel: [AppNotification] = []
    private var diffCalculator: SingleSectionTableViewDiffCalculator<AppNotification>?
    ...
    override func viewDidLoad() {
        ...
        diffCalculator = SingleSectionTableViewDiffCalculator<AppNotification>(tableView: self.tableView, initialRows: [], sectionIndex: 0)
        diffCalculator?.insertionAnimation = .top
        diffCalculator?.deletionAnimation = .middle
        ...
    }

The crash happens when we fetch the data from network, prepare and then store it to the dataModel property and then set the self.diffCalculator?.rows = self.dataModel.

Any ideas on what could be the reason for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant