From 3b07fb7426b63f23ecd53b9c11dc1cd57af217fe Mon Sep 17 00:00:00 2001 From: Nick Lefever Date: Mon, 10 Mar 2025 19:00:36 -0700 Subject: [PATCH] Disable clipped view removal on recycle (#49938) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/49938 Recycling a `ReactViewGroup` will lead to all child views being removed from the view. To avoid having view recycling corrupt the clipping state set for the child views, ahead of base view recycling preparation this diff disables `removeClippedSubviews` so that layout changes don't run over all child views that will end up being removed anyway. The bug reported earlier should already have been resolved by D70672120 since the view recycling of a child view would remove the view from the parent. Meaning the ReactViewGroup can only have subviews that are not prepared for recycling, any recycled view would have been removed from their parent (the ReactViewGroup) Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D70921641 fbshipit-source-id: a8b311169b268c09400d2b62008184e379f6fe79 --- .../java/com/facebook/react/views/view/ReactViewManager.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.kt index 233be99a71e..49f724944b0 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.kt @@ -73,6 +73,10 @@ public open class ReactViewManager : ReactClippingViewManager() reactContext: ThemedReactContext, view: ReactViewGroup ): ReactViewGroup? { + // We don't want to run the view clipping when the view is being prepared for recycling to avoid + // have size changes iterate over child view that should be removed anyway + view.removeClippedSubviews = false + // BaseViewManager val preparedView = super.prepareToRecycleView(reactContext, view) preparedView?.recycleView()