Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

CGContextAddArc not respecting clipping rects for open paths

macOS 15.2, MBP M1, built-in display.

The following code produces a line outside the bounds of my clipping region when drawing to CGLayers, to produce a clockwise arc:

    CGContextBeginPath(m_s.outContext);
    CGContextAddArc(m_s.outContext, leftX + radius, topY - radius, radius, -startRads, -endRads, 1);
    CGContextSetRGBStrokeColor(m_s.outContext, col.fRed(), col.fGreen(), col.fBlue(), col.fAlpha());
    CGContextSetLineWidth(m_s.outContext, width);
    CGContextStrokePath(m_s.outContext);

Drawing other shapes such as rects or ellipses doesn't cause a problem.

I can work around the issue by bringing the path back to the start of the arc:

    CGContextBeginPath(m_s.outContext);
    CGContextAddArc(m_s.outContext, leftX + radius, topY - radius, radius, -startRads, -endRads, 1);
    // add a second arc back to the start
    CGContextAddArc(m_s.outContext, leftX + radius, topY - radius, radius, -endRads, -startRads, 0);
    CGContextSetRGBStrokeColor(m_s.outContext, col.fRed(), col.fGreen(), col.fBlue(), col.fAlpha());
    CGContextSetLineWidth(m_s.outContext, width);
    CGContextStrokePath(m_s.outContext);

But this does appear to be a bug.

I tried to reproduce the problem you described here, but I could only guess what the values stored in your variables were. Can you provide a version with the values you're using?

CGContextAddArc not respecting clipping rects for open paths
 
 
Q