Skip to content

Commit

Permalink
clean up IGListExperimentKeepPointerToCollectionViewDataSource
Browse files Browse the repository at this point in the history
Summary: QE launched and reduced crashes, so lets clean up

Differential Revision: D60184705

fbshipit-source-id: 574b0228e3efadf7bd3bd0677a4373a3b95888d1
  • Loading branch information
Maxime Ollivier authored and facebook-github-bot committed Jul 24, 2024
1 parent d90909f commit 6c2cfcf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 0 additions & 2 deletions Source/IGListDiffKit/IGListExperiments.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ typedef NS_OPTIONS (NSInteger, IGListExperiment) {
IGListExperimentInvalidateLayoutForUpdates = 1 << 2,
/// Throw NSInternalInconsistencyException during an update
IGListExperimentThrowOnInconsistencyException = 1 << 3,
/// Test keeping a strong pointer to the collectionView.dataSource during a batch update to avoid a crash
IGListExperimentKeepPointerToCollectionViewDataSource = 1 << 4,
};

/**
Expand Down
9 changes: 4 additions & 5 deletions Source/IGListKit/Internal/IGListBatchUpdateTransaction.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,10 @@ - (void)_didDiff:(IGListIndexSetResult *)diffResult onBackground:(BOOL)onBackgro
[self.delegate listAdapterUpdater:self.updater didDiffWithResults:diffResult onBackgroundThread:onBackground];

@try {
// Experiment with keeping a pointer to the self.collectionView.dataSource, because we're seeing a crash where it could be missing.
const BOOL keepDataSource = IGListExperimentEnabled(self.config.experiments, IGListExperimentKeepPointerToCollectionViewDataSource);
id<UICollectionViewDataSource> const collectionViewDataSource = keepDataSource ? self.collectionView.dataSource : nil;

if (self.collectionView.dataSource == nil || (keepDataSource && collectionViewDataSource == nil)) {
// Keeping a pointer to self.collectionView.dataSource, because it can get deallocated before the UICollectionView and crash
id<UICollectionViewDataSource> const collectionViewDataSource = self.collectionView.dataSource;

if (collectionViewDataSource == nil) {
// If the data source is nil, we should not call any collection view update.
[self _bail];
} else if (diffResult.changeCount > 100 && self.config.allowsReloadingOnTooManyUpdates) {
Expand Down

0 comments on commit 6c2cfcf

Please # to comment.