mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-24 09:48:21 +00:00
Summary:
## Issue
We're seeing crashes like this one:
```
Invalid batch updates detected: the number of sections and/or items returned by the data source before and after performing the batch updates are inconsistent with the updates.
Data source before updates = { 6 sections with item counts: [1, 0, 6, 8, 5, 7] }
Data source after updates = { 1 section with item counts: [0] }
Updates = [
]
```
I'm thinking the `IGListAdapter` gets deallocated during an update.
1. `1 section with item counts: [0]` is the default when the `self.collectionView.dataSource` is `nil`. I don't really see a way we'd return a single section with zero cells.
2. We're not seeing any of the additional crash information set by the `IGListAdapterUpdaterDelegate`, which would happen if `IGListAdapter` gets deallocated (it holds the strong pointer to the delegate).
## Fix
Lets keep a strong pointer within the scope of the function to make sure it sticks around. Theoretically, there could be a situation where the section-controller holds a strong pointer to the list-adapter in an update block, which gets released after it runs. This seems pretty unlikely, so lets test this fix to see if that's it.
Reviewed By: candance
Differential Revision: D52747014
fbshipit-source-id: 545aaa3deb90af85a011e716ac870659da42106f
|
||
|---|---|---|
| .. | ||
| Internal | ||
| IGListAssert.h | ||
| IGListBatchUpdateData.h | ||
| IGListBatchUpdateData.mm | ||
| IGListCompatibility.h | ||
| IGListDiff.h | ||
| IGListDiff.mm | ||
| IGListDiffable.h | ||
| IGListDiffKit.h | ||
| IGListExperiments.h | ||
| IGListIndexPathResult.h | ||
| IGListIndexPathResult.m | ||
| IGListIndexSetResult.h | ||
| IGListIndexSetResult.m | ||
| IGListMacros.h | ||
| IGListMoveIndex.h | ||
| IGListMoveIndex.m | ||
| IGListMoveIndexPath.h | ||
| IGListMoveIndexPath.m | ||
| NSNumber+IGListDiffable.h | ||
| NSNumber+IGListDiffable.m | ||
| NSString+IGListDiffable.h | ||
| NSString+IGListDiffable.m | ||