Skip to content

Process event-driven animations synchronously on every event (#56439)#56439

Closed
markv wants to merge 1 commit intofacebook:mainfrom
markv:export-D100719854
Closed

Process event-driven animations synchronously on every event (#56439)#56439
markv wants to merge 1 commit intofacebook:mainfrom
markv:export-D100719854

Conversation

@markv
Copy link
Copy Markdown
Contributor

@markv markv commented Apr 14, 2026

Summary:

The C++ NativeAnimatedNodesManager only processes the first scroll event in a gesture synchronously via trigger()/onRender(). Subsequent events just store the updated value and defer graph traversal + prop commit to the next choreographer frame, introducing ~16ms (1 frame) latency.

This differs from the Java NativeAnimatedNodesManager which calls updateNodes() → updateView() → synchronouslyUpdateViewOnUIThread() for every event with no gating.

The issue was the !isEventAnimationInProgress_ guard at line 502, which prevented trigger()/onRender() from running on the 2nd+ events. isEventAnimationInProgress_ stays true for the entire scroll gesture (only resets when a choreographer frame produces zero changes), so every scroll event after the first was deferred.

This change moves the trigger()/onRender() call outside the !isEventAnimationInProgress_ gate so every scroll event gets immediate synchronous processing, matching the Java implementation. The startRenderCallbackIfNeeded + isEventAnimationInProgress_ setup still only happens once (first event).

Changelog:

[General] [Fixed] - Fix 1-frame latency in C++ NativeAnimatedNodesManager for event-driven animations by processing the animation graph synchronously on every scroll event, matching the Java implementation behavior

Reviewed By: zeyap

Differential Revision: D100719854

@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 Apr 14, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Apr 14, 2026

@markv has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100719854.

…k#56439)

Summary:

The C++ NativeAnimatedNodesManager only processes the first scroll event in a gesture synchronously via trigger()/onRender(). Subsequent events just store the updated value and defer graph traversal + prop commit to the next choreographer frame, introducing ~16ms (1 frame) latency.

This differs from the Java NativeAnimatedNodesManager which calls updateNodes() → updateView() → synchronouslyUpdateViewOnUIThread() for every event with no gating.

The issue was the `!isEventAnimationInProgress_` guard at line 502, which prevented trigger()/onRender() from running on the 2nd+ events. `isEventAnimationInProgress_` stays true for the entire scroll gesture (only resets when a choreographer frame produces zero changes), so every scroll event after the first was deferred.

This change moves the trigger()/onRender() call outside the `!isEventAnimationInProgress_` gate so every scroll event gets immediate synchronous processing, matching the Java implementation. The startRenderCallbackIfNeeded + isEventAnimationInProgress_ setup still only happens once (first event).

## Changelog:
[General] [Fixed] - Fix 1-frame latency in C++ NativeAnimatedNodesManager for event-driven animations by processing the animation graph synchronously on every scroll event, matching the Java implementation behavior

Reviewed By: zeyap

Differential Revision: D100719854
@meta-codesync meta-codesync bot changed the title Process event-driven animations synchronously on every event Process event-driven animations synchronously on every event (#56439) Apr 14, 2026
@markv markv force-pushed the export-D100719854 branch from 451c0d1 to 6279477 Compare April 14, 2026 18:16
@meta-codesync meta-codesync bot closed this in 0517fb5 Apr 14, 2026
@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by Mark Verlingieri in 0517fb5

When will my fix make it into a release? | How to file a pick request?

@react-native-bot react-native-bot added the Merged This PR has been merged. label Apr 14, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Apr 14, 2026

This pull request has been merged in 0517fb5.

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. fb-exported Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants