From 7c5d6a96bd8355f989e526d33cf30705fc41d7d3 Mon Sep 17 00:00:00 2001 From: Gregory Moskaliuk Date: Mon, 19 Oct 2026 23:28:41 +0200 Subject: [PATCH] Skip the clear background attribute on iOS Text TextAttributes default backgroundColor to clearColor(), so every fragment of every Text got NSBackgroundColorAttributeName set to a transparent color, and TextKit computed and filled the background rects of each run on every draw without changing any pixel. Set the attribute only for a background color that isn't clear. Co-Authored-By: Claude Opus 5.5 --- .../react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm index 95ff5a0d180e..927c3c296432 100644 --- a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm +++ b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm @@ -205,7 +205,8 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex attributes[NSForegroundColorAttributeName] = effectiveForegroundColor; } - if (textAttributes.backgroundColor || !isnan(textAttributes.opacity)) { + // A clear background draws nothing, but TextKit still computes and fills its rects on every draw. + if (textAttributes.backgroundColor && textAttributes.backgroundColor != clearColor()) { attributes[NSBackgroundColorAttributeName] = RCTEffectiveBackgroundColorFromTextAttributes(textAttributes); }