tungs / timecut

Node.js program to record smooth movies of web pages with JavaScript animations
BSD 3-Clause "New" or "Revised" License
623 stars 72 forks source link

Overriding native setTimeout is causing the application page to behave incorrectly #26

Open subhadeepguin opened 4 years ago

subhadeepguin commented 4 years ago

Hi, We are trying to use timecut to animate one of the application page which uses native setTimeout functions to show a few elements on page. While using this application page with timecut, we noticed that the features (using setTimeout) are behaving incorrectly. after digging down a bit, we noticed that timecut overrides the native function which is causing this issue. Any suggestions on how to use timecut for this kind of application?

frizurd commented 4 years ago

Did you find a solution?

Having the same issue, I use setInterval to check if external fonts have finished loading but the setInterval functionality never fires when Timecut is doing its job.

I'm using webfontloader to load the fonts, which has an onLoaded event callback but this also doesn't fire with Timecut.

Trying to hack my way into a solution, will keep you updated if I find one.

tungs commented 3 years ago

timecut works by overwriting time handling functions, including setTimeout, to virtual ones. Currently it doesn't allow users to not overwrite these functions, but it provides access to the old, realtime functions, via the timeweb.realtime property.

v0.3.1+ of timecut (The Current Way, though undocumented)

v0.2.0-v0.3.0 of timecut (Undocumented)

For versions of v0.2.0-v0.3.0 of timecut, the overwritten time handling functions were available via the _timeweb_old prefix. They were removed in v0.3.1 of timecut (which was a result of the move to timeweb v0.2.0), in favor of the above method: