Kick off your book project, get started with GhostAI, get better at marketing, or spend the day doing all three! Free live workshops on Zoom. Saturday, June 27, 2026.

Leanpub Header

Skip to main content

Jetpack Compose Mechanisms

A dissection of what runs beneath every @Composable

This book is 100% completeLast updated on 2026-06-16

This book takes you straight into the Compose compiler, runtime, and UI layer, all about Compose performance tuning, reading the source line by line and explaining the why behind every design decision, then connecting each internal mechanism back to the code you write every day. With four in-depth chapters, 40+ original diagrams, dozens of "In Practice" sections, and "Pro Tips for Mastery" sidebars, it turns Compose from a set of APIs you memorize into a system you can reason about from first principles, debug with confidence, and optimize with intent.

The Course: Jetpack Compose Mechanisms

Minimum price

$42.99

$52.99

You pay

Author earns

$

Also available for 2 book credits with a Reader Membership

Buying multiple copies for your team? See below for a discount!

PDF
EPUB
WEB
APP
539
Pages
126,983Words
About

About

About the Book

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 AnalyzerCompose Stability InferenceCompose Navigation GraphCompose 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)

Team Discounts

Team Discounts

Get a team discount on this book!

  • Up to 3 members

    Minimum price
    $107
    Suggested price
    $132
  • Up to 5 members

    Minimum price
    $171
    Suggested price
    $211
  • Up to 10 members

    Minimum price
    $300
    Suggested price
    $370
  • Up to 15 members

    Minimum price
    $429
    Suggested price
    $529
  • Up to 25 members

    Minimum price
    $644
    Suggested price
    $794

Bundles

Bundles that include this book

Author

About the Author

Jaewoong

The author of this book, Jaewoong Eum (known as skydoves), is a Google Developer Expert (GDE) for Android, Kotlin, and Firebase; an open-source developer who has created 100+ open-source libraries and projects, collectively amassing 40+ million downloads annually. The author of the Manifest Android Interview / Practical Kotlin Deep Dive books and also the founder of Dove Letter, a subscription-based repository dedicated to sharing, learning, and discussing Android and Kotlin development.

Contents

Table of Contents

Preface

  1. Who This Book Is For
  2. What This Book Covers
  3. Issue Report

Chapter 1: The Compose Compiler

  1. @Composable: From annotation to code transformation
  2. Stability inference: How the compiler classifies parameters
  3. Lambda memoization: Preventing unnecessary recomposition
  4. The Compose compiler plugin architecture
  5. The IR transformation pipeline
  6. Composer parameter injection
  7. The $changed bitmask: Tracking parameter mutations
  8. Composable function body transformation
  9. Durable function keys
  10. The complete picture: Tracing a composable through all passes
  11. Feature flags and compiler optimizations
  12. Reading Compose compiler reports
  13. Stability configuration: Controlling inference for external types
  14. Debugging recomposition with composition tracing
  15. Live Literals: How the compiler enables literal hot swap
  16. Chapter 1 key takeaways

Chapter 2: The Compose Runtime

  1. Remember and caching
  2. State management: mutableStateOf and the state record system
  3. Derived state: Lazy computation with dependency tracking
  4. Effects: Side effects in a declarative world
  5. CompositionLocal: Implicit data passing through the tree
  6. The Composer: Orchestrating composition
  7. The SlotTable: A gap buffer for UI state
  8. Groups: The building blocks of composition
  9. The snapshot system: Isolation through MVCC
  10. The Recomposer: Scheduling and executing recomposition
  11. The Applier: Bridging runtime and trees
  12. MovableContent: Preserving state across tree moves
  13. Bridging state and Flow: snapshotFlow, collectAsState, and produceState
  14. Common state pitfalls: Why the runtime behaves the way it does
  15. Recomposition scope: What actually gets re-executed
  16. Testing with snapshots: Controlling time and state in tests
  17. Chapter 2 key takeaways

Chapter 3: The Compose UI

  1. Modifier order: Why sequence changes everything
  2. LayoutNode: The central element of the UI tree
  3. The modifier system: From Modifier to Modifier.Node
  4. The coordinator chain: Measure and layout delegation
  5. The measurement and layout pipeline
  6. The rendering pipeline: From draw calls to pixels
  7. Input and gesture handling: From touch to composable
  8. Focus management: Keyboard navigation and focus traversal
  9. Semantics and accessibility: Making Compose accessible
  10. The lookahead system: Predictive measurement for animation
  11. SubcomposeLayout: Dynamic composition during measurement
  12. Android integration: AndroidComposeView and the platform bridge
  13. Building custom layouts with the Layout composable
  14. Creating custom Modifier.Node implementations
  15. Shared element transitions: From LookaheadScope to SharedTransitionScope
  16. The shared element API: small surface, large machine
  17. Nested scrolling: How scroll events flow through the modifier chain
  18. Lazy layouts: How LazyColumn builds on SubcomposeLayout
  19. Building your own Compose UI: the runtime, your tree
  20. Chapter 3 key takeaways

Chapter 4: Performance

  1. Three rendering phases: Where performance costs live
  2. Stability inference: The 12 phase algorithm
  3. The skip decision: From stability to execution
  4. Stability patterns: Making your types skip friendly
  5. State reads: Where you read determines what recomposes
  6. Lambda recomposition: When event handlers trigger rebuilds
  7. Measuring performance: From compiler reports to CI validation
  8. Anti patterns: Six ways to accidentally slow down Compose
  9. Advanced techniques: When stability is not enough
  10. Case study: Optimizing a chat message list
  11. Chapter 4 key takeaways

Conclusion

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub