Skip to content

Commit

Permalink
fix(scheduler): getNow detection can randomly fail (vuejs#9667)
Browse files Browse the repository at this point in the history
The previous detection code compared time stamps based on Date.now()
which are not monotonic, so the check could fail due to clock skew or
adjustments.

This fix changes the check to compare against performance.now() if it is
supported, because it is monotonic (strictly increasing).
  • Loading branch information
felixbuenemann authored and kiku-jw committed Jun 18, 2019
1 parent 7d5bf48 commit 091a58c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/observer/scheduler.js
Expand Up @@ -51,7 +51,7 @@ if (
inBrowser &&
window.performance &&
typeof performance.now === 'function' &&
getNow() > document.createEvent('Event').timeStamp
document.createEvent('Event').timeStamp <= performance.now()
) {
// if the event timestamp is bigger than the hi-res timestamp
// (which is evaluated AFTER) it means the event is using a lo-res timestamp,
Expand Down

0 comments on commit 091a58c

Please sign in to comment.