Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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]
}
Expand Down