Skip to content

Commit

Permalink
Patch loophole that caused some Animated instructions to be executed …
Browse files Browse the repository at this point in the history
…out of order

Summary:
This patches a loophole in the logic that caused some operations to execute immediately and some to be deferred, even within the same render loop. This caused the non-queued operations to be executed out of order. Instead, if an operation is created and a queued exists, we just push the operation to the end of the queue so ordering is preserved.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D36379125

fbshipit-source-id: d9f63f4d47d8453d51add61763b7b9c74ffe9d88
  • Loading branch information
JoshuaGross authored and facebook-github-bot committed May 13, 2022
1 parent 12f6081 commit bd2d0b2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Libraries/Animated/NativeAnimatedHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ const API = {
}
},
queueOperation: (fn: () => void): void => {
if (queueOperations) {
// If queueing is explicitly on, *or* the queue has not yet
// been flushed, use the queue. This is to prevent operations
// from being executed out of order.
if (queueOperations || queue.length !== 0) {
queue.push(fn);
} else {
fn();
Expand Down

0 comments on commit bd2d0b2

Please sign in to comment.