From 4d94021a3934db81753c5158a3bcf991bf71b5a6 Mon Sep 17 00:00:00 2001 From: Bartlomiej Bloniarz Date: Thu, 19 Mar 2026 05:10:50 -0700 Subject: [PATCH] Add null check for ViewState in SurfaceMountingManager::updateProps Summary: I saw that in D95793355 a null check was added for the view state in updateLayout. A similar issue can happen (and has been happening with Reanimated) with the updateProps method, so this diff makes it consistent with the other codepaths. ## Changelog: [General] [Changed] - use getNullableViewState in SurfaceMountingManager::updateProps and log a soft exception instead Differential Revision: D97087668 --- .../react/fabric/mounting/SurfaceMountingManager.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.kt index bb82a0676c1..485dd80d02f 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.kt @@ -608,7 +608,14 @@ internal constructor( return } - val viewState = getViewState(reactTag) + val viewState = getNullableViewState(reactTag) + if (viewState == null) { + ReactSoftExceptionLogger.logSoftException( + ReactSoftExceptionLogger.Categories.SURFACE_MOUNTING_MANAGER_MISSING_VIEWSTATE, + ReactNoCrashSoftException("Unable to find viewState for tag $reactTag for updateProps"), + ) + return + } if ( ReactNativeFeatureFlags.overrideBySynchronousMountPropsAtMountingAndroid() && @@ -624,7 +631,7 @@ internal constructor( viewState.currentProps = ReactStylesDiffMap(props) } - val view: View = checkNotNull(viewState.view) { "Unable to find view for tag [$reactTag]" } + val view: View = viewState.view ?: return checkNotNull(viewState.viewManager).updateProperties(view, viewState.currentProps) }