markbrown4 — 2013-10-17T22:22:51-04:00 — #1
After getting back from a 3 month holiday I've been exposed to a lot of new info on rendering performance from people working on Chrome/blink.
The rendering engine has always been a black box til now, we haven't known the best ways to optimize things.
The Chrome dev tools expose how rendering happens and makes it easy for us to find what work we're making the browser do and identify bottlenecks.
I have never done such micro improvements before but I'm finding minor tweaks to the css can have massive improvements on sites with laggy scrolling.
Anyone have other resources on this or thoughts?
paulob — 2013-10-19T07:36:50-04:00 — #2
It would be interesting if you could document some of your findings Mark.
It's not an area that I have really looked deeply into so your insight would be useful.
markbrown4 — 2013-10-19T23:34:08-04:00 — #3
The videos will do a much better job at explaining how the tools work than me but I can give you a few practical examples.
Sites that are notoriously janky are ones that update the dom regularly with js, use fixed positioning, or even lots of positioning with z-index.
The main finding was understanding the different steps that the browser takes to render something on the screen
Put simply, with each frame the following steps all need to occur in 16ms to be able to update the page at 60 frames per second giving the illusion of fluid motion.
- js can execute taking a certain amount of time
- Rendering is a step that happens whenever the browser needs to recalculate styles or layout e.g. changes to classes, window size, images loading pushing things around etc.
- Painting is the drawing of actual pixels - areas of the page that are in 'layers' are saved as separate images
- Compositing is then stacking all of the separate images together to present an image to the screen.
So the things you want to do to decrease rendering time are:
1. Record some action in the Timeline Frames and find where the majority of time is being spent.
2. Turn on Show Paint Rectangles to show which areas of the page are getting rendered over and over.
3. Reduce the number of paints by changing the DOM less often or by moving unrelated areas of the page into their own layers - transform: translateZ() is one way.
4. Turn on Continuous repaint to show frames per second for continuously repainting the whole page. You can reduce fps by removing costly styles. e.g. fliters / large drop shadows - sometimes a combinations of styles is costly.
It's fun to play with and give a lot of insight into the source of performance problems.
Safari has similar tools, Opera is basically the same as Chrome for now, Firefox and IE have no tools like this.. yet.
paulob — 2013-10-20T06:40:23-04:00 — #4
Thanks Mark, I'll have to find some spare time and study that a bit more in depth
davut_c20 — 2013-10-20T18:56:51-04:00 — #5
Thank you for useful information