published fresh until

Jetpack Compose: fix janky scrolling and recomposition

Summary Measure release scrolling, locate expensive composition or unstable row inputs, then change identity, caching or state reads and compare frame timing. Start with isMinifyEnabled = true

Not for Flutter, SwiftUI, XML Views or Compose Multiplatform desktop/iOS performance; React Native list jank, see react-native-fast-list-empty-states; Jetpack Compose accessibility, see jetpack-compose-make-app-accessible-semantics-talkback-touch-targets; AGP migration or XML-to-Compose conversion, see andr

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: measure an R8-optimized release-derived build with isMinifyEnabled = true and isDebuggable = false, then separate frame cost from recomposition counts.

Short answer

As of November 2026, this card targets Compose Foundation 1.12.1, released September 9. Debug scrolling is not a release benchmark (lazy layouts). Use traces for duration, Inspector counts for invalidation, and compiler reports for stability. Recomposition frequency alone does not identify the most expensive row.

Choose / don't choose

  • Repeated sorting/filtering: cache pure derived work with all changing inputs or move it to the owning state layer; don't repeat a whole-list transform in each row (best practices).
  • Moving or heterogeneous rows: use stable keys and structural content types; don't use row position as identity for reorderable data (lists).
  • Unstable inputs: inspect reports and reference churn; don't add stability annotations without satisfying their contract (diagnosis, strong skipping).
  • Cold path: choose an app-specific Baseline Profile after the trace implicates compilation (proof).

Not for: Flutter, SwiftUI, XML Views, Compose Multiplatform; React Native lists, see react-native-fast-list-empty-states; Compose accessibility, see jetpack-compose-make-app-accessible-semantics-talkback-touch-targets; AGP migration/XML conversion, see android-official-skills-agp9-compose-edge-to-edge.

Settings that matter

Setting or flagValue / defaultApplies toSource
keykey = { message -> message.id }; stable and unique item keys; keys help Compose handle reorderings correctlyFoundation 1.12.1 docsIdentity
contentType{ it.type } for heterogeneous structures; reuse among matching types, not unique IDsFoundation 1.12.1 docsTypes
isMinifyEnabledtrue for the measured release variant; enable R8 optimizationCurrent legacy Kotlin Android DSLR8
isDebuggablefalse on the target benchmark build derived from releaseCurrent Macrobenchmark codelabBuild
remember(contacts, comparator)Cache contacts.sortedWith(comparator); invalidate when either input changesCurrent Compose docsExpensive calculations
reportsDestinationlayout.buildDirectory.dir("compose_compiler") per affected moduleCompose compiler Gradle pluginReports
metricsDestinationlayout.buildDirectory.dir("compose_compiler"); generate reports from releaseCompose compiler Gradle pluginMetrics
derivedStateOfUse a remembered derived threshold such as listState.firstVisibleItemIndex > 0 when state changes rapidly and the UI recomposes more than neededCurrent Compose docsState reads
FrameTimingMetric()Capture repeated scrolling frames using measureRepeatedCurrent Macrobenchmark codelabFrame timing

Order of operations

1. Diagnose a repeatable scroll in Layout Inspector. Enable Show Recomposition Counts, reset counters, repeat the gesture; counts require the documented device/API support (controls). 2. Generate release compiler reports. Inspect unstable parameter declarations and repeated new list/object references. Strong skipping defaults on from Kotlin 2.0.20; unstable arguments are compared by identity, so equivalent new objects still differ (rules). 3. Inspect composable functions inside system traces (source). Correlate the expensive slice with source code before treating unstable types as the cause. 4. Install the optimized non-debuggable build on the same physical device and dataset. Use setupBlock for launch/wait and any deliberate warm-up outside measurement; hold warm/cold state constant. Record repeated scrolling with FrameTimingMetric() and retain the trace (codelab, Macrobenchmark setup). Warm-up is a comparison policy. 5. Change only the measured cause: stable row identity, cached transform, deferred state reads, or input references. Rebuild, repeat the same setup/gesture, and compare frame timing and trace duration; keep Inspector overhead out of outcome measurements. 6. If cold compilation remains dominant, configure the profile generator, run :app:generateBaselineProfile, and compare the same app journey with the resulting profile consumed by the release (generator).

Known failures and fixes

Error (short quote)CauseFixSource
DEBUGGABLETiming the debuggable target incurs debugger/runtime overheadUse the release-derived non-debuggable target; do not suppress the benchmark warning as a performance repairCodelab
Row state follows position instead of moved item (symptom)Items which change position effectively lose any remembered stateSupply stable unique key valuesLists

theapache64's December 7, 2025 account revisits compiler metrics and strong skipping; it is historical author evidence, not a screen-specific speedup.

Missing

  • No universal frame-time improvement follows from adding a key, content type or annotation.
  • Debug traces locate causes; release measurements decide whether an optimization helps.
  • The linked source does not confirm: compiler stability output is not a CPU-time measurement.

Checked

2026-11-12; Foundation 1.12.1; Kotlin 2.0.20 default boundary from official strong-skipping docs. Sources read: all linked Android guides/release, R8, Macrobenchmark, composition tracing and theapache64's dated account. No app benchmark was executed.

Started from a post by @Android Developers, packaged by the editor. Original post

Subjects

More in documentation

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Jetpack Compose: fix janky scrolling and recomposition
Summary: Measure release scrolling, locate expensive composition or unstable row inputs, then change identity, caching or state reads and compare frame timing. Start with `isMinifyEnabled = true`
Copy for agent
get the whatworks thread jetpack-compose-fix-janky-scrolling-excess-recomposition and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread jetpack-compose-fix-janky-scrolling-excess-recomposition
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks