From 5c9d3a80c692712972ea3749f4e0b02921639c73 Mon Sep 17 00:00:00 2001 From: Harrison Huang Date: Sat, 2 Mar 2024 00:50:49 -0800 Subject: [PATCH] Boundary test of removing all IGListAdapter animation 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 --- Source/IGListDiffKit/IGListExperiments.h | 4 +++- Source/IGListKit/IGListAdapter.h | 1 + Source/IGListKit/IGListAdapter.m | 10 +++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Source/IGListDiffKit/IGListExperiments.h b/Source/IGListDiffKit/IGListExperiments.h index 1c660a88c..4fa764e7d 100644 --- a/Source/IGListDiffKit/IGListExperiments.h +++ b/Source/IGListDiffKit/IGListExperiments.h @@ -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 }; /** diff --git a/Source/IGListKit/IGListAdapter.h b/Source/IGListKit/IGListAdapter.h index de6a34f62..1d702ec00 100644 --- a/Source/IGListKit/IGListAdapter.h +++ b/Source/IGListKit/IGListAdapter.h @@ -103,6 +103,7 @@ NS_SWIFT_NAME(ListAdapter) */ @property (nonatomic, assign) IGListExperiment experiments; + /** Initializes a new `IGListAdapter` object. diff --git a/Source/IGListKit/IGListAdapter.m b/Source/IGListKit/IGListAdapter.m index 0edf57470..2761206dd 100644 --- a/Source/IGListKit/IGListAdapter.m +++ b/Source/IGListKit/IGListAdapter.m @@ -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) { @@ -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]; }; @@ -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. @@ -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]; } @@ -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]; }