-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
I'm reading this section in the docs:
High precision timer
During replay, we will get the complete snapshot chain at one time. If all the snapshots are executed in sequence, we can directly get the last state of the recorded page, but what we need is to synchronously initialize the first full snapshot, and then apply the remaining incremental snapshots asynchronously. Using a time interval we replay each incremental snapshot one after the other, which requires a high-precision timer.
The reason why high precision is emphasized is because the native setTimeout does not guarantee accurate execution after the set delay time, for example, when the main thread is blocked.
For our replay function, this imprecise delay is unacceptable and can lead to various weird phenomena, so we implement a constantly calibrated timer with requestAnimationFrame to ensure that in most cases incremental snapshots have a replay delay of no more than one frame.
At the same time, the custom timer is also the basis for our "fast forward" function.
And I'm not sure I understand it -- if the main thread is blocked setTimeout callbacks won't fire for the same exact reason requestAnimationFrame callbacks won't fire, the thread is just blocked running something else, it can't execute anything else while it's blocked.
Did I misunderstand what it's trying to say? Because the way I'm reading it it's just saying something incorrect 🤔