CALayer shadow renders incorrect in manually created CGContext

Originator:an00na
Number:rdar://31888650 Date Originated:April 28, 2017 11:28 AM
Status:Open Resolved:
Product:iOS + SDK Product Version:10.3
Classification:UI/Usability Reproducible:Always
 
Area:
Core Animation


Summary:
On a 2x device, rendering a CALayer with shadowRadius = r and shadowOffset = (x, y) in a manually created CGContext using CALayer.render(in:) produces a shadow with shadowRadius = r/2 and shadowOffset = (x/2, -y/2), as if transformation matrix is not set up and still in the initial state even though it is already correctly set up.

If the context is set up using UIGraphicsBeginImageContextWithOptions the result is correct.

Even if I create my own context based on the context created with UIGraphicsBeginImageContextWithOptions the result is still wrong.


Steps to Reproduce:
1. Launch sample app.
2. Tap Render button.
3. Check saved images in Photos app.


Code:
https://cloudup.com/cZZBSCTbDJy

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!