setNeedsDisplay grows linear with drawRect:

Number:rdar://31113056 Date Originated:17-Mar-2017
Status:Open Resolved:
Product:iOS + SDK Product Version:
Classification:Performance Reproducible:Always

setNeedsDisplay should notify the system that the view needs to be redrawn but return immediately. In the attached Playground and Screenshot you can see that the time in setNeedsDisplay grows linear with the time spent in drawRect:.

Steps to Reproduce:
1. Open attached playground
2. add graphs for the variables `timeInSetNeedsDisplay` and `timeInDrawRect`
3. draw by panning in the live view

Expected Results:
setNeedsDisplay should return in constant time

Actual Results:
setNeedsDisplay grows linear with drawRect:

Swift Playground, Macbook Pro, macOS 10.12.3, Xcode 8.2.1


Swift Playground, Macbook Pro 10.12.3, Xcode 8.2.1

Playground can be found here:
Screenshot with results on Twitter:


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at 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!