Skip to content

Commit

Permalink
Use performance.now() for the frames instead (#859)
Browse files Browse the repository at this point in the history
I'm not sure how `Date.now()` sneaked in there. Dates should only ever
be used if the calendar is important, which is definitely not the case
for managing the frame rate. Any NTP sync should haved messed with the
frames before, at least to some slight degree.
  • Loading branch information
CryZe authored Apr 29, 2024
1 parent 0dc2a38 commit 0f87db7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/util/AutoRefresh.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class AutoRefresh extends React.Component<Props> {
}

private startAnimation() {
this.previousTime = Date.now();
this.previousTime = performance.now();
this.animate();
}

Expand All @@ -40,7 +40,7 @@ export default class AutoRefresh extends React.Component<Props> {

assert(this.previousTime !== undefined, "Previous time must be defined");

const currentTime = Date.now();
const currentTime = performance.now();
const elapsed = currentTime - this.previousTime;

if (elapsed > this.fpsInterval) {
Expand Down

0 comments on commit 0f87db7

Please sign in to comment.