Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GPU accelerated CSS animation vs SVG native animations

Tags:

My question is, what is faster, native SVG animation tags, like for example:

<path d="something very long and non-human-friendly">
    <animateTransform attributeName="transform" attributeType="XML"
    type="rotate" from="0" to="360" begin="0s" dur="3s" fill="freeze"
    repeatCount="indefinite" />
</path>

or CSS animations, for example:

path {
    animation: foo 3s ease-out infinite;
}

@keyframes foo {
    50% {
        transform: rotate(360);
}

Maybe it's better to use SVG animations since SVG has better browser support?

Also related: Since CSS transforms trigger hardware acceleration, I was also wondering if native SVG animation tags also trigger GPU acceleration or are painted by the browser. If not, is it possible to force hardware acc on SVG native animations?

Cheers!

like image 516
Xirux Nefer Avatar asked Aug 10 '14 21:08

Xirux Nefer


People also ask

Is SVG GPU accelerated?

SVG animations are now GPU-accelerated in Chrome Until recently, animating an SVG element via CSS would trigger repaint on every frame (usually 60 times per second) in Chromium-based browsers. Such constant repainting can have a negative impact on the smoothness of the animation and the performance of the page itself.

Can CSS animations can be hardware accelerated?

Did you know that we can hardware-accelerate graphics-intensive CSS features by offloading them to the GPU (Graphics Processing Unit) for better rendering performance in the browser? Most computers these days have graphics cards suitable for hardware acceleration.

Is SVG animate deprecated?

19.2. Although SVG defines 'animateColor', its use is deprecated in favor of simply using the 'animate' element to target properties that can take color values.

Is SVG animation good?

SVGs are a great image format to go with. They are scalable, lightweight, text-based, and efficient. They are easy to edit, animate, and integrate. Importantly, they are supported by almost any browser except Internet Explorer 8 and Android 2.3.


1 Answers

I did a lot of reading on this topic as I was having performance issues on my multi-platform Phonegap app and to keep things simple:

No one really knows which CSS are universally hardware accelerated as standards implementation is fragmented, it looks like iOS is leader in CSS HW acceleration but do you want to limit optimal experience to that market share?

Eventually I came across this article which tries to explain that JS solutions have better compatibility and performance. While adding abilities that are simply out of reach for CSS. Do Keep in mind that both articles are written by the creator of GSAP and thus biased, but after simply giving it a try I was convinced.

A more elaborate version of the aforementioned article can be found here.

like image 158
JGM.io Avatar answered Sep 16 '22 14:09

JGM.io