question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Test case to show choppiness resulting from not using RAF timestamp

See original GitHub issue

Velocity uses (new Date).getTime() instead of the RAF timestamp argument (velocity.js:3366):

/* We ignore RAF's high resolution timestamp since it can be significantly offset
   when the browser is
   under high stress; we opt for choppiness over allowing the browser to drop huge
   chunks of frames. */
var timeCurrent = (new Date).getTime();

I created a test case to demonstrate the resulting choppiness: http://codepen.io/joliss/pen/rLOxBb

My hope is that you can use this test case as a debugging aid, and as a motivating example to convince browser vendors to get the timestamp offset issues resolved.

Running the CodePen, we see that there is some slight choppiness with the default getTime implementation:

a pen by jo liss bnbir

Using the RAF timestamp argument instead, the animation feels smoother, and the graph is perfectly smooth as well:

a pen by jo liss g4l3o

I thought that perhaps using the microsecond-resolution performance.now() function would improve smoothness, but it doesn’t seem to help much:

a pen by jo liss alfz7

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

1reaction
Rycochetcommented, Sep 24, 2016

Btw, thank you @joliss for that awesome codepen and letting us know - Velocity wants performance and quality 😃

0reactions
Rycochetcommented, Feb 11, 2018

This is no longer an option in V2 - we always care about performance, and shim it if it doesn’t exist!

Read more comments on GitHub >

github_iconTop Results From Across the Web

requestAnimationFrame() timestamp argument has jitter
So the first question, especially given comment 5, is whether in the cases where the jitter is observed we're running off vsync or...
Read more >
timestamp of requestAnimationFrame is not reliable
When the browser is done doing this 300ms computation, it has to schedule a new animation frame. At the next event-loop iteration it...
Read more >
Misuse of requestAnimationFrame() - Impact Forums - ImpactJS
It seems ImpactJS is misusing the requestAnimationFrame() feature by having game logic execute during the callback. Whenever the callback is triggered, ...
Read more >
requestAnimationFrame for smart animating - Paul Irish
With the fallback implementation (using setTimeout) this is not the case, causing sync problems. The fallback implementation could check whether ...
Read more >
Untitled
Surface blood bruises, Bad person song, Rational numbers measure zero proof, Internship cover letter psychology, Timberland collection hiver 2013, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found