Parsing, Styling, Layout, Painting, Your Code and Every Press of a Button Take Turns on a Single Queue, and Whoever Is Holding It Is Holding Everything
Last timeWhy the Page Jumps
Why a computation that takes 300 milliseconds freezes the page, what the two ways out actually are, and which parts of the work can be moved and which genuinely cannot.
What shares the queue
Seven lessons have described separate machinery: a parser, a style resolver, a
layout pass, a painter, a compositor, your own code. They are not separate in
the way the lessons made them sound. Almost all of it runs on one thread, in
one queue, one item at a time, and each item runs to completion before the next
one starts.
That rule is the whole lesson. There is no interrupting. A task that has
started will finish before anything else happens, including the handling of a
press that arrived while it was running, including the production of the next
frame.
Some work genuinely does happen elsewhere. Painting and assembly can run on
other threads, image decoding usually does, and a separate process is often
doing the networking. But styling, layout, and all of your own code run in the
one place, so those are the ones that can block everything.
How a freeze happens
Consider a function that takes three hundred milliseconds. Perhaps it is
sorting ten thousand rows, or parsing a large response, or computing a layout
of its own in code.
The lesson stops here
4 more paragraphs to go
You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.
The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.
See the planThe contentsThis is the reading half
Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.
The contents