Open rkittinger opened 6 years ago
@rkittinger I haven't seen this problem. Maybe your data has changed to 0 just before DeepDiff finishes ?
We seemed to have fixed the problem above, but crashes in this case:
self.tableView.reload(changes: self.diffModels) { _ in
UIView.setAnimationsEnabled(true)
self.diffModels.removeAll()
}
error: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (15) must be equal to the number of rows contained in that section before the update (15), plus or minus the number of rows inserted or deleted from that section (15 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'
@rkittinger I hit the issue you're describing. I've been using Differ in the past, but ran into the invalid update error and had to work around it. I thought it was an isolated case since I couldn't find any other issue describing the problem. Today I figured I'd give DeepDiff a try, to see if it had the same issue, and it does.
I've found an article that explains the issue, and the proposed fix/workaround also worked well for me: https://fangpenlin.com/posts/2016/04/29/uicollectionview-invalid-number-of-items-crash-issue/
I've personally only hit it for collection views, not table views. Perhaps the new API for performBatchUpdates
on UITableView
introduced in iOS 11
causes the same problem, and that is what you are seeing.
@Burgestrand Hi, I will try to look into https://fangpenlin.com/posts/2016/04/29/uicollectionview-invalid-number-of-items-crash-issue/ soon. Do you have a test or demo that reproduces this bug?
A workaround is to check data source for number of objects before perform changes of diffing. This can be added to DeepDiff or users must do this before calling apply(changes)
in client code
@onmyway133 I'm experiencing the same issue and would like to try to solve it. I suppose one could let the client call into DeepDiff to get value that the clients needs to return from function numberOfItemsInSection thus returning the appropriate values depending on the phase of any current batch operation (as proposed in the linked article above). Do you have any other ideas on how to implement the fix in DeepDiff?
@rkittinger @snoozemoose @Burgestrand Hi, I just introduced updateData
in this new release https://github.com/onmyway133/DeepDiff/releases/tag/1.4.0, hope it helps
When I remove, the number/ranking on the leaderboard does not update.
I am using ver.1.1.1 and the app crashes sometimes with:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete row 0 from section 0, but there are only 0 sections before the update'
Has this been fixed in 1.1.2? I saw here that it could take a while to fix: https://medium.com/flawless-app-stories/a-better-way-to-update-uicollectionview-data-in-swift-with-diff-framework-924db158db86