Преглед изворни кода

fix(scheduler): getNow detection can randomly fail (#9667)

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).
Felix Bünemann пре 7 година
родитељ
комит
ef2a380c6e
1 измењених фајлова са 1 додато и 1 уклоњено
  1. 1 1
      src/core/observer/scheduler.js

+ 1 - 1
src/core/observer/scheduler.js

@@ -51,7 +51,7 @@ if (
   inBrowser &&
   inBrowser &&
   window.performance &&
   window.performance &&
   typeof performance.now === 'function' &&
   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
   // 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,
   // (which is evaluated AFTER) it means the event is using a lo-res timestamp,