In the dev tools timeline, what are the empty green rectangles?

前端 未结 1 1156
忘了有多久
忘了有多久 2021-01-31 19:19

In the Chrome dev tools timeline, what is the difference between the filled, green rectangles (which represent paint operations) and the empty, green rectangles (which apparentl

1条回答
  •  不思量自难忘°
    2021-01-31 19:59

    Painting is really two tasks: draw calls and rasterization.

    • Draw calls. This is a list of things you'd like to draw, and its derived from the CSS applied to your elements. Ultimately there is a list of draw calls not dissimilar to the Canvas element's: moveTo, lineTo, fillRect (though they have slightly different names in Skia, Chrome's painting backend, it's a similar concept.)
    • Rasterization. The process of stepping through those draw calls and filling out actual pixels into buffers that can be uploaded to the GPU for compositing.

    So, with that background, here we go:

    • The solid green blocks are the draw calls being recorded by Chrome. These are done on the main thread alongside JavaScript, style calculations, and layout. These draw calls are grouped together as a data structure and passed to the compositor thread.
    • The empty green blocks are the rasterization. These are handled by a worker thread spawned by the compositor.

    Essentially, then, both are paint, they just represent different sub-tasks of the overall job. If you're having performance issues (and from the grab you provided you appear to be paint bound), then you may need to examine what properties you're changing via CSS or JavaScript and see if there is a compositor-only way to achieve the same ends. CSS Triggers can probably help here.

    0 讨论(0)
提交回复
热议问题