Skip to content

Skip dropped mapped node in PropsAnimatedNode.updateView instead of crashing#57298

Open
shashank-bhatotia wants to merge 1 commit into
react:mainfrom
shashank-bhatotia:props-animated-node-skip-dropped-mapped-node
Open

Skip dropped mapped node in PropsAnimatedNode.updateView instead of crashing#57298
shashank-bhatotia wants to merge 1 commit into
react:mainfrom
shashank-bhatotia:props-animated-node-skip-dropped-mapped-node

Conversation

@shashank-bhatotia

Copy link
Copy Markdown

Summary

PropsAnimatedNode.updateView() iterates its mapped property nodes every frame and calls requireNotNull(node) { "Mapped property node does not exist" } for each one. When a connected component is unmounted (for example during a navigation transition), its child animated nodes can be dropped from NativeAnimatedNodesManager while a frame callback for the prop node is still in flight. On the next updateView the mapped node is gone, requireNotNull throws, and the app crashes:

java.lang.IllegalArgumentException: Mapped property node does not exist
  at com.facebook.react.animated.PropsAnimatedNode.updateView(PropsAnimatedNode.kt)
  at com.facebook.react.animated.NativeAnimatedNodesManager.updateNodes(NativeAnimatedNodesManager.java)
  at com.facebook.react.animated.NativeAnimatedNodesManager.runUpdates(NativeAnimatedNodesManager.java)

This is a teardown race: by the time the mapped node has been removed, the connected view is being torn down, so there is no meaningful value to write for that prop on this frame. This change skips a missing mapped node instead of throwing.

It mirrors the guard already at the top of the same method, which returns early when the view itself is gone (connectedViewTag == -1), and matches the lenient behavior on iOS, where RCTPropsAnimatedNode iterates its parent nodes with isKindOfClass: checks and a missing (nil) node is simply skipped.

Fixes #37267.

Changelog:

[ANDROID] [FIXED] - Prevent "Mapped property node does not exist" crash in PropsAnimatedNode.updateView when a mapped node is removed during an in-flight native animation

Test Plan

The crash is a timing-dependent race, so it reproduces probabilistically rather than deterministically. Using the repro from #37267 (a screen with many simultaneous native-driver animations, navigating in and out repeatedly) and increasing Animator duration scale in Developer Options widens the window and makes it reproduce reliably on lower-end devices.

  • Before: rapidly navigating away from a screen with running native-driver animations crashes with IllegalArgumentException: Mapped property node does not exist.
  • After: the stale node is skipped and no crash occurs.
  • Happy path unaffected: when all mapped nodes are present, behavior is identical. The change only adds an early continue for the already-removed-node case, so no prop update is lost for live nodes.

…rashing

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 react#37267.
@meta-cla

meta-cla Bot commented Jun 21, 2026

Copy link
Copy Markdown

Hi @shashank-bhatotia!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 21, 2026
@meta-cla

meta-cla Bot commented Jun 21, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jun 21, 2026
@meta-codesync

meta-codesync Bot commented Jun 21, 2026

Copy link
Copy Markdown

@fabriziocucci has imported this pull request. If you are a Meta employee, you can view this in D109253948.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android App Crash with Animated node with tag (child) [xxxx] does not exists

1 participant