Skip to content

Commit a78d74c

Browse files
yungstersblakef
authored andcommitted
RN: Backout "Scheduling Animated End Callbacks in Microtask" (#48132)
Summary: Pull Request resolved: #48132 Backs out D63573322 and D65645981, reverting the change that makes callbacks passed to `animation.start(<callback>)` scheduled for execution in a microtask. This is being reverted becuase the latency introduced by the current macro and pending micro tasks can introduce visible latency artifacts that diminish the fidelity of animations. Changelog: [General][Changed] - Reverts #47503. (~~Callbacks passed to `animation.start(<callback>)` will be scheduled for execution in a microtask. Previously, there were certain scenarios in which the callback could be synchronously executed by `start`.~~) Reviewed By: javache Differential Revision: D66852804 fbshipit-source-id: 08434b9876813fe9e8b189b6b467198933843bf0
1 parent d81be20 commit a78d74c

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

packages/react-native/Libraries/Animated/__tests__/Animated-test.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,23 +121,18 @@ describe('Animated', () => {
121121

122122
await unmount(root);
123123

124-
expect(callback).not.toBeCalled();
125-
await jest.runOnlyPendingTimersAsync();
126124
expect(callback).toBeCalledWith({finished: false});
127125
});
128126

129-
it('triggers callback when spring is at rest', async () => {
127+
it('triggers callback when spring is at rest', () => {
130128
const anim = new Animated.Value(0);
131129
const callback = jest.fn();
132130
Animated.spring(anim, {
133131
toValue: 0,
134132
velocity: 0,
135133
useNativeDriver: false,
136134
}).start(callback);
137-
138-
expect(callback).not.toBeCalled();
139-
await jest.runOnlyPendingTimersAsync();
140-
expect(callback).toBeCalledWith({finished: true});
135+
expect(callback).toBeCalled();
141136
});
142137

143138
it('send toValue when a critically damped spring stops', () => {

packages/react-native/Libraries/Animated/animations/Animation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export default class Animation {
165165
const callback = this.#onEnd;
166166
if (callback != null) {
167167
this.#onEnd = null;
168-
queueMicrotask(() => callback(result));
168+
callback(result);
169169
}
170170
}
171171
}

0 commit comments

Comments
 (0)