Skip to content

Commit

Permalink
[macOS][Xcode 15] Avoid using dirtyRect in drawRect: (#2136)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Saadnajmi committed Sep 20, 2023
1 parent 234f7b7 commit 23d65b9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion apple/Elements/RNSVGSvgView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 23d65b9

Please sign in to comment.