UITableView Auto Layout performance regression

Originator:futuretap
Number:rdar://27221045 Date Originated:07-Jul-2016 04:24 PM
Status:Duplicate/27103510/Open Resolved:
Product:iOS Product Version:10.0 b2
Classification:Performance Reproducible:Always
 
Summary:
When using UITableView with self sizing cells:

	tableView.rowHeight = UITableViewAutomaticDimension
	tableView.estimatedRowHeight = 44.0

and cells consisting of multiline labels, iOS 10 b2 shows a degraded scrolling performance over iOS 9.

Steps to Reproduce:
Run the attached sample app, a slightly modified version of @smileyborg's (your Tyler Fox) sample app (https://github.com/smileyborg/TableViewCellWithAutoLayoutiOS8). When scrolling, there are noticeable hickups as soon as a new cell appears.

When analyzing the performance in Instruments, UILabel.intrinsicContentSize() is the biggest offender. We counted how often this method is called per label in iOS 9 vs. iOS 10  when a new cell comes up:

7 times on iOS 9
9 times on iOS 10b2

In my opinion it should be sufficient to call it once (for the height calculation) or twice (another one for the actual layout operation) since this is an expensive operation. 9 times is definitely too often. Also, this number is for one label. For table view cells with multiple labels, the number goes up quickly which renders the whole concept of Auto Layout for table view cells useless.

Note: the problem is not limited to cells with UILabels. UITextView is affected as well.

see also rdar://27103510

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!