From d868859554ebcd5c387584039b9fb68f89ad756c Mon Sep 17 00:00:00 2001 From: Scott Goodson Date: Sun, 23 Apr 2017 17:48:43 -0700 Subject: [PATCH] [ASCollectionView] Prevent prefetching from being enabled to eliminate overhead. Some apps explicitly enable this, which is counterproductive with ASDK. --- Source/ASCollectionView.mm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Source/ASCollectionView.mm b/Source/ASCollectionView.mm index f8b466bc7..7b6b27e09 100644 --- a/Source/ASCollectionView.mm +++ b/Source/ASCollectionView.mm @@ -251,12 +251,12 @@ - (instancetype)_initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionV if (!(self = [super initWithFrame:frame collectionViewLayout:layout])) return nil; - // Disable UICollectionView prefetching. + // Disable UICollectionView prefetching. Use super, because self disables this method. // Experiments done by Instagram show that this option being YES (default) // when unused causes a significant hit to scroll performance. // https://github.com/Instagram/IGListKit/issues/318 if (AS_AT_LEAST_IOS10) { - self.prefetchingEnabled = NO; + super.prefetchingEnabled = NO; } _layoutController = [[ASCollectionViewLayoutController alloc] initWithCollectionView:self]; @@ -2091,6 +2091,16 @@ - (void)layer:(CALayer *)layer didChangeBoundsWithOldValue:(CGRect)oldBounds new #pragma mark - UICollectionView dead-end intercepts +- (void)setPrefetchDataSource:(id)prefetchDataSource +{ + return; +} + +- (void)setPrefetchingEnabled:(BOOL)prefetchingEnabled +{ + return; +} + #if ASDISPLAYNODE_ASSERTIONS_ENABLED // Remove implementations entirely for efficiency if not asserting. // intercepted due to not being supported by ASCollectionView (prevent bugs caused by usage)