From 23d65b98351cc1555cf1e4c3c5b4166d47b0bded Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Wed, 20 Sep 2023 06:22:24 -0700 Subject: [PATCH] [macOS][Xcode 15] Avoid using dirtyRect in `drawRect:` (#2136) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apple made a breaking change in Xcode 15 / macOS Sonoma which breaks usages of drawRect:. You can no longer trust that the OS will provide you a dirtyRect will be within the bounds of your view. Specifically (from the appkit release notes): Filling the dirty rect of a view inside of -drawRect. A fairly common pattern is to simply rect fill the dirty rect passed into an override of NSView.draw(). The dirty rect can now extend outside of your view’s bounds. This pattern can be adjusted by filling the bounds instead of the dirty rect, or by setting clipsToBounds = true. This led to an unfortunate bug where any SVG drawn took up the full width/height of your window. Let's follow Apple's advice and draw using [self bounds] instead of dirtyRect. --- apple/Elements/RNSVGSvgView.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apple/Elements/RNSVGSvgView.mm b/apple/Elements/RNSVGSvgView.mm index a91fee4c3..4c1cc6a28 100644 --- a/apple/Elements/RNSVGSvgView.mm +++ b/apple/Elements/RNSVGSvgView.mm @@ -293,7 +293,7 @@ - (void)drawRect:(CGRect)rect _boundingBox = rect; CGContextRef context = UIGraphicsGetCurrentContext(); - [self drawToContext:context withRect:rect]; + [self drawToContext:context withRect:[self bounds]]; } - (RNSVGPlatformView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event