CGContext boundingBoxOfPath returns wrong bounds

Originator:anton.marunko
Number:rdar://6468254639 Date Originated:25.06.2018
Status:Open Resolved:
Product:iOS + SDK (Core Graphics) Product Version:iOS 11.4 / 15F79
Classification:Serious bug Reproducible:always
 
Summary:

For cases like this:

let path = UIBezierPath()
path.move(to: CGPoint(x: 50, y: 50))
let to = CGPoint(x: 50, y: 10)
let p1 = CGPoint(x: 20, y: 20)
let p2 = CGPoint(x: 40, y: 20)
path.addCurve(to: to, controlPoint1: p1, controlPoint2: p2)
let cgPath = path.cgPath
print(cgPath.boundingBoxOfPath) // valid: (34.16, 10.0, 15.84, 40.0)
ctx.addPath(cgPath)
print(ctx.boundingBoxOfPath)  // invalid: (20.0, 10.0, 30.0, 40.0)

boundingBoxOfPath return wrong results

Steps to Reproduce:

just paste this code into the project with core graphics included.

Expected Results:

The path has bounds - 34.16, 10.0, 15.84, 40.0

Actual Results:

The path has bounds - 20.0, 10.0, 30.0, 40.0

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!