Featured as the #1 Book on Leanpub

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.

4
Chapters
539
PDF Pages
64
Deep-Dive Topics
54
Diagrams

Written by reading the AOSP source line by line, and from hands-on experience building Compose tooling.

About the Author

Jaewoong Eum (skydoves)

Jaewoong Eum (skydoves)

Google Developer Expert (Android & Firebase) · Senior Developer Advocate & Engineer at RevenueCat

I am Jaewoong Eum (also known as skydoves), a Google Developer Expert (GDE) for Android and Firebase, formerly Kotlin. I have created over 100 open-source libraries and projects, downloaded more than 15 million times annually by developers worldwide, many of them built on Jetpack Compose.

Most developers know how to use Compose, but far fewer understand the magic that happens underneath a @Composable function. I wrote this book to close that gap: to help you see what really runs beneath your UI, then put that understanding to work using Compose correctly and tuning its performance in the products you build today. It continues my previous books Manifest Android Interview and Practical Kotlin Deep Dive.

Just as importantly, this book is not based on source reading alone. It is grounded in my own hands-on experience building Compose tooling and libraries, including Compose Stability Analyzer, Compose Stability Inference, Compose Navigation Graph, Compose HotSwan, and Compose Performance Skills. Every mechanism in these pages is something I have used, debugged, and shipped in production.

I hope this book helps you build a complete mental model of Compose, from compiler transformations and snapshot-based state to layout, drawing, and the performance characteristics that follow from them.

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. 1@Composable: From annotation to code transformationp.10
  2. 2Stability inference: How the compiler classifies parametersp.24
  3. 3Lambda memoization: Preventing unnecessary recompositionp.35
  4. 4The Compose compiler plugin architecturep.44
  5. 5The IR transformation pipelinep.48
  6. 6Composer parameter injectionp.56
  7. 7The $changed bitmask: Tracking parameter mutationsp.60
  8. 8Composable function body transformationp.69
  9. 9Durable function keysp.83
  10. 10The complete picture: Tracing a composable through all passesp.88
  11. 11Feature flags and compiler optimizationsp.90
  12. 12Reading Compose compiler reportsp.94
  13. 13Stability configuration: Controlling inference for external typesp.103
  14. 14Debugging recomposition with composition tracingp.114
  15. 15Live Literals: How the compiler enables literal hot swapp.123
  16. 16Chapter 1 key takeawaysp.131
Includes 10 Pro Tips & Fun Facts
  1. 1Remember and cachingp.136
  2. 2State management: mutableStateOf and the state record systemp.145
  3. 3Derived state: Lazy computation with dependency trackingp.150
  4. 4Effects: Side effects in a declarative worldp.155
  5. 5CompositionLocal: Implicit data passing through the treep.164
  6. 6The Composer: Orchestrating compositionp.170
  7. 7The SlotTable: A gap buffer for UI statep.176
  8. 8Groups: The building blocks of compositionp.195
  9. 9The snapshot system: Isolation through MVCCp.203
  10. 10The Recomposer: Scheduling and executing recompositionp.214
  11. 11The Applier: Bridging runtime and treesp.223
  12. 12MovableContent: Preserving state across tree movesp.231
  13. 13Bridging state and Flow: snapshotFlow, collectAsState, and produceStatep.235
  14. 14Common state pitfalls: Why the runtime behaves the way it doesp.244
  15. 15Recomposition scope: What actually gets re-executedp.252
  16. 16Testing with snapshots: Controlling time and state in testsp.262
  17. 17Chapter 2 key takeawaysp.268
Includes 10 Pro Tips & Fun Facts
  1. 1Modifier order: Why sequence changes everythingp.272
  2. 2LayoutNode: The central element of the UI treep.274
  3. 3The modifier system: From Modifier to Modifier.Nodep.279
  4. 4The coordinator chain: Measure and layout delegationp.293
  5. 5The measurement and layout pipelinep.299
  6. 6The rendering pipeline: From draw calls to pixelsp.307
  7. 7Input and gesture handling: From touch to composablep.315
  8. 8Focus management: Keyboard navigation and focus traversalp.326
  9. 9Semantics and accessibility: Making Compose accessiblep.330
  10. 10The lookahead system: Predictive measurement for animationp.335
  11. 11SubcomposeLayout: Dynamic composition during measurementp.339
  12. 12Android integration: AndroidComposeView and the platform bridgep.348
  13. 13Building custom layouts with the Layout composablep.355
  14. 14Creating custom Modifier.Node implementationsp.361
  15. 15Shared element transitions: From LookaheadScope to SharedTransitionScopep.366
  16. 16The shared element API: small surface, large machinep.372
  17. 17Nested scrolling: How scroll events flow through the modifier chainp.375
  18. 18Lazy layouts: How LazyColumn builds on SubcomposeLayoutp.382
  19. 19Building your own Compose UI: the runtime, your treep.390
  20. 20Chapter 3 key takeawaysp.400
Includes 12 Pro Tips & Fun Facts
  1. 1Three rendering phases: Where performance costs livep.407
  2. 2Stability inference: The 12 phase algorithmp.415
  3. 3The skip decision: From stability to executionp.434
  4. 4Stability patterns: Making your types skip friendlyp.448
  5. 5State reads: Where you read determines what recomposesp.461
  6. 6Lambda recomposition: When event handlers trigger rebuildsp.473
  7. 7Measuring performance: From compiler reports to CI validationp.478
  8. 8Anti-patterns: Six ways to accidentally slow down Composep.498
  9. 9Advanced techniques: When stability is not enoughp.508
  10. 10Case study: Optimizing a chat message listp.521
  11. 11Chapter 4 key takeawaysp.531
Includes 9 Pro Tips & Fun Facts
Jetpack Compose Mechanisms course
The Jetpack Compose Mechanisms Course

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.

Compiler
Runtime
UI
Performance
8ch·59lessons
Structured curriculum
~880p
Book-equivalent depth
123
Practical questions
240
Quiz & exercises

Jaewoong Eum (skydoves) · Updated for Kotlin 2.4.0 · Compose Compiler 2.4.0

Journey

Timeline & Milestones

June 17, 2026
Reached 100 copies sold 🎉
June 16, 2026
Published the first edition.