Skip to content

Commit

Permalink
Boundary test of removing all IGListAdapter animation
Browse files Browse the repository at this point in the history
Summary:
# Context

We've seen several experiments in which disabling standard-update animation yielded significant app-value wins. Overall there is a trend of moving towards snappier

- Reels grid disabled animation, led to vpvd wins
- Home feed disabled update animations -- led to Session and revenue wins

# This diff

From IGListAdapter+Common, create a kill switch to disable all animation. Potentially use this flag to dogfood and see where we have unnecessary animation.

Differential Revision: D54388375

fbshipit-source-id: a46c60944317db5deeceaac6d0baed71104d0c34
  • Loading branch information
Harrison Huang authored and facebook-github-bot committed Mar 2, 2024
1 parent 6a834f8 commit 5c9d3a8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 3 additions & 1 deletion Source/IGListDiffKit/IGListExperiments.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ typedef NS_OPTIONS (NSInteger, IGListExperiment) {
/// 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
IGListExperimentKeepPointerToCollectionViewDataSource = 1 << 4,
/// Test keeping disable all animation on updates
IGListExperimentDisableAnimationOnUpdates= 1 << 5
};

/**
Expand Down
1 change: 1 addition & 0 deletions Source/IGListKit/IGListAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ NS_SWIFT_NAME(ListAdapter)
*/
@property (nonatomic, assign) IGListExperiment experiments;


/**
Initializes a new `IGListAdapter` object.
Expand Down
10 changes: 5 additions & 5 deletions Source/IGListKit/IGListAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ - (void)performUpdatesAnimated:(BOOL)animated completion:(IGListUpdaterCompletio
[strongSelf _updateWithData:data];
}
};

const BOOL shouldAnimateUpdates = animated && !IGListExperimentEnabled(self.experiments, IGListExperimentDisableAnimationOnUpdates);
IGListUpdaterCompletion outerCompletionBlock = ^(BOOL finished){
__typeof__(self) strongSelf = weakSelf;
if (strongSelf == nil) {
Expand All @@ -424,7 +424,7 @@ - (void)performUpdatesAnimated:(BOOL)animated completion:(IGListUpdaterCompletio

// release the previous items
strongSelf.previousSectionMap = nil;
[strongSelf _notifyDidUpdate:IGListAdapterUpdateTypePerformUpdates animated:animated];
[strongSelf _notifyDidUpdate:IGListAdapterUpdateTypePerformUpdates animated:shouldAnimateUpdates];
IGLK_BLOCK_CALL_SAFE(completion,finished);
[strongSelf _exitBatchUpdates];
};
Expand Down Expand Up @@ -686,7 +686,7 @@ - (IGListTransitionData *)_generateTransitionDataWithObjects:(NSArray *)objects
dataSource, object);
return;
}

if ([sectionController isMemberOfClass:[IGListSectionController class]]) {
// If IGListSectionController is not subclassed, it could be a side effect of a problem. For example, nothing stops
// dataSource from returning a plain IGListSectionController if it doesn't recognize the object type, instead of throwing.
Expand Down Expand Up @@ -1367,7 +1367,7 @@ - (void)insertInSectionController:(IGListSectionController *)sectionController a

NSArray *indexPaths = [self indexPathsFromSectionController:sectionController indexes:indexes usePreviousIfInUpdateBlock:NO];
[self.updater insertItemsIntoCollectionView:collectionView indexPaths:indexPaths];

if (![self isInDataUpdateBlock]) {
[self _updateBackgroundView];
}
Expand All @@ -1386,7 +1386,7 @@ - (void)deleteInSectionController:(IGListSectionController *)sectionController a

NSArray *indexPaths = [self indexPathsFromSectionController:sectionController indexes:indexes usePreviousIfInUpdateBlock:YES];
[self.updater deleteItemsFromCollectionView:collectionView indexPaths:indexPaths];

if (![self isInDataUpdateBlock]) {
[self _updateBackgroundView];
}
Expand Down

0 comments on commit 5c9d3a8

Please sign in to comment.