mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Fix IllegalStateException in SurfaceMountingManager.removeViewAt (#57860)
Summary: Pull Request resolved: https://github.com/react/react-native/pull/57860 Fix a crash in `SurfaceMountingManager.removeViewAt()` where an `IllegalStateException` is thrown when the parent view is not a `ViewGroup`. The Fabric differ can emit inconsistent remove instructions that reference a parent whose instantiated view is no longer a `ViewGroup` (e.g. after view recycling). Since a non-`ViewGroup` cannot hold child views, the removal is a semantic no-op. Replace the hard throw with `ReactSoftExceptionLogger.logSoftException` + early return, matching the defensive pattern already used by peer conditions in the same method (null `parentViewState`, child already removed, wrong index). Also fixes a "a a" typo in the error message. Changelog: [Android] [Fixed] - Fix IllegalStateException in SurfaceMountingManager.removeViewAt Reviewed By: zeyap Differential Revision: D115211130 fbshipit-source-id: 942a5fea8f31927ded86774c2e01cd01225179c5
This commit is contained in:
1 parent
0f1bdddfb3
commit
3f553d76bc
1 file changed
+7
-4
+7
-4
@@ -427,10 +427,13 @@ internal constructor(
|
||||
val parentView = parentViewState.view
|
||||
checkNotNull(parentView) { "Unable to find parentView for tag $parentTag" }
|
||||
if (parentView !is ViewGroup) {
|
||||
val message =
|
||||
"Unable to remove a view from a a non-ViewGroup ${parentView.javaClass.simpleName} when removing [$tag] from parent [$parentTag]"
|
||||
FLog.e(TAG, message)
|
||||
throw IllegalStateException(message)
|
||||
ReactSoftExceptionLogger.logSoftException(
|
||||
TAG,
|
||||
ReactNoCrashSoftException(
|
||||
"Unable to remove a view from a non-ViewGroup ${parentView.javaClass.simpleName} when removing [$tag] from parent [$parentTag]"
|
||||
),
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
if (SHOW_CHANGED_VIEW_HIERARCHIES) {
|
||||
|
||||
Reference in new issue
Block a user