You write @Composable functions every day. Do you actually know what happens under the hood?
Most resources teach you how to use Compose. Jetpack Compose Mechanisms explains why it behaves the way it does, traced line by line through the AOSP source: from @Composable transformations to the gap buffer that stores your composition, to the single-pass pipeline that turns declarations into pixels. And rather than a dry, encyclopedic tour of internal APIs, it draws on the author's hands-on experience to pair every mechanism with highly practical, production-ready examples, so you fully internalize how Compose works instead of just memorizing it. Fully updated for the latest Kotlin 2.4.0 and Compose Compiler 2.4.0.
Here is the thing almost no one tells you: the @Composable function you wrote is not the function that runs. By the time the compiler is finished, a second, hidden function has taken its place, with a $composer threaded through every call, a $changed bitmask deciding whether to skip, a slot table quietly remembering your state by position, and a LayoutNode tree measured in a single pass and recorded into hardware layers. You have felt this machinery every time a recomposition fired when you did not expect it, every time a list scrolled with jank you could not explain, every time a compiler report flagged a composable as "not skippable" and left you guessing why. This book is the manual for all of it.
You will learn why @Composable is not an annotation but a change to the function's type, how the compiler rewrites your code into something closer to a state machine, why mutableStateOf triggers recomposition while a plain var silently does not, how the snapshot system hands you multithreaded state with no locks, why a single unstable List field can quietly tank an entire screen, and how the layout system measures everything in one pass without the exponential blowup that haunted the View world. Every chapter opens where any Compose developer can follow and ends somewhere you did not know the rabbit hole reached.
Just as importantly, this book is not based on Compose internal source reading alone. It is grounded in my own hands on experience building Compose tooling and libraries, such as Compose Stability Analyzer, Compose Stability Inference, Compose Navigation Graph, Compose HotSwan, and Compose Performance Skills. Every mechanism in these pages is something the author have used, debugged, and shipped in production, even the Composer/Kotlin compilers and Compose runtime.
The book follows Compose down through its three layers, then back up into practice. Chapter 1 opens the compiler and watches your @Composable functions get rewritten: the $composer and $changed parameters, the stability inference that decides what can skip, lambda memoization, and the dozen IR passes that produce the code that actually runs. Chapter 2 moves into the runtime: the gap buffer slot table that remembers your composition by position, the snapshot system that hands you lock-free, multithreaded state, the Recomposer that schedules work at frame boundaries, and the Applier seam that lets the same engine drive any tree. Chapter 3 turns that tree into pixels: the LayoutNode, the modern Modifier.Node system and its coordinator chain, single-pass measurement, graphics layers, input, semantics, lookahead and shared element transitions, and SubcomposeLayout, ending by building a tiny working Compose UI from scratch.
Chapter 4 is where it all comes together. It pulls everything from the first three chapters into a practical, battle-tested performance playbook, drawn directly from the author's experience shipping Compose libraries and tooling. You will walk the stability inference algorithm phase by phase, watch the runtime make its skip decision for a real composable, learn to scope state reads to the right rendering phase, fix the lambda and ViewModel patterns that quietly trigger rebuilds, and measure it all with compiler reports, recomposition tracing, the Layout Inspector, and Macrobenchmark. It names the handful of anti-patterns that silently cost you frames, and closes with a full case study that takes a janky chat screen from 47 recompositions a second down to zero. By the end, you are not just reading about performance, you can diagnose and fix it straight from the source.
By the last page, Compose stops being a set of APIs to memorize and rules to follow on faith. It becomes a system you can reason about from first principles, predict before you press Run, and debug straight from the source. If you have ever wanted to stop guessing and actually see what runs beneath your UI, this is the book you have been looking for.
ā Jaewoong Eum (skydoves)