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 flag | Value / default | Applies to | Source |
|---|---|---|---|
key | key = { message -> message.id }; stable and unique item keys; keys help Compose handle reorderings correctly | Foundation 1.12.1 docs | Identity |
contentType | { it.type } for heterogeneous structures; reuse among matching types, not unique IDs | Foundation 1.12.1 docs | Types |
isMinifyEnabled | true for the measured release variant; enable R8 optimization | Current legacy Kotlin Android DSL | R8 |
isDebuggable | false on the target benchmark build derived from release | Current Macrobenchmark codelab | Build |
remember(contacts, comparator) | Cache contacts.sortedWith(comparator); invalidate when either input changes | Current Compose docs | Expensive calculations |
reportsDestination | layout.buildDirectory.dir("compose_compiler") per affected module | Compose compiler Gradle plugin | Reports |
metricsDestination | layout.buildDirectory.dir("compose_compiler"); generate reports from release | Compose compiler Gradle plugin | Metrics |
derivedStateOf | Use a remembered derived threshold such as listState.firstVisibleItemIndex > 0 when state changes rapidly and the UI recomposes more than needed | Current Compose docs | State reads |
FrameTimingMetric() | Capture repeated scrolling frames using measureRepeated | Current Macrobenchmark codelab | Frame 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) | Cause | Fix | Source |
|---|---|---|---|
DEBUGGABLE | Timing the debuggable target incurs debugger/runtime overhead | Use the release-derived non-debuggable target; do not suppress the benchmark warning as a performance repair | Codelab |
| Row state follows position instead of moved item (symptom) | Items which change position effectively lose any remembered state | Supply stable unique key values | Lists |
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