Skip to content

Commit

Permalink
RN: Backout "Scheduling Animated End Callbacks in Microtask" (#48132)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yungsters authored and facebook-github-bot committed Dec 6, 2024
1 parent f15fe4b commit 8793b7d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,23 +121,18 @@ describe('Animated', () => {

await unmount(root);

expect(callback).not.toBeCalled();
await jest.runOnlyPendingTimersAsync();
expect(callback).toBeCalledWith({finished: false});
});

it('triggers callback when spring is at rest', async () => {
it('triggers callback when spring is at rest', () => {
const anim = new Animated.Value(0);
const callback = jest.fn();
Animated.spring(anim, {
toValue: 0,
velocity: 0,
useNativeDriver: false,
}).start(callback);

expect(callback).not.toBeCalled();
await jest.runOnlyPendingTimersAsync();
expect(callback).toBeCalledWith({finished: true});
expect(callback).toBeCalled();
});

it('send toValue when a critically damped spring stops', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export default class Animation {
const callback = this.#onEnd;
if (callback != null) {
this.#onEnd = null;
queueMicrotask(() => callback(result));
callback(result);
}
}
}

0 comments on commit 8793b7d

Please sign in to comment.