Why does enabling hardware-acceleration in CSS3 slow down performance?

后端 未结 6 1967
醉梦人生
醉梦人生 2020-11-30 17:23

I am moving 6000 small div elements in an css3 experiment using a transition from top: 0 to top: 145px to test performance.

Using n

6条回答
  •  执念已碎
    2020-11-30 17:52

    The reason animation was slower when you added the null transform hack (translateZ(0)) is that each null 3D transform creates a new layer. When there are too many of these layers, rendering performance suffers because the browser needs to send a lot of textures to the GPU.

    The problem was noticed in 2013 on Apple's homepage, which abused the null transform hack. See http://wesleyhales.com/blog/2013/10/26/Jank-Busting-Apples-Home-Page/

    The OP also correctly noticed the explanation in their comment:

    Moving few big objects is more performant than moving lots of small items when using 3D-acceleration because all the 3D-accelerated layers have to be transferred to the GPU and the way back. So even if the GPU does a good job, the transfer of many objects might be a problem so that using GPU acceleration might not be worth it.

提交回复
热议问题