Skip to content

Commit da668bf

Browse files
Skip dropped mapped node in PropsAnimatedNode.updateView instead of crashing
A mapped child node can be removed from NativeAnimatedNodesManager (e.g. its component unmounted during a navigation transition) between animation frames while the prop node is still queued for an update. updateView() then calls requireNotNull on the missing node and throws IllegalArgumentException: "Mapped property node does not exist", crashing the app on a benign teardown race. Skip the stale node instead, mirroring the connectedViewTag == -1 early-return at the top of the method. Fixes #37267.
1 parent 27e83d0 commit da668bf

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/PropsAnimatedNode.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,15 @@ internal class PropsAnimatedNode(
7575
}
7676
for ((key, value) in propNodeMapping) {
7777
val node = nativeAnimatedNodesManager.getNodeById(value)
78-
requireNotNull(node) { "Mapped property node does not exist" }
78+
// A mapped child node can be dropped (e.g. its component unmounted during
79+
// navigation) between animation frames while this prop node is still
80+
// queued for an update. Skip the stale node instead of throwing: the
81+
// connected view is being torn down, so there is no meaningful value to
82+
// write for this prop on this frame. Mirrors the connectedViewTag == -1
83+
// early-return above. Fixes #37267.
84+
if (node == null) {
85+
continue
86+
}
7987
if (node is StyleAnimatedNode) {
8088
node.collectViewUpdates(propMap)
8189
} else if (node is ValueAnimatedNode) {

0 commit comments

Comments
 (0)