UIGraphicsImageRenderer does not respect UITraitCollection's displayScale

Number:rdar://46554126 Date Originated:07-Dec-2018 05:07 PM
Status:Closed Resolved:
Product:iOS + SDK Product Version:12.0
Classification:Security Reproducible:Always
UIGraphicsImageRenderer behaves slightly differently when used on 2x and 3x display size devices even though its UITraitCollection (set via UIGraphicsRendererFormat) is set to a different displayScale.

Steps to Reproduce:
1. Initialize a UIGraphicsImageRenderer with UITraitCollection with displayScale of 2
2. Render an image on a 2x Simulator such as “iPhone 7” and save it
3. Render an image on a 3x Simulator such as “iPhone 7 Plus” and save it
4. Compare the images

Expected Results:
The images are identical.

Actual Results:
The images are slightly different, especially the fonts.


I’ve attached an Xcode project that shows the issue.

You can run the test case on a 2x device (such as iPhone 7), where it will pass.
When the test case is run on a 3x device (such as iPhone 7 Plus), the snapshot will look slightly different.

There is also an image that shows the differences explicitly.


Apple Developer Relations

This issue behaves as intended based on the following: It's expected that different devices will render fonts slightly different. Also when rendering 2x device int 2x context, there is no pixel interpolation required. When rendering 3x into 2x CoreGraphics will interpolate pixels and CoreGraphics's interpolator (in-process) is different from the one used by CoreAnimation (in render server), so it's expected to see different end results. We are now closing this bug report. If you have questions about the resolution, or if this is still a critical issue for you, then please update your bug report with that information. Please be sure to regularly check new Apple releases for any updates that might affect this issue.

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!