kishikawakatsumi / IBPCollectionViewCompositionalLayout

Backport of UICollectionViewCompositionalLayout to earlier iOS 12

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Performance issue during scroll / always create new cell instances

DavidObfuscator opened this issue · comments

Hi,
i have performance issues with the IBPUICollectionViewCompositionalLayout.

During the scroll, the IBPUICollectionViewCompositionalLayout's layoutAttributesForElementsInRect method always ask data source for the cell, if we use estimated item size and item contentInsets.

the documentation / comments says:
contentInsets are ignored for any axis with an .estimated dimension
which is not ignored, makes the performance really bad.

Even if the collectionView's dequeueReusableCell method are used, it creates a new instance of the cell (and run the layouting)

Issue is on iOS 12, there is no any unwanted cell creation or performance issue on iOS 13

how to reproduce:
use estimated item height in Examples/ListViewController2:
change:
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .fractionalHeight(1.0))
to:
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .estimated(10.0))