CGPathAddPath in a loop extremely slow

I am seeing severe performance degradation in my app within core graphics with ios13 (currently have 13.3.1). I call CGPathAddPath in a loop. This used to take a couple of seconds prior to ios13 and now take 30 seconds. When I profiled the code it is showing up taking all the time in CG::Path::recalculate_bounding_box. Anyone seen this issue and has a solution? How do I log a defect with Apple?

if ( !CGAffineTransformIsIdentity(transform) )

{

CGMutablePathRef mutablePath = CGPathCreateMutable();

CGMutablePathRef mutableStrokePath = CGPathCreateMutable();

for ( MONDesignPath * dp in _designPaths)

{

[dp transformPathWithTransform: transform];

CGPathAddPath(mutablePath, NULL, dp.path);

CGPathAddPath(mutableStrokePath, NULL, dp.strokePath);

}

if ( _path) CGPathRelease(_path);

_path = mutablePath; // This will not call the setter as not prefixed by self.

if ( _strokePath) CGPathRelease(_strokePath);

_strokePath = mutableStrokePath; // This will not call the setter as not prefixed by self.

}

Replies

I have similar issues. I have a view drawing lots of simple lines, working just OK performance wise. But if I draw ellipses instead (commented out line below), the code slows down considerably.

Code Block Swift
func path(in rect: CGRect) -> Path {
      var path = Path()
// ...
      path.addLine(to: CGPoint(x: xOrigin + xTarget, y: yOrigin))
      // path.addEllipse(in: CGRect(origin: CGPoint(x: xOrigin + xTarget, y: yOrigin-1), size: CGSize(width: 3, height: 3)))

Most of the time (84.9% according to Instruments profiler ) is spent in CG::Path::recalculate_bounding_box().

Any hints on how to draw repeatedly and effectively hundreds of rects using Path?