Why Hardware-Accelerated CSS animation cost too much quot;composite layerquot; times in main thread?(为什么硬件加速的 CSS 动画花费太多“复合层?主线程中的时间?)
问题描述
我用一张大图(33440 x 440)对大图进行变换,然后实现类似帧动画的动画;我还使用 translate3D 来获得 GPU 加速,
I use a big picture(33440 x 440) and transform the big image, then achieve a animation like as frame animation; and also I use the translate3D to get a GPU Acceleration,
下面的简化代码:
@keyframes testName {
0% { transform: translate3d(0,0,0); }
100% { transform: translate3d(-33440px,0,0); }
}
众所周知,复合层的工作将转移到 GPU;但是在性能的chrome devtools中,主线程中复合层的任务花费了太多时间:(解码图像发生在光栅线程而不是主线程中)
as we know, the work of composite layers will move to GPU; but in chrome devtools of performance, the task of composite layers in main thread cost too much time: (decode image happens in raster thread not in main thread)
那么为什么任务复合层在主线程中做了什么?
so why and what the taskcomposite layers did in main thread?
推荐答案
问题是你的图片太大了.合成图层"大致是指将页面上的所有元素(图层)以正确的顺序和位置相互叠加,如果这些图层很大,这将需要很长时间.仅仅因为它发生在 GPU 上并不意味着如果你将 14 兆像素的图像投入其中,它就会立即发生.
The problem is that your image is HUGE. "Compositing layers" roughly means rendering all of the elements (layers) on the page on top of each other in the correct order and location, which will take a long time if these layers are gigantic. Just because it's happening on the GPU doesn't mean it will happen instantly if you throw a 14 megapixel image into it.
这篇关于为什么硬件加速的 CSS 动画花费太多“复合层"?主线程中的时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么硬件加速的 CSS 动画花费太多“复合层"?主线程中的时间?
基础教程推荐
- Bootstrap 模态出现在背景下 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
