Infinite recursion and stack overflow when using self-sizing collection view cells

Originator:tom.catterall
Number:rdar://22948986 Date Originated:02-Oct-2015
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 9
Classification:Crash Reproducible:Always
 
Summary:
Under certain circumstances, a flow layout using estimated item size smashes the stack. The problem seems to be an unbounded recursion in `UICollectionView _updateVisibleCellsNow:`.

Steps to Reproduce:
Open the attached example project and build and run.

Expected Results:
I expect the cells to be correctly sized in the collection view.

Actual Results:
The app crashes about 4000 frames deep in `UICollectionView _updateVisibleCellsNow:`

Version:
iOS 9

Notes:
The problem was discovered while I was designing a custom flow layout. I was using arbitrary strings generated by arc4random, passed into a spelled out NSNumberFormatter, hence the oddly specific data.

Returning only one item in the data source, instead of 6, will show a correctly functioning app. Returning 2 will cause a crash, so I suspect it might be specific widths of cells.

I believe I have eliminated the possibility of constraint ambiguity. Adjusting the compression and hugging priorities to 1000 does not resolve the issue.

It may be possible to refine this bug further but without the symbols it's quite tough to see what's going!

Configuration:
iPhone Simulator and iOS device

Attachments:
'collection-view-bug.zip' was successfully uploaded.

Comments


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!