Commit e4f0509
Add pushAnimationMutations to the AnimationBackend (#56401)
Summary:
Pull Request resolved: #56401
Add `pushAnimationMutations(Callback)` to the AnimationBackend as a targeted alternative to `trigger()`.
The existing `trigger()` method has two problems:
1. **Blast radius**: It calls `onAnimationFrame()` which invokes ALL registered callbacks. When one animation frontend (e.g. Animated) calls `trigger()` in response to an event, every other frontend (e.g. Reanimated) also spins up unnecessarily.
2. **Broken timestamp on iOS**: `trigger()` uses `std::chrono::steady_clock` which on iOS maps to a different kernel clock than what `CADisplayLink` uses for vsync timestamps. These clocks have different baselines and can diverge over time (e.g. after device sleep), causing animations to see time jumps.
`pushAnimationMutations(Callback)` fixes both issues:
- Executes only the provided callback, not all registered ones
- Uses `AnimationChoreographer::now()` which delegates to `HighResTimeStamp`, providing a timestamp from the same clock as the vsync path on each platform
Also refactors `onAnimationFrame` to use `unpackMutations`/`applySurfaceUpdates` helpers, avoiding intermediate vector/set merging when accumulating mutations from multiple callbacks.
## Changelog:
[General][Added] - Add pushAnimationMutations to AnimationBackend for targeted event-driven animation updates
Reviewed By: zeyap
Differential Revision: D100164749
fbshipit-source-id: 53d36ed316614baa835707a45361ae8f3b828d261 parent 7d51201 commit e4f0509
File tree
12 files changed
+126
-30
lines changed- packages/react-native/ReactCommon/react/renderer
- animated
- animationbackend
- uimanager
- private/react-native-fantom/tester/src
- scripts/cxx-api/api-snapshots
12 files changed
+126
-30
lines changedLines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
515 | 515 | | |
516 | 516 | | |
517 | 517 | | |
518 | | - | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
519 | 522 | | |
520 | 523 | | |
521 | 524 | | |
| |||
Lines changed: 47 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
58 | 61 | | |
59 | | - | |
60 | | - | |
61 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
62 | 67 | | |
63 | 68 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
| 69 | + | |
| 70 | + | |
78 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
79 | 75 | | |
80 | 76 | | |
81 | 77 | | |
| |||
89 | 85 | | |
90 | 86 | | |
91 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
92 | 112 | | |
93 | 113 | | |
94 | 114 | | |
| |||
123 | 143 | | |
124 | 144 | | |
125 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
126 | 152 | | |
127 | 153 | | |
128 | 154 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
66 | 75 | | |
67 | 76 | | |
68 | 77 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
24 | 29 | | |
25 | 30 | | |
26 | 31 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
22 | 37 | | |
23 | 38 | | |
| 39 | + | |
24 | 40 | | |
25 | 41 | | |
26 | 42 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1546 | 1546 | | |
1547 | 1547 | | |
1548 | 1548 | | |
| 1549 | + | |
1549 | 1550 | | |
1550 | 1551 | | |
1551 | 1552 | | |
| |||
1562 | 1563 | | |
1563 | 1564 | | |
1564 | 1565 | | |
| 1566 | + | |
1565 | 1567 | | |
1566 | 1568 | | |
1567 | 1569 | | |
| |||
2814 | 2816 | | |
2815 | 2817 | | |
2816 | 2818 | | |
2817 | | - | |
| 2819 | + | |
2818 | 2820 | | |
2819 | 2821 | | |
2820 | 2822 | | |
| |||
5211 | 5213 | | |
5212 | 5214 | | |
5213 | 5215 | | |
| 5216 | + | |
5214 | 5217 | | |
5215 | 5218 | | |
5216 | 5219 | | |
| |||
10379 | 10382 | | |
10380 | 10383 | | |
10381 | 10384 | | |
10382 | | - | |
| 10385 | + | |
10383 | 10386 | | |
10384 | 10387 | | |
10385 | 10388 | | |
| |||
12930 | 12933 | | |
12931 | 12934 | | |
12932 | 12935 | | |
| 12936 | + | |
| 12937 | + | |
12933 | 12938 | | |
12934 | 12939 | | |
12935 | 12940 | | |
| |||
12938 | 12943 | | |
12939 | 12944 | | |
12940 | 12945 | | |
| 12946 | + | |
12941 | 12947 | | |
12942 | 12948 | | |
12943 | 12949 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1545 | 1545 | | |
1546 | 1546 | | |
1547 | 1547 | | |
| 1548 | + | |
1548 | 1549 | | |
1549 | 1550 | | |
1550 | 1551 | | |
| |||
1561 | 1562 | | |
1562 | 1563 | | |
1563 | 1564 | | |
| 1565 | + | |
1564 | 1566 | | |
1565 | 1567 | | |
1566 | 1568 | | |
| |||
2811 | 2813 | | |
2812 | 2814 | | |
2813 | 2815 | | |
2814 | | - | |
| 2816 | + | |
2815 | 2817 | | |
2816 | 2818 | | |
2817 | 2819 | | |
| |||
5202 | 5204 | | |
5203 | 5205 | | |
5204 | 5206 | | |
| 5207 | + | |
5205 | 5208 | | |
5206 | 5209 | | |
5207 | 5210 | | |
| |||
10235 | 10238 | | |
10236 | 10239 | | |
10237 | 10240 | | |
10238 | | - | |
| 10241 | + | |
10239 | 10242 | | |
10240 | 10243 | | |
10241 | 10244 | | |
| |||
12786 | 12789 | | |
12787 | 12790 | | |
12788 | 12791 | | |
| 12792 | + | |
| 12793 | + | |
12789 | 12794 | | |
12790 | 12795 | | |
12791 | 12796 | | |
| |||
12794 | 12799 | | |
12795 | 12800 | | |
12796 | 12801 | | |
| 12802 | + | |
12797 | 12803 | | |
12798 | 12804 | | |
12799 | 12805 | | |
| |||
0 commit comments