UICollectionViewCompositionalLayout stuck in an infinite cycle, filling the memory and crashing in the end

Number:rdar://FB7716084 Date Originated:27-05-2020
Status:Open Resolved:No
Product:iOS/UIKit Product Version:13.5
Classification:Incorrect/Unexpected Behavior Reproducible:Yes
Which area are you seeing an issue with?

Please describe the issue and what steps we can take to reproduce it:

When NSCollectionLayoutSize width dimension is larger than the screen size, it is stuck and in the end crashes the app due to insufficient memory.

It looks like the app is allocating infinite amount of memory due to infinite cycle in layoutSubviews method.

This happens when either set:

- Fractional width to higher than 1.0 (.fractionalWidth(1.1))
- Estimated size to larger than screen width (.estimated(9999))

The behaviour is consistent both on simulator and on the device.

Used tools:

- Xcode Version 11.5 (11E608c)
- iOS 13.5 (17F75)


We’ve isolated the issue and are able to reproduce it just by changing one value in the Apple provided sample code:


1. Download the example.
2. Open ConferenceVideoSessionsViewController.swift file
3. Change line 32 to wrong dimension (higher than the screen width).
4. Try to open this screen in simulator or on the device
5. The view controller is not presented and the app crashes after a while.


- Screenshots from Xcode and the sample application when it is stuck.
- Apple sample code with the change which is crashing when you try to open Conference Videos screen.

Expected behaviour:

If this is not supported and most likely like a programmer error I would expect at least receiving something like internal inconsistency exception.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!