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 3b5816a7e21c..ff07aee0c8e4 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 @@ -756,9 +756,14 @@ internal constructor( return } - val view = getViewState(reactTag).view + val viewState = getNullableViewState(reactTag) + val view = viewState?.view if (view == null) { - throw RetryableMountingLayerException("Unable to find viewState view for tag $reactTag") + ReactSoftExceptionLogger.logSoftException( + ReactSoftExceptionLogger.Categories.SURFACE_MOUNTING_MANAGER_MISSING_VIEWSTATE, + ReactNoCrashSoftException("Unable to find viewState for tag $reactTag for sendAccessibilityEvent"), + ) + return } view.sendAccessibilityEvent(eventType) @@ -1000,16 +1005,22 @@ internal constructor( return } - val viewState = getViewState(reactTag) - val view = viewState.view + val viewState = getNullableViewState(reactTag) + + val view = viewState?.view + if (view == null) { + ReactSoftExceptionLogger.logSoftException( + ReactSoftExceptionLogger.Categories.SURFACE_MOUNTING_MANAGER_MISSING_VIEWSTATE, + ReactNoCrashSoftException("Unable to find viewState for tag $reactTag for setJSResponder"), + ) + return + } + if (initialReactTag != reactTag && view is ViewParent) { // In this case, initialReactTag corresponds to a virtual/layout-only View, and we already // have a parent of that View in reactTag, so we can use it. jsResponderHandler.setJSResponder(initialReactTag, view as ViewParent) return - } else if (view == null) { - SoftAssertions.assertUnreachable("Cannot find view for tag [$reactTag].") - return } if (viewState.isRoot) { @@ -1118,12 +1129,6 @@ internal constructor( ) } - private fun getViewState(reactTag: Int): ViewState = - getNullableViewState(reactTag) - ?: throw RetryableMountingLayerException( - "Unable to find viewState for tag $reactTag. Surface stopped: $isStopped" - ) - private fun getNullableViewState(reactTag: Int): ViewState? = registryLock.read { tagToViewState[reactTag] }