Skip to content

Keep static styles set after a native-driver animation with the shared animation backend - #60604

Open
Nishant-96 wants to merge 1 commit into
react:mainfrom
Nishant-96:fix-static-style-after-native-animation
Open

Nishant-96 wants to merge 1 commit into
react:mainfrom
Nishant-96:fix-static-style-after-native-animation

Conversation

@Nishant-96

Copy link
Copy Markdown

Summary:

Fixes #60603.

With the shared animation backend, if a view finishes a useNativeDriver: true animation and you then give it a static value for the same prop, it keeps the last animated value. Fade to 0.2, switch to opacity: 0.6, and it stays at 0.2.

Three things put the old value back:

  • AnimationBackendCommitHook applies the registry snapshot on top of React's commit, and the snapshot still has the animated value.
  • On Android, SurfaceMountingManager keeps re-applying opacity/transform from the synchronous path on every mount until it gets a null, which never comes.
  • The end callback can reach JS before the last frame reaches the registry, so that frame occasionally lands after the static value.

What this changes:

  • When an AnimatedProps node stops driving a prop, JS releases it in the insertion effect, before React's commit, through a new optional releaseAnimatedProps. Values are processed with the view's validAttributes, and removed props go as null.
  • The registry swaps the released keys for React's values and drops them from later animation updates until the old node disconnects. The backend also requests a flush, since React won't commit if its value didn't change.
  • Android gets a pre-mount item that clears the released keys from the synchronous override without touching the view (clearSynchronousMountPropsOverride, a no-op elsewhere).

This touches SurfaceMountingManager like #60471, happy to rebase whichever lands first.

Changelog:

[General] [Fixed] - Fix a view keeping its last native-driver animated value after switching to a static style with the shared animation backend

Test Plan:

  • Fantom: new cases in AnimatedBackend-itest.js compare the view after the switch with the same style rendered without an animation (opacity, transform, colors, layout props, removing the prop, switching mid-animation, a prop that keeps animating, a shared value, switching twice). 124/124 pass. Without the JS release call, 34 fail.
  • gtests in AnimatedPropsRegistryTest for the release and for dropping late updates, run through the Fantom tester build (animationbackend, animated, uimanager, scheduler suites all pass). Disabling the filter fails the two late-update tests.
  • Kotlin: 4 new cases in SurfaceMountingManagerSynchronousMountPropsTest, 13/13.
  • yarn jest (Animated), flow, lint, formatters, build-types --validate, android-api-validate, C++ API snapshots regenerated.
  • Ran the repro from Static style right after a native-driver animation keeps the animated value (shared animation backend) #60603 on 0.90.0-nightly-20261205 in Release on the iOS simulator and an Android emulator (ReactAndroid built from source). Before is the stock nightly, after has this patch, same taps:

iOS:

Android:

@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Dec 5, 2026
…d animation backend

Fixes react#60603.

Signed-off-by: Nishant Pratihast <87017414+Nishant-96@users.noreply.github.com>
@Nishant-96
Nishant-96 force-pushed the fix-static-style-after-native-animation branch from 86b8eb0 to 911998d Compare December 5, 2026 21:52

This branch has not been deployed

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

Labels

Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Static style right after a native-driver animation keeps the animated value (shared animation backend)

1 participant