Skip to content

Batch Android animated prop updates into one JNI call per surface - #58765

Closed
bartlomiejbloniarz wants to merge 2 commits into
animated-props-routingfrom
animated-props-android
Closed

bartlomiejbloniarz wants to merge 2 commits into
animated-props-routingfrom
animated-props-android

Conversation

@bartlomiejbloniarz

Copy link
Copy Markdown
Contributor

Summary:

With the batched delegate from the previous PR, Android applied the backend's synchronous updates with one JNI call and one ReadableNativeMap per view per frame. When optimizedAnimatedPropUpdates is on, a surface's updates now go to the UI thread in a single call: FabricMountingManager::synchronouslyUpdateAnimatedProps encodes them into int and double buffers, and BatchedAnimatedPropsMountItem decodes and applies them. This continues the encoder and mount item from #56468. Views that are not mounted yet are still queued.

A view is packed only when every prop it carries has a command. Unsupported props, null resets, platform colors, malformed values and typed props send the whole view through the existing packAnimatedProps serializer as a map instead. The commands cover the props Reanimated applies synchronously on Android, following the parity review in #56468 (comment). Angles are converted to radians in C++, and radii and translations keep their px or percent units. Because the decoder produces JavaOnlyArray transforms, TransformHelper's Kotlin conversion now applies a uniform scale to Z as well as X and Y, matching the native conversion when scale is combined with 3D rotation.

On a low-end Android phone (4× Cortex-A53) with 12 views animating opacity, UI-thread time per frame's synchronous batch dropped from about 6.5 ms to 3.4 ms.

Changelog:

[Android] [Performance] - Batch synchronous animated prop updates when optimizedAnimatedPropUpdates is enabled

Test Plan:

  • JVM: BatchedAnimatedPropsMountItemTest, MountingManagerAnimatedPropsTest, MatrixMathHelperTest and SkewMatrixHelperTest pass. The scale regression test fails without the TransformHelper change.
  • Native: the encoder, registry and RawProps tests pass on Android. The numeric-color fallback test fails without the checked conversion.
  • The Android arm64 release build succeeds. C++ API snapshots regenerated. Not built for iOS.

Summary:

With the batched delegate from the previous PR, Android applied the backend's synchronous updates with one JNI call and one `ReadableNativeMap` per view per frame. When `optimizedAnimatedPropUpdates` is on, a surface's updates now go to the UI thread in a single call: `FabricMountingManager::synchronouslyUpdateAnimatedProps` encodes them into int and double buffers, and `BatchedAnimatedPropsMountItem` decodes and applies them. This continues the encoder and mount item from #56468. Views that are not mounted yet are still queued.

A view is packed only when every prop it carries has a command. Unsupported props, null resets, platform colors, malformed values and typed props send the whole view through the existing `packAnimatedProps` serializer as a map instead. The commands cover the props Reanimated applies synchronously on Android, following the parity review in #56468 (comment). Angles are converted to radians in C++, and radii and translations keep their px or percent units. Because the decoder produces `JavaOnlyArray` transforms, `TransformHelper`'s Kotlin conversion now applies a uniform scale to Z as well as X and Y, matching the native conversion when scale is combined with 3D rotation.

On a low-end Android phone (4× Cortex-A53) with 12 views animating opacity, UI-thread time per frame's synchronous batch dropped from about 6.5 ms to 3.4 ms.

Changelog:

[Android][Performance] - Batch synchronous animated prop updates when `optimizedAnimatedPropUpdates` is enabled

Test Plan:

- JVM: `BatchedAnimatedPropsMountItemTest`, `MountingManagerAnimatedPropsTest`, `MatrixMathHelperTest` and `SkewMatrixHelperTest` pass. The scale regression test fails without the `TransformHelper` change.
- Native: the encoder, registry and `RawProps` tests pass on Android. The numeric-color fallback test fails without the checked conversion.
- The Android arm64 release build succeeds. C++ API snapshots regenerated. Not built for iOS.
…sts and scaffolding

Tests and C++ API snapshots for the change in the parent commit.
@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 Sep 30, 2026
@facebook-github-tools facebook-github-tools Bot added p: Software Mansion Partner: Software Mansion Partner labels Sep 30, 2026
@bartlomiejbloniarz
bartlomiejbloniarz added this pull request to stack #58767 September 30, 2026 13:00
@facebook-github-tools facebook-github-tools Bot added the p: Facebook Partner: Facebook label Sep 30, 2026
@github-actions

Copy link
Copy Markdown

Caution

Invalid Changelog Format

Please verify your Changelog format. See Changelog format

Caution

Invalid Base Branch

The base branch for this PR is animated-props-routing, which is not main or a -stable branch.
Are you sure you want to target this branch?

@bartlomiejbloniarz
bartlomiejbloniarz deleted the animated-props-android branch October 1, 2026 08:45
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. p: Facebook Partner: Facebook p: Software Mansion Partner: Software Mansion Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant