New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simple animations cause high cpu load #635
Comments
I doubt it's used 'incorrectly', but ultimately you are doing animations, with rotations and things like that, and I guess methods like requestAnimationframe will try and repeat animation steps everytime there is a spare frame/cycle to do it. |
have you see those animations? Its just 8 simple images moving back and forth. |
But it isn't just 8 simple images moving back and forth, this is svg not canvas... You have a lot of elements on that page, all with unique semi complex paths, a lot of them with transforms and fills on them. Then when they are moving to render, the display will need to calculate which objects are above which in the display etc. then you've got a handler or handlers that can interact with them that needs to check if something is happening to which object. Then you've got requestAnimationFrame which will try and do it as smooth as possible, which I think runs at the fps of the display (so I think in my case it would be 240 updates a second). So I'm not saying it couldn't be written with more optimisation in mind if needed, it could. But it's just worth being aware with svg, there's often a lot more going on with animations and interaction than is sometimes apparent. If you need performance, svg is the wrong thing to look at, it should be something like canvas. Svg is all about elements and an object approach to vector graphics. I'm also not suggesting that Snap is the most efficient method out there either, there are probably some more optimal solutions out there, but it depends if you are after raw efficiency or simplicity of use. |
I'm just evaluating snap.svg but I noticed that the demo 'game' causes my MBA fan to rev up and a CPU load of nearly 100% ("Brave Browser Helper (GPU)"). This doesn't look right to me and is a little concerning, is the library used incorrectly in the demo?
Here's the page
http://snapsvg.io/demos/#game
The text was updated successfully, but these errors were encountered: