Jetpack Compose Mechanisms
A dissection of what runs beneath every @Composable: how the compiler, runtime, and UI layer actually work.
Most resources teach you how to use Compose. This book 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 walkthrough of every internal API, 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.
Written by reading the AOSP source line by line, and from hands-on experience building Compose tooling.
Understand Compose From the Inside Out
What Sets This Book Apart
From compile-time transformations to on-screen pixels, grounded in the actual source
🔬Straight From the Source
Written by reading the Compose compiler, runtime, and UI source in AOSP line by line, not paraphrased docs, and battle-tested against real Compose tooling the author has built and shipped. And it all builds toward one practical payoff: the understanding you need to improve real-world Compose performance.
🧠Why, Not Just How
Goes beyond API usage to explain why Compose behaves the way it does: stability inference, recomposition, the snapshot system, and the single-pass measurement model that defines how your UI runs.
🎨54 Original Diagrams
Complex mechanisms (IR transformations, the SlotTable gap buffer, the coordinator chain) made visual with 54 original diagrams you can actually follow and reason about.
📈Progressive Depth
Each chapter starts with concepts any Android developer can follow and gradually descends into deep internals, so you can stop at any point and still walk away with practical knowledge.
Inside the Book
54 Original Diagrams
The hardest internals (IR transformations, the SlotTable gap buffer, effect lifecycles, stability inference) visualized so you can actually see how Compose works, not just read about it.
A sample of the diagrams inside the book. Click any diagram to zoom in.
Content Structure
What's Inside This Book
64 deep-dive topics across 4 chapters
This book does more than just teach you the inner workings of Compose. It provides actionable insights you can immediately apply to real-world projects and utilize for high-level performance tuning.
What makes it different is that it is not theory written from the outside. Every chapter is grounded in real experience building Compose tooling, including Compose Stability Analyzer, Compose Stability Inference, Compose Navigation Graph, Compose HotSwan, and Compose Performance Skills, so the insights are battle-tested and immediately useful in production code.
- 1@Composable: From annotation to code transformationp.10
- 2Stability inference: How the compiler classifies parametersp.24
- 3Lambda memoization: Preventing unnecessary recompositionp.35
- 4The Compose compiler plugin architecturep.44
- 5The IR transformation pipelinep.48
- 6Composer parameter injectionp.56
- 7The $changed bitmask: Tracking parameter mutationsp.60
- 8Composable function body transformationp.69
- 9Durable function keysp.83
- 10The complete picture: Tracing a composable through all passesp.88
- 11Feature flags and compiler optimizationsp.90
- 12Reading Compose compiler reportsp.94
- 13Stability configuration: Controlling inference for external typesp.103
- 14Debugging recomposition with composition tracingp.114
- 15Live Literals: How the compiler enables literal hot swapp.123
- 16Chapter 1 key takeawaysp.131
- 1Remember and cachingp.136
- 2State management: mutableStateOf and the state record systemp.145
- 3Derived state: Lazy computation with dependency trackingp.150
- 4Effects: Side effects in a declarative worldp.155
- 5CompositionLocal: Implicit data passing through the treep.164
- 6The Composer: Orchestrating compositionp.170
- 7The SlotTable: A gap buffer for UI statep.176
- 8Groups: The building blocks of compositionp.195
- 9The snapshot system: Isolation through MVCCp.203
- 10The Recomposer: Scheduling and executing recompositionp.214
- 11The Applier: Bridging runtime and treesp.223
- 12MovableContent: Preserving state across tree movesp.231
- 13Bridging state and Flow: snapshotFlow, collectAsState, and produceStatep.235
- 14Common state pitfalls: Why the runtime behaves the way it doesp.244
- 15Recomposition scope: What actually gets re-executedp.252
- 16Testing with snapshots: Controlling time and state in testsp.262
- 17Chapter 2 key takeawaysp.268
- 1Modifier order: Why sequence changes everythingp.272
- 2LayoutNode: The central element of the UI treep.274
- 3The modifier system: From Modifier to Modifier.Nodep.279
- 4The coordinator chain: Measure and layout delegationp.293
- 5The measurement and layout pipelinep.299
- 6The rendering pipeline: From draw calls to pixelsp.307
- 7Input and gesture handling: From touch to composablep.315
- 8Focus management: Keyboard navigation and focus traversalp.326
- 9Semantics and accessibility: Making Compose accessiblep.330
- 10The lookahead system: Predictive measurement for animationp.335
- 11SubcomposeLayout: Dynamic composition during measurementp.339
- 12Android integration: AndroidComposeView and the platform bridgep.348
- 13Building custom layouts with the Layout composablep.355
- 14Creating custom Modifier.Node implementationsp.361
- 15Shared element transitions: From LookaheadScope to SharedTransitionScopep.366
- 16The shared element API: small surface, large machinep.372
- 17Nested scrolling: How scroll events flow through the modifier chainp.375
- 18Lazy layouts: How LazyColumn builds on SubcomposeLayoutp.382
- 19Building your own Compose UI: the runtime, your treep.390
- 20Chapter 3 key takeawaysp.400
- 1Three rendering phases: Where performance costs livep.407
- 2Stability inference: The 12 phase algorithmp.415
- 3The skip decision: From stability to executionp.434
- 4Stability patterns: Making your types skip friendlyp.448
- 5State reads: Where you read determines what recomposesp.461
- 6Lambda recomposition: When event handlers trigger rebuildsp.473
- 7Measuring performance: From compiler reports to CI validationp.478
- 8Anti-patterns: Six ways to accidentally slow down Composep.498
- 9Advanced techniques: When stability is not enoughp.508
- 10Case study: Optimizing a chat message listp.521
- 11Chapter 4 key takeawaysp.531

Understand why every @Composable behaves the way it does.
Trace the AOSP source line by line through the compiler, runtime, and UI layers beneath every Composable, then tie all three together into deep, real-world performance tuning, from stability inference to the skip decision.
Jaewoong Eum (skydoves) · Updated for Kotlin 2.4.0 · Compose Compiler 2.4.0
Also by skydoves
Other Books by the Author
If this book resonates with you, you might enjoy my other books.

Manifest Android Interview
108 in-depth interview questions and practical exercises across the Android framework, Jetpack Compose, and Jetpack libraries.
Visit site
Practical Kotlin Deep Dive
492 pages from core Kotlin fundamentals to coroutines, Flow, compiler internals, and Kotlin Multiplatform.
Visit siteJourney