Patch loophole that caused some Animated instructions to be executed 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
This commit is contained in:
Joshua Gross
2022-05-13 13:32:02 -07:00
committed by Facebook GitHub Bot
parent 12f6081865
commit bd2d0b28bd
+4 -1
View File
@@ -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();