Test case to show choppiness resulting from not using RAF timestamp
See original GitHub issueVelocity 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:
Using the RAF timestamp
argument instead, the animation feels smoother, and the graph is perfectly smooth as well:
I thought that perhaps using the microsecond-resolution performance.now()
function would improve smoothness, but it doesn’t seem to help much:
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:5
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Btw, thank you @joliss for that awesome codepen and letting us know - Velocity wants performance and quality 😃
This is no longer an option in V2 - we always care about performance, and shim it if it doesn’t exist!