From 5a141094ce93d1e01077b2edad849a888af12e2e Mon Sep 17 00:00:00 2001 From: andyfinnell Date: Wed, 21 May 2025 15:56:25 -0400 Subject: [PATCH] Check for batch fetching on scroll ## Summary For collection views, we do not currently check for batch fetching on scroll. This appears to be a bug, as `scrollViewDidScroll:` does call `_checkForBatchFetching`, and [the commit that added it states it's trying to check on each scroll](https://github.com/TextureGroup/Texture/commit/df497b82c286771658a0ef0826945c716baaa783). Unfortunately, `_checkForBatchFetching` checks for `isTracking` and `isDragging` first and returns if either are `YES`. Since we're in a scroll, they are `YES`. So the call is effectively a no-op. This bug has been around for 9 years and I'm unsure of the performance implications of turning the batch fetching check on for each scroll tick. Therefore, put the fix behind an experiment feature flag _and_ only call it on the first scroll tick for the scroll session, instead of every scroll tick. Finally, I moved the check after the delegate call, in case the delegate has logic in it to turn on or off the batch fetching. ## Test plan Ran the app and manually tested batching getting called or not. Also ran `build.sh tests`. --- Source/ASCollectionView.mm | 17 ++++++++++++++++- Source/ASExperimentalFeatures.h | 1 + Source/ASExperimentalFeatures.mm | 3 ++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Source/ASCollectionView.mm b/Source/ASCollectionView.mm index 1ff6062a4..a190abe03 100644 --- a/Source/ASCollectionView.mm +++ b/Source/ASCollectionView.mm @@ -142,6 +142,12 @@ @interface ASCollectionView ()