I am using Compositional Layout plus Diffable Data Source to display requested images in a single column inside a UICollectionView from the Photos Album using PhotoKit's Cached Image Manager.
I would like the image cell to be the entire width of the collection view and the height of the cell to be scaled to the height of the image using Aspect Fit content mode.
When I create the layout I use estimated height for both item and group layout objects.
But the initial height of each cell stays at the estimated height. As soon as I start scrolling, some of the cells do actually resize the height correctly, but not always.
Here is the sample code (replace the default ViewController.swift logic in a sample iOS project with the attached Sample Code):