May 25, 2026
Compose Performance 2026: Stability as the Key Lever Against Jank
How to master stability in Jetpack Compose to eliminate unnecessary recompositions, improve performance, and deliver smooth UIs.

By Santiago Mattiauda
11 min read
If you've ever noticed your Compose app "freezing" when scrolling through a long list or interacting with a complex UI, you're likely facing an issue with unnecessary recomposition. The good news: the most common cause has a name β type instability β and resolving it is more systematic than it seems.
In this article, we'll break down what stability in Compose is, why it's the most important lever for combating jank, and how to implement it in your project with a concrete action plan.
π This article includes a companion project on GitHub with all the examples ready to run. The link will be available at the end.
Why talk about stability now?
Google actively maintains its official Stability in Compose guide (with updates published in January and February 2026), positioning it as the central pillar of the performance strategy in Compose. This is no coincidence: with the massive adoption of Compose in production, performance issues are no longer "edge cases" β they are the daily reality for teams managing lists, feeds, dashboards, and multi-module UIs.
Stability is no longer a micro-optimization. It's now a daily architectural checklist.
How Compose Decides What to Recompile (and What to Skip)
To understand stability, we need to understand the skip mechanism of the Compose compiler.
When state changes, Compose traverses the composable tree and evaluates whether it needs to re-execute each function. The decision is based on a simple rule:
- β Stable parameters with no changes β Compose skips recompilation (skippable).
- β At least one unstable parameter β Compose always recompiles, even if nothing has changed.
This means that a single unstable parameter can force the recomposition of an entire composable and its entire subtree.
Compiler tags: restartable and skippable
When compiling your code, the Compose compiler marks each composable function with a combination of two tags:
- Restartable: the function can act as a scope from which a recompose starts. It is the re-entry point when a state read within it changes.
- Skippable: the function can be skipped during a recomposition if all its arguments are the same as those from the previous invocation.
A function can be one, both, or neither. Restartable enables recomposition; skippable enables optimization. These are the tags you'll see in the Compose Compiler Reports we cover below.
What makes a type "stable"?
Compose classifies types into three categories:
π‘ Interface stability: by default, interfaces are unstable because the compiler cannot infer them. The exception is SAM interfaces (a single abstract method, such as Comparator), which are treated as function types and are stable. If you need to expose state via an interface, annotate it with @Stable.
β οΈ The annotation contract: annotating with @Stable or @Immutable is an opt-in to a contract with the compiler, similar to Kotlin's !! operator. If the class mutates without notifying Compose, you'll break recomposition in subtle and hard-to-debug ways. The semantic distinction:
@Immutableβ for classes that never change after being constructed.@Stableβ for classes that are potentially mutable but stable (typically backed by snapshot state).
Today the compiler treats both the same, but using the correct one better communicates your intent.
The typical "culprits" of instability
These are the patterns that most frequently cause unnecessary recompositions in real projects:
1. Standard Kotlin collections
Compose always considers the List, Set, and Map types from the standard library to be unstable, because it cannot guarantee that they are immutable.
// β UNSTABLE: List<String> is unstable for Compose
@Composable
fun TagList(tags: List<String>) {
tags.forEach { tag ->
Text(text = tag)
}
}
// β
STABLE: ImmutableList guarantees immutability
import kotlinx.collections.immutable.ImmutableList
@Composable
fun TagList(tags: ImmutableList<String>) {
tags.forEach { tag ->
Text(text = tag)
}
}// β UNSTABLE: List<String> is unstable for Compose
@Composable
fun TagList(tags: List<String>) {
tags.forEach { tag ->
Text(text = tag)
}
}
// β
STABLE: ImmutableList guarantees immutability
import kotlinx.collections.immutable.ImmutableList
@Composable
fun TagList(tags: ImmutableList<String>) {
tags.forEach { tag ->
Text(text = tag)
}
}2. Mutable data models
Using var in the properties of a data class breaks stability:
// β UNSTABLE: mutable properties
data class Contact(var name: String, var number: String)
// β
STABLE: immutable properties
data class Contact(val name: String, val number: String)// β UNSTABLE: mutable properties
data class Contact(var name: String, var number: String)
// β
STABLE: immutable properties
data class Contact(val name: String, val number: String)When Contact is immutable, Compose can compare instances for structural equality and decide whether to skip recomposition:
@Composable
fun ContactRow(contact: Contact, modifier: Modifier = Modifier) {
var selected by remember { mutableStateOf(false) }
Row(modifier) {
ContactDetails(contact) // Skipped if contact hasn't changed
ToggleButton(selected, onToggled = { selected = !selected })
}
}@Composable
fun ContactRow(contact: Contact, modifier: Modifier = Modifier) {
var selected by remember { mutableStateOf(false) }
Row(modifier) {
ContactDetails(contact) // Skipped if contact hasn't changed
ToggleButton(selected, onToggled = { selected = !selected })
}
}In this example, when selected changes, Compose skips ContactDetails because Contact is stable and its value hasn't changed. If Contact were unstable, ContactDetails would be recomposed on every toggleβunnecessarily.
3. Types from other modules (multi-module)
Compose marks any type coming from a module where the Compose compiler does not run as unstable. This is very common in multi-module architectures where domain models live in a :core:model module that does not depend on Compose.
// :core:model module (no Compose dependency)
data class Product(val id: String, val name: String, val price: Double)
// :feature:catalog module (with Compose)
@Composable
fun ProductCard(product: Product) { // β Product is unstable here
Column {
Text(product.name)
Text("$${product.price}")
}
}// :core:model module (no Compose dependency)
data class Product(val id: String, val name: String, val price: Double)
// :feature:catalog module (with Compose)
@Composable
fun ProductCard(product: Product) { // β Product is unstable here
Column {
Text(product.name)
Text("$${product.price}")
}
}Solutions (3 official approaches):
- Stability Configuration File (Compose Compiler 1.5.5+) β declare classes you don't control as stable, without touching their code. We cover this in a dedicated section below.
- Enable the Compose Compiler in the data layer module β just add the dependency for
compose-runtime(notcompose-ui). Then you can annotate your models with@Stableor@Immutable. - Dedicated UI Models in the UI module β the cleanest option when you want to strictly separate data and presentation:
// :feature:catalog module
@Immutable
data class ProductUiModel(
val id: String,
val name: String,
val formattedPrice: String
)
@Composable
fun ProductCard(product: ProductUiModel) { // β
Stable
Column {
Text(product.name)
Text(product.formattedPrice)
}
}// :feature:catalog module
@Immutable
data class ProductUiModel(
val id: String,
val name: String,
val formattedPrice: String
)
@Composable
fun ProductCard(product: ProductUiModel) { // β
Stable
Column {
Text(product.name)
Text(product.formattedPrice)
}
}4. Lambdas: The Most Common Misconception
π― Myth to debunk: a lambda with unstable captures is not an unstable object. The official doc is clear: "The Compose compiler always considers lambdas to be stable." The problem isn't the lambda itself, but rather that without memoization, Compose allocates a new instance on every recomposition, and the comparison with the previous one fails.
With Strong Skipping enabled (default in Kotlin 2.0.20+), Compose automatically memoizes lambdas by wrapping them in a remember(...) with their captures as keys. But in code prior to 2.0.20, or if a lambda has captures that are frequently recreated, the classic pattern applies:
// β New lambda on every recomposition (without Strong Skipping)
@Composable
fun ParentScreen(viewModel: MyViewModel) {
ItemList(
items = viewModel.items,
onClick = { item -> viewModel.onItemClicked(item) } // New instance every time
)
}
// β
Method reference: always the same instance
@Composable
fun ParentScreen(viewModel: MyViewModel) {
ItemList(
items = viewModel.items,
onClick = viewModel::onItemClicked // Same reference
)
}// β New lambda on every recomposition (without Strong Skipping)
@Composable
fun ParentScreen(viewModel: MyViewModel) {
ItemList(
items = viewModel.items,
onClick = { item -> viewModel.onItemClicked(item) } // New instance every time
)
}
// β
Method reference: always the same instance
@Composable
fun ParentScreen(viewModel: MyViewModel) {
ItemList(
items = viewModel.items,
onClick = viewModel::onItemClicked // Same reference
)
}If you need to force a specific lambda not to be memoized (for example, one that is deliberately "single-use"), Compose offers the official @DontMemoize annotation:
val lambda = @DontMemoize { /* ... */ }val lambda = @DontMemoize { /* ... */ }5. Anti-pattern: passing State<T> as a parameter
Passing a State<T> directly to a child composable is tempting, but it exposes implementation details about how state is stored and makes testing and previews difficult. The official documentation recommends passing the value, or a lambda provider when you want to defer reading:
// β Passing State exposes implementation details
@Composable
fun UserItem(userState: State<User>) {
val user by userState
Text(user.name)
}
// β
Passing the value directly
@Composable
fun UserItem(user: User) {
Text(user.name)
}
// β
Or a lambda provider (to defer state reading)
@Composable
fun UserItem(userProvider: () -> User) {
Text(userProvider().name)
}// β Passing State exposes implementation details
@Composable
fun UserItem(userState: State<User>) {
val user by userState
Text(user.name)
}
// β
Passing the value directly
@Composable
fun UserItem(user: User) {
Text(user.name)
}
// β
Or a lambda provider (to defer state reading)
@Composable
fun UserItem(userProvider: () -> User) {
Text(userProvider().name)
}Passing State<T> does not break stability (it is a stable type), but it breaks the principle of state hoisting: each composable should receive only what it needs to render.
Diagnostic tools: measure before optimizing
Before applying any fixes, you need to know where the problems are. Compose offers several tools:
Compose Compiler Reports
The Compose compiler can generate detailed stability reports. With the Compose Compiler Gradle Plugin (standard since Kotlin 2.0), the idiomatic configuration is:
// build.gradle.kts (module-level)
composeCompiler {
reportsDestination = layout.buildDirectory.dir("compose_compiler")
metricsDestination = layout.buildDirectory.dir("compose_compiler")
}// build.gradle.kts (module-level)
composeCompiler {
reportsDestination = layout.buildDirectory.dir("compose_compiler")
metricsDestination = layout.buildDirectory.dir("compose_compiler")
}This generates three files per module:
<modulename>-classes.txtβ inferred stability of each class.<modulename>-composables.txtβ which functions are skippable and restartable.<modulename>-composables.csvβ a format suitable for spreadsheets or CI pipelines.
π‘ Always run the reports on a release build to get representative results.
Example output:
restartable skippable scheme("[androidx.compose.ui.UiComposable]") fun ContactRow(
stable contact: Contact
stable modifier: Modifier? = @static Companion
)restartable skippable scheme("[androidx.compose.ui.UiComposable]") fun ContactRow(
stable contact: Contact
stable modifier: Modifier? = @static Companion
)If you see unstable next to a parameter, that is your action item.
Layout Inspector with recomposition
Android Studio includes a Layout Inspector that displays the number of recompositions in real time. This allows you to visually identify which composables are recomposing excessively.
Metrics in CI
You can integrate the compiler reports into your CI pipeline to detect stability regressions:
- Generate the reports on every build.
- Parse the files and count non-skippable composables.
- Fail the build if the number exceeds a defined threshold.
Strong Skipping Mode
Starting with Kotlin 2.0.20, Strong Skipping Mode is enabled by default in the Compose Compiler. With it, all restartable composable functions become skippable, regardless of whether they have unstable parameters. Non-restartable functions remain non-skippable.
The comparison rules change slightly:
- Stable parameters are compared for structural equality (
equals). - Unstable parameters are compared for reference equality (===).
- Lambdas with unstable captures are automatically memoized.
If your project is still using a version prior to Kotlin 2.0.20 (Compose Compiler 1.5.4+), you can enable it manually:
// build.gradle.kts
composeCompiler {
enableStrongSkippingMode = true
}// build.gradle.kts
composeCompiler {
enableStrongSkippingMode = true
}Why === and not == for unstableparameters ? Comparing references is O(1) and predictable. Comparing values (equals) in mutable collections would be O(n) and, worse, would give a false sense of security: adding an element with add would not trigger recomposition, and the UI would become out of sync with the state.
Extended scope: the same comparison rules that Strong Skipping applies to composable parameters also apply to the keys of automatically memoized lambdas β stable keys are compared with equals, unstable keys with ===. The official documentation clarifies that this is different from a "typical" remember { }, where all keys are compared with equals.
Impact on APK: Enabling Strong Skipping marks more composables as skippable and wraps more lambdas in remember, which generates slightly more code. The impact is minimal: the official documentation reports a +4 KB increase on Now in Android.
Strong Skipping drastically reduces unnecessary recompositions "out of the box," but it does not replace stability best practices: if your unstable instances are recreated on every state change, the by-reference comparison will still fail and recomposition will skyrocket. Strong Skipping is a safety net, not an excuse to ignore architecture.
Stability Configuration File
Starting with Compose Compiler 1.5.5, you can declare classes you don't control as stable β stdlib types (java.time.LocalDateTime), models from external libraries, or classes from modules where the Compose Compiler doesn't runβwithout wrapping them.
Create a plain text file (one class per line), for example stability_config.conf in the project root:
// Consider LocalDateTime stable
java.time.LocalDateTime
// Consider the whole data layer stable
com.miapp.datalayer.*
// Consider submodules as well
com.miapp.datalayer.**
// Stability parameterized by the first type parameter
com.example.GenericClass<*,_>// Consider LocalDateTime stable
java.time.LocalDateTime
// Consider the whole data layer stable
com.miapp.datalayer.*
// Consider submodules as well
com.miapp.datalayer.**
// Stability parameterized by the first type parameter
com.example.GenericClass<*,_>Enable it in the composeCompiler block:
composeCompiler {
stabilityConfigurationFile = rootProject.layout.projectDirectory
.file("stability_config.conf")
}composeCompiler {
stabilityConfigurationFile = rootProject.layout.projectDirectory
.file("stability_config.conf")
}β οΈ Like any stability annotation, this is an opt-in to a contract. If you declare a class as stable that actually mutates without notifying Compose, you'll encounter subtle recomposition bugs.
Multi-module tip: You can have a single file in the root and reference it from each module, or a separate file per module if you need granularity.
Best practices: the stability checklist
β Do
- Separate UI Models from Domain Models: composables should receive types defined in the UI module, annotated with
@Immutableor@Stableif necessary. - Use immutable collections: replace
List,Set, andMapwith their equivalents fromkotlinx.collections.immutable(persistentListOf,persistentMapOf, etc.). - State hoisting: keep state as high up as possible and pass only immutable data down.
- Use
derivedStateOffor derived calculations that should not trigger additional recompositions:
@Composable
fun FilteredList(items: ImmutableList<Item>, query: String) {
val filteredItems by remember(items, query) {
derivedStateOf {
items.filter { it.name.contains(query, ignoreCase = true) }
}
}
LazyColumn {
items(filteredItems) { item ->
ItemRow(item)
}
}
}@Composable
fun FilteredList(items: ImmutableList<Item>, query: String) {
val filteredItems by remember(items, query) {
derivedStateOf {
items.filter { it.name.contains(query, ignoreCase = true) }
}
}
LazyColumn {
items(filteredItems) { item ->
ItemRow(item)
}
}
}- Measure first, optimize later: use Compiler Reports and the Layout Inspector before applying changes.
β Avoid
- Passing "raw"
Lists/Mapsas composable parameters. - Using var in data classes passed to composables.
- Recreate lambdas and objects inside composable functions without remember``.
- Annotating with
@Stable/@Immutablewithout adhering to the contract: if the class mutates internally, the annotation misleads the compiler and will cause subtle bugs. - Over-optimizing without measuring: not all recompositions are bad. Only those that cause visible jank warrant attention.
Integrated example: before and after
Let's look at a realistic case β a filtered product feed:
β Before (unstable)
// Domain model in :core:model (no Compose compiler)
data class Product(
val id: String,
var name: String, // var β unstable
val tags: List<String> // List β unstable
)
// In :feature:catalog
@Composable
fun ProductFeed(products: List<Product>) { // List<unstable> β never skips
LazyColumn {
items(products) { product ->
ProductCard(
product = product,
onClick = { navigateTo(product.id) } // Recreated lambda
)
}
}
}// Domain model in :core:model (no Compose compiler)
data class Product(
val id: String,
var name: String, // var β unstable
val tags: List<String> // List β unstable
)
// In :feature:catalog
@Composable
fun ProductFeed(products: List<Product>) { // List<unstable> β never skips
LazyColumn {
items(products) { product ->
ProductCard(
product = product,
onClick = { navigateTo(product.id) } // Recreated lambda
)
}
}
}Result: every state change in ProductFeed recomposes all ProductCards, even if no products have changed.
β After (stable)
// UI Model in :feature:catalog
@Immutable
data class ProductUiModel(
val id: String,
val name: String,
val tags: ImmutableList<String>
)
@Composable
fun ProductFeed(
products: ImmutableList<ProductUiModel>,
onProductClick: (String) -> Unit
) {
LazyColumn {
items(
items = products,
key = { it.id }
) { product ->
ProductCard(
product = product,
onClick = { onProductClick(product.id) }
)
}
}
}
@Composable
fun ProductCard(
product: ProductUiModel,
onClick: () -> Unit
) {
// Compose can skip this recomposition if product hasn't changed
Card(onClick = onClick) {
Text(product.name)
FlowRow {
product.tags.forEach { tag ->
AssistChip(onClick = {}, label = { Text(tag) })
}
}
}
}// UI Model in :feature:catalog
@Immutable
data class ProductUiModel(
val id: String,
val name: String,
val tags: ImmutableList<String>
)
@Composable
fun ProductFeed(
products: ImmutableList<ProductUiModel>,
onProductClick: (String) -> Unit
) {
LazyColumn {
items(
items = products,
key = { it.id }
) { product ->
ProductCard(
product = product,
onClick = { onProductClick(product.id) }
)
}
}
}
@Composable
fun ProductCard(
product: ProductUiModel,
onClick: () -> Unit
) {
// Compose can skip this recomposition if product hasn't changed
Card(onClick = onClick) {
Text(product.name)
FlowRow {
product.tags.forEach { tag ->
AssistChip(onClick = {}, label = { Text(tag) })
}
}
}
}Result: only the cards whose data has changed are re-rendered. The feed with 100+ items no longer lags.
Pattern: Hoisted State Type
When a reusable component begins to accumulate multiple state parameters and callbacks, the official Compose API guidelines recommend extracting that state into a State-type class , backed by a snapshot state, which is hoisted upwardβjust like LazyListState, ScrollState, or DrawerState.
@Stable
class MapState {
private val _location = mutableStateOf<Position?>(null)
val latitude by derivedStateOf { _location.value?.latitude }
val longitude by derivedStateOf { _location.value?.longitude }
fun changeLocation(position: Position) {
_location.value = position
}
}
@Composable
fun rememberMapState(): MapState = remember { MapState() }
@Composable
fun MapComponent(
mapState: MapState = rememberMapState()
) {
// Uses mapState.latitude, mapState.longitude...
}@Stable
class MapState {
private val _location = mutableStateOf<Position?>(null)
val latitude by derivedStateOf { _location.value?.latitude }
val longitude by derivedStateOf { _location.value?.longitude }
fun changeLocation(position: Position) {
_location.value = position
}
}
@Composable
fun rememberMapState(): MapState = remember { MapState() }
@Composable
fun MapComponent(
mapState: MapState = rememberMapState()
) {
// Uses mapState.latitude, mapState.longitude...
}If you want to allow multiple implementations (for example, for testing), expose the contract as an interface annotated with @Stable:
@Stable
interface MapState {
val latitude: Double?
val longitude: Double?
}
private class MapStateImpl : MapState { /* ... */ }
@Composable
fun rememberMapState(): MapState = remember { MapStateImpl() }@Stable
interface MapState {
val latitude: Double?
val longitude: Double?
}
private class MapStateImpl : MapState { /* ... */ }
@Composable
fun rememberMapState(): MapState = remember { MapStateImpl() }This pattern solves three problems at once: it maintains stability, prevents the API from exploding into N parameters, and centralizes state logic in a testable location.
Not every composable should be skippable
Making every composable in the project skippable is premature optimization. The official documentation identifies three scenarios where it isn't worth it:
- Composables that almost never recompose β the cost of checking parameter equality is pure overhead.
- Composables that only delegate to other composables that are already skippable β the "real" skip happens downstream; adding it upstream doesn't change anything.
- Composables with many parameters and expensive
equals()β comparing may be more expensive than recomposing.
Under Strong Skipping, you can also choose to make a specific composable restartable but not skippable using the official @NonSkippableComposable annotation:
@NonSkippableComposable
@Composable
fun MyNonSkippableComposable() { /* ... */ }@NonSkippableComposable
@Composable
fun MyNonSkippableComposable() { /* ... */ }The golden rule: measure, identify the real jank, and optimize only what matters.
3-Step Action Plan
If you want to bring stability to your project in an orderly way, follow this plan:
Step 1: Diagnose π
- Enable Compose Compiler Reports in your project.
- Identify restartable but non-skippable composables.
- Use the Layout Inspector to confirm excessive recompositions on critical screens.
Step 2: Prioritize π
- Focus on composables inside
LazyColumn/LazyRow(most visible impact). - Prioritize screens with frequent interaction (feeds, forms, dashboards).
- Don't touch composables that are already skippable β if it ain't broke, don't fix it.
Step 3: Fix π οΈ
- Create immutable UI Models for high-impact composables.
- Migrate collections to
kotlinx.collections.immutable. - Stabilize lambdas with
rememberor method references. - Evaluate enabling Strong Skipping Mode.
- Add compiler reports to CI to prevent regressions.
GitHub - santimattius/compose-stability-playground Contribute to santimattius/compose-stability-playground development by creating an account on GitHub.
Conclusion
Stability in Compose isn't an implementation detail β it's an architectural decision that directly impacts the user experience. With Google's updated tools and guidelines, there's no longer any excuse to leave stability to chance.
The path is clear: diagnose with data, prioritize by impact, and fix with immutable types and state hoisting. If you do this consistently, jank ceases to be a mystery and becomes a solved problem.
References
- Stability in Compose β Android Developers
- Diagnose stability issues β Android Developers
- Fix stability issues β Android Developers
- Strong skipping mode β Android Developers
- Jetpack Compose Performance β Android Developers
- Deeper Performance Considerations β Android Developers Blog
- Compose Compiler release notes β Android Developers
- kotlinx.collections.immutable β GitHub