From 7afb8ab3054e019ca83efbd737fd11487400aba9 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Tue, 29 Jul 2025 09:43:44 -0700 Subject: [PATCH] disable subview clipping traversal when view culling is enabled (#52903) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52903 changelog: [internal] disable subview clipping traversal when view culling is enabled. Subview clipping is already disabled by preventing prop from being set to true: https://fburl.com/code/bynvtwfs but we found a crash where the traversal leads to memory corruption with view culling enabled. Reviewed By: lenaic Differential Revision: D79168116 fbshipit-source-id: 9dcb624ca12bc2d94b265681795604ee0ac3fe00 --- .../ScrollView/RCTScrollViewComponentView.mm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index a3191aa4372..d09026fa9a0 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -947,6 +947,10 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu - (void)_remountChildrenIfNeeded { + if (ReactNativeFeatureFlags::enableViewCulling()) { + return; + } + CGPoint contentOffset = _scrollView.contentOffset; if (std::abs(_contentOffsetWhenClipped.x - contentOffset.x) < kClippingLeeway && @@ -961,6 +965,10 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu - (void)_remountChildren { + if (ReactNativeFeatureFlags::enableViewCulling()) { + return; + } + [_scrollView updateClippedSubviewsWithClipRect:CGRectInset(_scrollView.bounds, -kClippingLeeway, -kClippingLeeway) relativeToView:_scrollView]; }