Skip to content

Commit

Permalink
Restore early return to NativeAnimatedHelper.flushQueue
Browse files Browse the repository at this point in the history
Summary:
Brings back a small performance win of avoiding starting/stopping a batch if the queue is empty.

## Background

This was attempted previously but it happened to expose a single frame animation visual regression in VR.

1. First added in D36298399 (55ee8ce), reverted in D36378363
2. Added in a different form in D36338606 (35e2a63), reverted in D36479089 (a4690d0)
3. Root cause of the visual regressions introduced was fixed in D36612758 (40f4c66)

Now that we've fixed the root cause of the visual regression, this is safe to restore.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D36670591

fbshipit-source-id: 42b6bc9c7764484f2dbb9edb122780a91b7393b4
  • Loading branch information
jehartzog authored and facebook-github-bot committed May 25, 2022
1 parent 27bbb5e commit 0ef73f2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Libraries/Animated/NativeAnimatedHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ const API = {
invariant(NativeAnimatedModule, 'Native animated module is not available');
flushQueueTimeout = null;

// Early returns before calling any APIs
if (useSingleOpBatching && singleOpQueue.length === 0) {
return;
}
if (!useSingleOpBatching && queue.length === 0) {
return;
}

if (useSingleOpBatching) {
// Set up event listener for callbacks if it's not set up
if (
Expand Down

0 comments on commit 0ef73f2

Please sign in to comment.