From 53e3f364cf737fc9fd54e8a347a79269f6eaee6f Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Thu, 15 Feb 2024 05:39:23 -0800 Subject: [PATCH] Fix incorrect cast in RemoveDeleteTree (#43018) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43018 Assuming that if View is a ViewGroup, its ViewManager is a ViewGroupManager is incorrect. Custom ViewManagers may use ViewGroups internally to represent complex views exposed to JS. Type-check the ViewManager instead to avoid the crash seen in T178300877 Changelog: [Internal] Reviewed By: cortinico Differential Revision: D53586565 fbshipit-source-id: 49408098cebc7f76d8be0e585187ba9b6ca52049 --- .../react/fabric/mounting/SurfaceMountingManager.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java index b423b44a3ca..3784ab2e14a 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java @@ -1432,8 +1432,9 @@ public class SurfaceMountingManager { ViewState thisViewState = getNullableViewState(reactTag); if (thisViewState != null) { View thisView = thisViewState.mView; - if (thisView instanceof ViewGroup) { - IViewGroupManager viewManager = getViewGroupManager(thisViewState); + ViewManager thisViewManager = thisViewState.mViewManager; + if (thisViewManager instanceof IViewGroupManager) { + IViewGroupManager viewManager = (IViewGroupManager) thisViewManager; // Children are managed by React Native if both of the following are true: // 1) There are 1 or more children of this View, which must be a ViewGroup