Inside the rendering engine
Follow one frame through Chrome's RenderingNG pipeline: which part of Chrome does each step, on which thread, and what it hands on. Then see how Firefox and Safari split the same work.
- 01Follow one frame through ChromeName the part of Chrome, the process and the thread for each step, from style to the screen.
- 02Say what each step hands onComputed styles, the fragment tree, property trees, the display list, layers, tiles and the compositor frame.
- 03Compare the three enginesSay how Firefox's WebRender and Safari's WebKit split the same work between their processes.
One change, from a script to the screen
Asha opens the Mint tea page on her phone. She taps Show details. A short paragraph appears under the price, and the Add to basket button moves down to make room. It happens faster than a blink.
Ravi built the page. From The pixel pipeline, he knows the steps: style, layout, paint and composite. The JavaScript course's The rendering pipeline shows them from a script's side. Now he wants to look one level deeper. Who inside Chrome does each step? On which thread, and in which process? And what does each step hand to the next one?
Chrome's team calls its way of drawing pages RenderingNG, short for the next generation of rendering. They wrote a series of articles about it, and Chrome's code is open. A frame is one picture on the screen. This lesson follows one real frame through both.
To record it, the course gave the Mint tea page a small test script. A second after the page loads, the script shows the details by itself, in one frame. It makes no other change. Chrome 157.0.8103.52 traced every process and thread while it ran. Here are five moments from the frame:
// One recorded frame of the Mint tea page, in ms after Chrome began it.const frame = { styled: 0.8, copied: 1.5, rastered: 2.1, drawn: 3.7, shown: 6 }; console.log(`The main thread started on the change at ${frame.styled} ms.`);console.log(`The compositor thread started its copy at ${frame.copied} ms.`);console.log(`A raster worker started on the tiles at ${frame.rastered} ms.`);console.log(`Viz started drawing the frame at ${frame.drawn} ms.`);console.log(`It was on the screen at ${frame.shown} ms.`);- Line 1 is a comment. Every time is in milliseconds (ms) after Chrome began the frame.
- Line 2 holds five recorded times, one for each part of Chrome the change passed through.
- Lines 4 to 6 print
The main thread started on the change at 0.8 ms.,The compositor thread started its copy at 1.5 ms.andA raster worker started on the tiles at 2.1 ms. - Lines 7 and 8 print
Viz started drawing the frame at 3.7 ms.andIt was on the screen at 6 ms.
You met the main thread and the compositor thread in Processes and threads. Both live in the page's renderer, the process that runs one site. Viz, short for visuals, is the part of Chrome that puts frames on the screen. It lives in a separate process, the GPU process. RenderingNG's articles call it the Viz process. Here is the whole frame, step by step, next to what Asha saw:
Three places, one after another. The main thread was done after 1.4 ms. Yet the frame reached the screen at 6 ms. Most of its trip happened on other threads. That's why it matters: the main thread is only the first stop.
At night, a newspaper's newsroom writes the stories and lays out each page. It sends a copy of the pages to the print room, and starts on tomorrow's news. The print room makes the printing plates. The packing room puts the sports section, the ads and the front page into one paper. Then the paper goes out.
- In real life: The newsroom, writing and laying out the pages
- In Chrome: Blink, on the renderer's main thread
- In real life: A copy of the finished pages, sent to the print room
- In Chrome: The commit, to the compositor thread
- In real life: The print room, making the printing plates
- In Chrome: cc: raster and the compositor frame
- In real life: The packing room, putting every section into one paper
- In Chrome: Viz, putting every frame together
- In real life: The paper on Asha's doorstep
- In Chrome: The frame on Asha's screen
Blink works out the page on the main thread: style, layout, pre-paint, paint and layerize. The compositor thread copies the result, rasters it and draws a compositor frame. Viz, in the GPU process, puts every frame together and shows it. Each step hands the next one a smaller, simpler thing than it got.
Style, layout and pre-paint: Blink works out the page
Blink is the part of Chrome that runs web pages inside the renderer. Its share of a frame is called the document lifecycle: a fixed list of states the page moves through. Chrome keeps the list in one file, document_lifecycle.h. In C++, the language Chrome is written in, an enum is a list of names. Lines that start with // are comments:
kVisualUpdatePending,kInStyleRecalc,kStyleClean,kInPerformLayout,kLayoutClean,// In InPrePaint step, any data needed by painting are prepared.// Paint property trees are built and paint invalidations are issued.kInPrePaint,kPrePaintClean,// In InPaint step, paint artifacts are generated and raster invalidations// are issued.// In CAP, composited layers are generated/updated.kInPaint,kPaintClean,In plain words, line by line:
- Line 1: something changed, and Blink waits for its turn to make a frame.
- Lines 2 and 3: working out style, then style is done. Chrome calls a finished step "clean".
- Lines 4 and 5: layout, then layout is done.
- Lines 6 and 7 are Chrome's comment: pre-paint gets ready for paint. It builds the property trees and marks what must be painted again.
- Lines 8 and 9: pre-paint, then pre-paint is done.
- Lines 10 to 12 are the comment for paint. Paint makes the display list. The last line says the layers are made here too. CAP is Composite After Paint, the project that moved that choice after paint.
- Lines 13 and 14: paint, then paint is done.
The BlinkNG article explains why the list matters. Each step's result is fixed once the step ends. Nothing may change it until the next frame. And there are only two ways into the pipeline: a full update for a new frame, or a quick answer to a question like offsetTop. That second way is the forced layout from Layout and layout thrashing. Step through the states yourself:
kVisualUpdatePendingkInStyleRecalcUpdateLayoutTreekStyleCleankInPerformLayoutLayoutkLayoutCleankInPrePaintPrePaintkPrePaintCleankInPaintPaint, LayerizekPaintClean
Something changed. Blink has asked for a frame, and waits for the compositor thread's signal to start.
What each step hands on
- Style works out each element's computed style: the final value of every CSS property. In the recorded frame, it restyled 2 elements. The trace calls this step
UpdateLayoutTree. - Layout works out each box's size and place. Its result is the fragment tree, one fragment for each box. The data structures article says each fragment "becomes immutable and is never changed again". Immutable means fixed. In the recorded frame, 6 of the page's 19 layout objects needed layout. The rest kept their old results.
- Pre-paint builds the property trees. There are four: transform, clip, effect and scroll. They say how each element is moved, cut off, faded, or scrolled. Pre-paint also marks what has to be painted again, in one walk over the layout tree.
Before a school play, the teachers plan in order. First the costume sheet: what each actor wears. Then the stage plan, in pen: where each actor stands. Then the lighting plan: who stands on the turning stage, who stands behind the thin curtain, who stands in the dim corner. They also note which scenes changed since last night.
- In real life: The costume sheet for each actor
- In Chrome: The computed style of each element
- In real life: The stage plan with chalk marks, drawn in pen
- In Chrome: The fragment tree: sizes and places, never changed again
- In real life: The lighting plan: who stands on the turntable, behind the gauze, under the dimmer
- In Chrome: The property trees: transform, clip, effect, scroll
- In real life: Notes on which scenes changed since last night
- In Chrome: Paint invalidation: what must be painted again
Why it matters: these three steps run on the main thread, in this order, whenever something changes size or place. A script that keeps the main thread busy holds them back.
Paint, layerize and commit: a list, some layers, a copy
Paint doesn't make pixels. It writes a display list: drawing commands such as "fill this rounded rectangle green". Chrome's notes call it a "paint artifact", a list of display items in paint order. Items that share the same property trees are grouped into paint chunks.
You can see the real list. DevTools' paint profiler shows each layer's commands. The course read them on the visit that darkened the button. Pick a layer, then compare before and after:
- 1Start with a clear layer.
drawPaint - 2Fill a 412 by 823 rectangle at 0, 0 with #FBF8F1.
drawRect - 3Fill a 412 by 48 rectangle at 0, 0 with #2F5D46.
drawRect - 4Draw a line of text at 16, 30 in #FFFFFF.
drawTextBlob - 5Fill a 378 by 409 rounded rectangle at 17, 65 with #FFFFFF.
drawRRect - 6Draw a 2 px rounded border, 378 by 409, at 17, 65 in #24311F.
drawRRect - 7Draw a line of text at 34, 113 in #24311F.
drawTextBlob - 8Save the drawing settings.
save - 9Draw only inside a 344 by 229 rounded rectangle at 34, 136.
clipRRect - 10Save the drawing settings.
save - 11Scale what comes next by 0.48, and move it to 34, 136.
concat44 - 12Draw the 720 by 480 photo.
drawImageRect - 13Go back to the saved settings.
restore - 14Go back to the saved settings.
restore - 15Draw a line of text at 34, 395 in #24311F.
drawTextBlob - 16Fill a 132 by 44 rounded rectangle at 34, 413 with #2F6B3A.
drawRRect - 17Draw a line of text at 50, 441 in #FFFFFF.
drawTextBlob
The page's layer is 412 by 823 CSS pixels. Its display list has 17 commands.
The page's layer holds 17 commands. When the button darkened, only one of them changed. Paint keeps the last list, and reuses every item that would come out the same. That's why it matters: a small change costs paint very little.
Layerize: on the main thread, after paint
Next, layerize splits the display list into layers: pieces the compositor can draw and move on their own. Its input is the paint artifact, and its output is a list of layers with their property trees. Here is where it runs:
DEVTOOLS_TIMELINE_TRACE_EVENT("Layerize", inspector_layerize_event::Data, frame_.Get());// Skip updating property trees, pushing cc::Layers, and issuing raster// invalidations if possible.if (paint_artifact_compositor_->TryFastPathUpdate( paint_controller_persistent_data_->GetPaintArtifact())) { return;}paint_artifact_compositor_->Update( paint_controller_persistent_data_->GetPaintArtifact(),In plain words, line by line:
- Lines 1 and 2 write a "Layerize" event into the trace. That's the name DevTools shows.
- Lines 3 and 4 are Chrome's comment: skip the work when it can.
- Lines 5 to 8: if only small things changed, a quick path updates the layers in place and stops.
- Lines 9 and 10: otherwise, read the paint artifact and rebuild the layers from it.
This code belongs to LocalFrameView, which runs on the main thread. The RenderingNG architecture article's diagram puts layerize on the compositor thread, after the commit. The BlinkNG article explains the gap: the diagram "shows layerization as being off the main thread, whereas currently it's still on the main thread". The code at the course's release agrees with BlinkNG. In every recorded frame, Layerize ran on the main thread, before the commit.
For the Mint tea page, layerize made five layers. Two of them draw something you can see: the page, and the swaying leaf. The leaf got its own layer because its transform is animating:
Commit: a copy for the compositor thread
The layers live on the main thread, and the main thread is about to start on other work. So the commit copies the layers and property trees to the compositor thread. How cc Works says commit pushes them into the pending tree: the compositor thread's own copy, waiting for raster. (cc is the folder of Chrome's code that runs the compositor.) Does the main thread wait while it's copied? Here is the main thread's side:
bool blocking = block_on_next_commit_;block_on_next_commit_ = false; ImplThreadTaskRunner()->PostTask( FROM_HERE, base::BindOnce(&ProxyImpl::NotifyReadyToCommitOnImpl, if (blocking) layer_tree_host_->WaitForProtectedSequenceCompletion();In plain words, line by line:
- Line 1: should the main thread wait this time? Read a flag called
block_on_next_commit_. - Line 2: set the flag back to false for the next frame.
- Lines 3 and 4: post a message to the compositor thread: "ready to commit".
- Lines 5 and 6: only if the flag was set, wait until the compositor thread has finished the copy.
Who sets the flag? A function for input. Chrome's comment says it: "If the next main frame will contain the visual response to an input event, we pause execution on the main thread". So the main thread waits only for frames that answer a tap or a key press. The How cc Works doc still says commit is done by blocking the main thread. The code at the course's release says otherwise, and the code wins.
The recording agrees. The test script made its change on its own, without a tap. The main thread handed off the commit and waited less than 0.01 ms. The compositor thread then spent 0.13 ms on the copy.
A cook writes each order as steps on a ticket. Dishes that leave the kitchen at different times go on separate trays. The cook passes a copy of the tickets through the hatch, then starts the next order. Only when a customer is waiting at the counter does the cook stop and watch the copy being taken.
- In real life: The steps written on the order ticket
- In Chrome: The display list
- In real life: Dishes that leave at different times, on separate trays
- In Chrome: Layers
- In real life: A copy of the tickets, passed through the hatch
- In Chrome: The commit, into the pending tree
- In real life: Waiting while a customer stands at the counter
- In Chrome: Waiting for the commit, on a frame that answers input
Raster and the display compositor: from tiles to the screen
The compositor thread now holds the layers, but still no pixels. Each layer is cut into tiles, pieces of the page. How cc Works says that with GPU raster, a tile is about as wide as the screen and a quarter as tall. Raster turns a tile's drawing commands into pixels. In this recording, that happened in two places:
- A raster worker, a helper thread in the renderer, took each tile. It handed the layer's display list to the GPU process, as commands. How cc Works calls this GPU raster.
- The GPU process's main thread ran those commands on the GPU, the graphics chip. That made the pixels.
The layout change needed 3 raster tasks, all on one worker thread. The GPU process ran 3 rasters for them.
Activate, then draw
New tiles take time. Meanwhile, the screen still needs frames: the leaf keeps swaying. So the compositor thread keeps two copies. The active tree is the one it draws from now. The pending tree waits. How cc Works says "The pending tree is the staging area to wait until all of the asynchronous rasterization work is complete." When its tiles are ready, activation makes it the active tree. Then the whole change appears at once, never half drawn.
A shop changes its window display behind a curtain. People walking by still see the old display. Only when every piece of the new one is in place does the shop open the curtain. Nobody sees half a display.
- In real life: The new display, set up behind the curtain
- In Chrome: The pending tree, waiting for raster
- In real life: The old display, still on show
- In Chrome: The active tree, still drawn every frame
- In real life: Opening the curtain once every piece is in place
- In Chrome: Activation
Then the compositor thread draws. In cc, to draw means to build a compositor frame: a list of quads, rectangles that say where each tile goes, grouped into render passes. No pixels move yet. The compositor thread sends the frame to Viz. In the recorded frame, it held one render pass.
Viz puts every frame together
The page is not the only thing on Asha's screen. The browser's own bar at the top sends frames too. So does every iframe from another site. The architecture article says there is "exactly one Viz process for all of Chromium", as there is usually one GPU and one screen. Inside Viz, the display compositor combines them all. Here is its main function:
bool Display::DrawAndSwap(const DrawAndSwapParams& params) { TRACE_EVENT0("viz", "Display::DrawAndSwap"); frame = aggregator_->Aggregate( renderer_->DrawFrame(&frame.render_pass_list, device_scale_factor_, renderer_->SwapBuffers(std::move(swap_frame_data));In plain words, line by line:
- Line 1: the function that makes one frame for the screen.
- Line 2: its trace event,
Display::DrawAndSwap. - Line 3: aggregate: put every compositor frame on the screen together into one.
- Line 4: draw it. Here,
renderer_means Viz's own drawing code, not a renderer process. - Line 5: swap: hand the finished picture to the screen.
During a live match, a TV control room gets pictures from many cameras. The mixing desk puts the score in one corner and the match in the middle, as one picture. Then that one picture goes on air.
- In real life: Each camera's picture
- In Chrome: Each compositor frame: the page, an iframe, the browser's bar
- In real life: The mixing desk, putting the pictures into one
- In Chrome: Aggregation in Viz's display compositor
- In real life: Putting the picture on air
- In Chrome: Draw and swap
Here is the recorded frame on all five threads, to scale:
One detail stands out. Viz started drawing at 3.7 ms. The GPU ran the three rasters at 4.2 ms, after that. Chrome doesn't make Viz wait for raster. The architecture article says it uses a "sync token" instead: a ticket the GPU checks, so it runs the raster before the draw. The swap came at 5.3 ms, and the frame was on the screen at 6 ms.
Here is every step of the recorded frame, with what it hands on. Read each row across:
| Step | Who runs it, and where | What it hands on |
|---|---|---|
| Style | Blink, on the renderer's main thread. | A computed style for each element the change reached. |
| Layout | Blink, on the renderer's main thread. | The fragment tree: each box's size and place. |
| Pre-paint | Blink, on the renderer's main thread. | Property trees, and marks on what must be painted again. |
| Paint | Blink, on the renderer's main thread. | The display list: drawing commands, grouped into paint chunks. |
| Layerize | Blink, on the renderer's main thread. | A list of layers, and the compositor's own property trees. |
| Commit | cc, on the renderer's compositor thread. | A copy of the layers, in the pending tree. |
| Raster | cc's raster workers, then the GPU process. | Tiles of pixels in the GPU's memory. |
| Activate | cc, on the renderer's compositor thread. | The active tree, ready to draw. |
| Draw | cc, on the renderer's compositor thread. | A compositor frame: render passes full of quads. |
| Aggregate and draw | Viz, in the GPU process. | One frame for the whole screen, drawn and swapped. |
Three changes, three paths
Not every change runs every step. The course recorded two more changes on the same page, each in its own visit. One darkened the button: a change of look. In the other, the script only noted the time, and the course followed the leaf's sway, a CSS animation of transform. Here is the rule, as a small model:
// A small model of which steps a change needs, written for this lesson.function stepsFor(change) { const steps = ["commit", "raster", "activate", "draw"]; if (change === "size or place") return ["style", "layout", "pre-paint", "paint", "layerize", ...steps]; if (change === "look") return ["style", "pre-paint", "paint", "layerize", ...steps]; return ["animate", "draw"]; // a transform or opacity animation the compositor runs} console.log(stepsFor("size or place").length);console.log(stepsFor("look").includes("layout"));console.log(stepsFor("compositor animation").join(" -> "));- Line 1 says what this is: a model written for the lesson, not Chrome's code.
- Line 3 lists the steps after Blink: commit, raster, activate and draw.
- Line 4: a change of size or place runs every step.
- Line 5: a change of look, like a colour, skips layout.
- Line 6: an animation the compositor runs needs only two steps on the compositor thread.
- Lines 9 to 11 print
9,falseandanimate -> draw.
Now check the model against the three recorded frames:


Two real frames: just before the change, and just after it.
| Step | Where it ran | Started | Took |
|---|---|---|---|
| Script | Renderer, main thread | 0.18 ms | 0.55 ms |
| Style | Renderer, main thread | 0.75 ms | 0.09 ms |
| Layout | Renderer, main thread | 0.85 ms | 0.16 ms |
| Pre-paint | Renderer, main thread | 1.04 ms | 0.19 ms |
| Paint | Renderer, main thread | 1.25 ms | 0.07 ms |
| Layerize | Renderer, main thread | 1.35 ms | 0.05 ms |
| Commit | Renderer, compositor thread | 1.51 ms | 0.13 ms |
| Raster (3) | Renderer, raster worker | 2.11 ms | 1.14 ms |
| Activate | Renderer, compositor thread | 3.3 ms | 0.05 ms |
| Draw | Renderer, compositor thread | 3.36 ms | 0.25 ms |
| Aggregate and draw | GPU process, Viz compositor thread | 3.71 ms | 0.17 ms |
| Raster on the GPU (3) | GPU process, GPU main thread | 4.23 ms | 0.1 ms |
| Swap | GPU process, GPU main thread | 5.31 ms | 0.89 ms |
Nothing was skipped.
The details paragraph appears, and the button moves down. The main thread ran style, layout, pre-paint, paint and layerize. 3 raster tasks ran. The frame was on the screen at 6.01 ms.
The darker button skipped layout and still reached the screen at 3.3 ms. The leaf's frame never touched the main thread. It was on the screen 1 ms after Chrome began it. Between the two leaf frames in the playground, 1.5 seconds apart, the compositor drew 90 frames. The main thread made none, and nothing was rastered.
That's why it matters. A change that only moves or fades a layer keeps going while the main thread is busy. That's the idea behind Compositor-friendly animation and Scrolling performance. A change that needs the main thread waits for it. That wait is the presentation delay of INP.
How Firefox and Safari split the same work
Chrome isn't the only engine with this design. The RenderingNG article says "Gecko and Webkit have also implemented most of the same architectural features", sometimes before Chromium. Gecko is Firefox's engine. WebKit is Safari's. The jobs are much alike. Where they run, and what crosses between processes, differs.
Firefox: WebRender
Mozilla's Rendering Overview walks through it:
- In the page's content process, Gecko works out style and layout. Its style engine, Stylo, works across all of the computer's cores at once.
- Layout builds a frame tree, and from it a display list.
- The display list is packed into a WebRender display list and sent to the GPU process. On systems without one, that work runs in Firefox's main process instead.
- There, WebRender turns it into a scene, cuts the scene down to what's visible, and sends commands to the GPU.
So WebRender has no separate paint step before compositing. Mozilla's post on WebRender describes it as "removing the distinction between paint and composite", like a game engine drawing a scene. It still saves work between frames: the overview says it keeps parts of the page as cached tiles, in groups it calls slices. Scrolling and zooming are handled in the GPU process too, by a part called APZ.
Safari: WebKit's layers
In WebKit, the page runs in a web content process. There, WebKit keeps a render tree for the page, and a layer tree for the parts that need layers of their own. WebKit's graphics docs say its layer class has a version for each kind of system. One is for Core Animation, Apple's system for drawing layers.
WebKit's code for Apple's systems has a remote layer tree. The web content process builds its layers for the UI process, the process that draws the app's window. The UI process receives each update and keeps each layer as a Core Animation layer. On Linux, WebKit's docs describe another way. A compositor thread inside the web process puts the layers together. Then it shares the finished frame with the UI process.
Here are the three engines side by side. Read each row across:
| Question | Chrome | Firefox | Safari (WebKit) |
|---|---|---|---|
| Where style and layout run | Blink, on the renderer's main thread. | The content process. Its style engine uses every core. | WebKit, in the web content process. |
| What leaves that process | Raster commands and compositor frames, to the GPU process. | A WebRender display list, to the GPU process. | With its remote layer tree, on Apple's systems: layers, to the UI process. |
| What the other process does with it | Viz puts every frame together into one, and draws it on the GPU. | WebRender builds a scene from it, and sends commands to the GPU. | The UI process turns each layer into a Core Animation layer. |
| A paint step before compositing | Yes: paint, then raster, then draw. | No: WebRender draws from the display list. | Yes: each layer is painted, then the layers are put together. |
Why it matters: the same CSS can cost different work in each engine. A change that skips paint in Chrome may be drawn a different way in Firefox. So measure in each browser. For Chrome, use DevTools' rendering tools.
Which part of Chrome does it?
Each job below happens somewhere in the frame you followed. Sort it by where it runs:
- Working out the button's computed style
- Building the property trees
- Splitting the display list into layers
- Turning the leaf a little for the next frame
- Copying the layers into the pending tree
- Making the pending tree the active tree
- Turning one tile's display list into GPU commands
- Putting the page's frame together with every other frame on the screen
- Running the commands that fill a tile with pixels
- Swapping the finished frame onto the screen
Sort each job by the thread or process that does it.
Common mix-ups
- "Paint makes the pixels." No. Paint writes drawing commands, the display list. Raster makes pixels later, in the GPU process.
- "The compositor thread decides the layers." No. In Chrome's code, layerize runs on the main thread, right after paint. The architecture diagram shows a planned move.
- "Every commit freezes the main thread." No. The main thread waits only on frames that show the response to input. Otherwise it hands the commit off and moves on.
- "Each tab puts its own pixels on the screen." No. Every tab, iframe and the browser's bar send compositor frames to Viz. Viz puts them together and draws one frame.
- "A CSS animation needs the main thread in every frame." No. The recorded leaf animation drew 90 frames in 1.5 seconds, with no main-thread frame at all.
- "Firefox and Safari work just like Chrome." No. Firefox sends a WebRender display list to its GPU process. On Apple's systems, WebKit's remote layer tree sends layers to the UI process.
Practice exercises
Answer first, then use the hints.
What does this program print?
// A small model of which steps a change needs, written for this lesson.
function stepsFor(change) {
const steps = ["commit", "raster", "activate", "draw"];
if (change === "size or place") return ["style", "layout", "pre-paint", "paint", "layerize", ...steps];
if (change === "look") return ["style", "pre-paint", "paint", "layerize", ...steps];
return ["animate", "draw"]; // a transform or opacity animation the compositor runs
}
console.log(stepsFor("look").slice(0, 3).join(" -> "));style -> pre-paint -> paint. A change of look skips layout, so pre-paint comes right after style.
The recorded layout frame again. What does the last line print?
// The recorded layout frame, in ms after Chrome began it.
const frame = { mainDone: 1.4, shown: 6 };
const more = (frame.shown - frame.mainDone).toFixed(1);
console.log(`After the main thread was done, the frame took ${more} ms more.`);After the main thread was done, the frame took 4.6 ms more. Most of the frame's trip was on the compositor thread and in the GPU process.
When the button darkened, how many raster tasks ran?
One. Only the tile under the button had new commands, so only one raster task ran.
After the button darkened, what colour does the changed command fill with?
#1B3D22. Only the button's fill changed colour. Every other command stayed the same, so paint reused them.
Open the course's copy of the Mint tea page in Chrome, then DevTools' Layers panel. What reason does it give for the leaf's layer?
Has an active accelerated transform animation or transition. That's Chrome's own words for the reason, from compositing_reasons.cc.
A script keeps the main thread busy for 300 ms. Which of the three recorded changes still reaches the screen during that time?
The leaf's sway. The compositor thread runs that animation and draws its frames, so it never waits for the main thread.
Check your understanding
For each question, ask where the work happens: on the main thread, on the compositor thread, or in the GPU process.
Question 1 of 8What does the second line of the steps model print?
Read the code, then predict// A small model of which steps a change needs, written for this lesson. function stepsFor(change) { const steps = ["commit", "raster", "activate", "draw"]; if (change === "size or place") return ["style", "layout", "pre-paint", "paint", "layerize", ...steps]; if (change === "look") return ["style", "pre-paint", "paint", "layerize", ...steps]; return ["animate", "draw"]; // a transform or opacity animation the compositor runs } console.log(stepsFor("size or place").length); console.log(stepsFor("look").includes("layout")); console.log(stepsFor("compositor animation").join(" -> "));Choose an answer to see the explanation.
Question 2 of 8In Chrome's code at the course's release, which thread runs Layerize?
Choose an answer to see the explanation.
Question 3 of 8What does the commit copy, and where to?
Choose an answer to see the explanation.
Question 4 of 8In the recording, where were the tiles' pixels actually made?
Choose an answer to see the explanation.
Question 5 of 8Why does the compositor thread keep a pending tree as well as an active tree?
Choose an answer to see the explanation.
Question 6 of 8What does Viz's display compositor do with the compositor frames it receives?
Choose an answer to see the explanation.
Question 7 of 8In Firefox, where does WebRender turn the page into GPU commands?
Choose an answer to see the explanation.
Question 8 of 8When does Chrome's main thread wait for the commit to finish?
Choose an answer to see the explanation.
Key takeaways
- Blink runs style, layout, pre-paint, paint and layerize on the renderer's main thread, in that fixed order.
- Each step hands on something simpler: computed styles, the fragment tree, property trees, the display list, then layers.
- The commit copies the layers to the compositor thread. The main thread waits only on frames that answer input.
- Raster workers send drawing commands to the GPU process. Activation shows the new tiles all at once. The draw builds a compositor frame.
- Viz puts every compositor frame together, draws it on the GPU, and swaps it onto the screen.
- Firefox sends a WebRender display list to its GPU process. Safari sends layers to its UI process.
Remember the one-liner.
Blink works the page out, cc copies, rasters and draws it, and Viz puts every frame together on the screen.
Sources
The facts on this page come from these articles, docs and source files. Chromium's are at the release the course records with:
- RenderingNG, Chris Harrelson, Chrome for Developers.
- RenderingNG architecture, Chris Harrelson, Chrome for Developers.
- Key data structures in RenderingNG, Chrome for Developers.
- BlinkNG, Stefan Zager and Chris Harrelson, Chrome for Developers.
- document_lifecycle.h: Blink's lifecycle states, Chromium source, 157.0.8103.52.
- local_frame_view.cc: the lifecycle update, paint and layerize, Chromium source, 157.0.8103.52.
- core/paint/README.md: pre-paint and paint, Chromium docs, 157.0.8103.52.
- platform/graphics/compositing/README.md: the layerize step, Chromium docs, 157.0.8103.52.
- How cc Works, docs/how_cc_works.md, Chromium docs, 157.0.8103.52.
- proxy_main.cc: the commit, from the main thread, Chromium source, 157.0.8103.52.
- layer_tree_host_impl.cc: activation and the compositor frame, Chromium source, 157.0.8103.52.
- gpu_raster_buffer_provider.cc: raster commands for the GPU process, Chromium source, 157.0.8103.52.
- components/viz/README.md: Viz and the display compositor, Chromium docs, 157.0.8103.52.
- display.cc: Display::DrawAndSwap, Chromium source, 157.0.8103.52.
- Rendering Overview, Firefox Source Docs, Mozilla.
- The whole web at maximum FPS: How WebRender gets rid of jank, Lin Clark, Mozilla Hacks.
- Inside a super fast CSS engine: Quantum CSS (aka Stylo), Lin Clark, Mozilla Hacks.
- Graphics, in WebKitGTK and WPE WebKit, WebKit Documentation.
- WebKit2: WebKit's multi-process architecture, WebKit Documentation.
- RemoteLayerTreeHost.h: the UI process's layer tree, WebKit source, webkitgtk-2.54.2.
Coming next: How the metrics are computed. You've seen when a frame reaches the screen. Next, how Chrome turns those moments into LCP, INP and CLS.