Skip to content

Commit

Permalink
clean up IGListExperimentReloadDataFallback
Browse files Browse the repository at this point in the history
Summary: This experiment shipped so we can remove it. We still need a way to disable it with `allowsReloadingOnTooManyUpdates` in case we don't want to resign the first responder on large updates.

Reviewed By: Haud

Differential Revision: D22219238

fbshipit-source-id: 98e78f3ed040809db6c4b4c8da8fd0e976aca0a2
  • Loading branch information
maxolls authored and facebook-github-bot committed Jun 26, 2020
1 parent 7fc4384 commit 86ecc60
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ The changelog for `IGListKit`. Also see the [releases](https://github.com/instag

- Improved performance by deferring requesting objects from the `IGListAdapterDataSource` until just before diffing is executed. If n updates are coalesced into one, this results in just a single request for objects from the data source. Shipped with experiment `IGListExperimentDeferredToObjectCreation` from Ryan Nystrom. [Maxime Ollivier](https://github.com/maxolls) (tbd)

- Improved performance by using `reloadData` when there are too many diffing updates. Shipped with experiment `IGListExperimentReloadDataFallback` from Ryan Nystrom. [Maxime Ollivier](https://github.com/maxolls) (tbd)

### Fixes

- `IGListCollectionViewLayout` should get the section/index counts via `UICollectionView` to stay in sync, instead of the `dataSource` [Maxime Ollivier](https://github.com/maxolls) (tbd)
Expand Down
4 changes: 1 addition & 3 deletions Source/IGListDiffKit/IGListExperiments.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ typedef NS_OPTIONS (NSInteger, IGListExperiment) {
IGListExperimentNone = 1 << 1,
/// Test updater diffing performed on a background queue.
IGListExperimentBackgroundDiffing = 1 << 2,
/// Test fallback to reloadData when "too many" update operations.
IGListExperimentReloadDataFallback = 1 << 3,
/// Test invalidating layout when cell reloads/updates in IGListBindingSectionController.
IGListExperimentInvalidateLayoutForUpdates = 1 << 4,
IGListExperimentInvalidateLayoutForUpdates = 1 << 3,
};

/**
Expand Down
6 changes: 6 additions & 0 deletions Source/IGListKit/IGListAdapterUpdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ NS_SWIFT_NAME(ListAdapterUpdater)
*/
@property (nonatomic, assign) BOOL allowsBackgroundReloading;

/**
If there's more than 100 diff updates, fallback to using `reloadData` to avoid stalling the main thread.
Default is YES.
*/
@property (nonatomic, assign) BOOL allowsReloadingOnTooManyUpdates;

/**
A bitmask of experiments to conduct on the updater.
*/
Expand Down
4 changes: 3 additions & 1 deletion Source/IGListKit/IGListAdapterUpdater.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ - (instancetype)init {
_completionBlocks = [NSMutableArray new];
_batchUpdates = [IGListBatchUpdates new];
_allowsBackgroundReloading = YES;
_allowsReloadingOnTooManyUpdates = YES;
}
return self;
}
Expand Down Expand Up @@ -110,6 +111,7 @@ - (void)performBatchUpdatesWithCollectionViewBlock:(IGListCollectionViewBlock)co
NSMutableArray *completionBlocks = [self.completionBlocks mutableCopy];
void (^objectTransitionBlock)(NSArray *) = [self.objectTransitionBlock copy];
const BOOL animated = self.queuedUpdateIsAnimated;
const BOOL allowsReloadingOnTooManyUpdates = self.allowsReloadingOnTooManyUpdates;
IGListBatchUpdates *batchUpdates = self.batchUpdates;

// clean up all state so that new updates can be coalesced while the current update is in flight
Expand Down Expand Up @@ -284,7 +286,7 @@ - (void)performBatchUpdatesWithCollectionViewBlock:(IGListCollectionViewBlock)co
if (collectionView.dataSource == nil) {
// If the data source is nil, we should not call any collection view update.
fallbackWithoutUpdates();
} else if (result.changeCount > 100 && IGListExperimentEnabled(experiments, IGListExperimentReloadDataFallback)) {
} else if (result.changeCount > 100 && allowsReloadingOnTooManyUpdates) {
reloadDataFallback();
} else {
performUpdate(result);
Expand Down
2 changes: 0 additions & 2 deletions Tests/IGListAdapterE2ETests.m
Original file line number Diff line number Diff line change
Expand Up @@ -1533,8 +1533,6 @@ - (void)test_whenMassiveUpdate_thatUpdateApplied {
// init empty
[self setupWithObjects:@[]];

((IGListAdapterUpdater *)self.updater).experiments = IGListExperimentReloadDataFallback;

NSMutableArray *objects = [NSMutableArray new];
for (NSInteger i = 0; i < 3000; i++) {
[objects addObject:genTestObject(@(i + 1), @4)];
Expand Down

0 comments on commit 86ecc60

Please sign in to comment.