-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add setImmediate implementation to the UI runtime (#3970)
## Summary This PR adds an implementation of web's setImmediate API to the reanimated's UI runtime. We utilize this implementation in mappers and event handlers for more accurate animation/gesture tracking as well as unblock further optimizations. There are several things that this PR changes: 1) We add event timestamp metadata to touch/scroll/sensor/etc events. This change is in preparation of providing a true system timestamps for such events (we don't do that yet but instead call system timer in order to pass down the current time) 2) We update performance.now API to use the same reference point for the provided time as requestAnimationFrame API. Before performance.now would use a different reference point which made it impossible to use it as a starting point for animations. 3) We update event handler callbacks such that they perform a flush for rAF and immediates queues 4) We populate global.__frameTimestamp for all the code that executes within requestAnimationFrame and event callbacks. We then use it in useAnimatedStyle as a reference point for starting animations and in case it wasn't set, we use performance.now 5) We add some code in initializers.ts to define setImmediate method and to register method for flushing immediates queue 6) We introduce set-immediate-based batching for runOnUI calls on the main RN runtime. We then flush all "immediates" after the whole batch is processed on the UI runtime. ## Test plan Check a bunch of examples from the example app: "Use animated style", "Bokeh", "Drag and snap". For touch based interaction verify that movement doesn't lag behind the event. The way this can be done is by screen recording drag and snap example with touch indicators on, then checking on the recorded clip in between frames whether there is a correct movement aligned with the updates of the touch indicator. The above needs to be done for all configurations: Android/iOS/Fabric/Paper
- Loading branch information
Showing
29 changed files
with
276 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.