tracing-recompositions-at-runtime

Instruments Jetpack Compose composables with @TraceRecomposition to log per-recomposition diffs in release builds.

Updated May 31, 2026
One-click install
npx skills add https://github.com/decoutkhanqindev/Lich-Viet-Loc-Phat --skill tracing-recompositions-at-runtime-decoutkhanqindev
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: tracing-recompositions-at-runtime
Source: https://github.com/decoutkhanqindev/Lich-Viet-Loc-Phat/tree/main/.claude/skills/tracing-recompositions-at-runtime
Command: npx skills add https://github.com/decoutkhanqindev/Lich-Viet-Loc-Phat --skill tracing-recompositions-at-runtime-decoutkhanqindev

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Layout Inspector only works in debug builds, where Live Literals and the interpreted Compose runtime inflate recomposition counts, so developers cannot confirm stability fixes in release-equivalent builds. This Skill instruments composables with @TraceRecomposition from skydoves/compose-stability-analyzer so per-recomposition diffs (which parameter or state changed, and the value transition) print to logcat under the Recomposition tag in any build, including release-with-debug-symbols. ## Core Features & Use Cases - Gradle plugin setup: Applies the com.github.skydoves.compose.stability.analyzer plugin and configures composeStabilityAnalyzer in the module that owns the composables. - Runtime gating: Gates emission with ComposeStabilityAnalyzer.setEnabled(BuildConfig.DEBUG) or a dedicated BuildConfig.ENABLE_RECOMPOSITION_TRACE flag so production APKs stay silent. - Logcat and heatmap analysis: Reads [Recomposition #N] entries via adb logcat -s Recomposition:D and uses the IntelliJ/Android Studio plugin's gutter heatmap (green under 10, yellow 10-50, red 50+) to spot offending composables. - Use Case: A PriceTicker composable recomposes on every parent tick in release. Annotate it with @TraceRecomposition(traceStates = true), ship a release+R8 dev build, run the user journey, and read logcat lines showing whether the price parameter changed or strong-skipping equals matched. ## Quick Start Instrument my PriceTicker composable with @TraceRecomposition, wire up the compose-stability-analyzer Gradle plugin with a BuildConfig.DEBUG runtime gate, and show me how to read the recomposition diffs in logcat.

Frequently Asked Questions about tracing-recompositions-at-runtime

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I trace recompositions in a Jetpack Compose release build?▼

Apply the com.github.skydoves.compose.stability.analyzer Gradle plugin, annotate the suspect composable with @TraceRecomposition(traceStates = true), and call ComposeStabilityAnalyzer.setEnabled from Application.onCreate. Then run adb logcat -s Recomposition:D to read per-recomposition diffs showing which parameter or state changed.

What is the difference between Layout Inspector and @TraceRecomposition?▼

Layout Inspector counts recompositions only in debug builds, where Live Literals inflate counts. @TraceRecomposition instruments composables at compile time and emits per-recomposition diffs to logcat in any build, including release-with-debug-symbols, making it the ground-truth confirmation tool.

Does @TraceRecomposition work in production release builds?▼

The annotation can remain on composables, but ComposeStabilityAnalyzer.setEnabled must resolve to false in production. Gate it on BuildConfig.DEBUG or a dedicated BuildConfig.ENABLE_RECOMPOSITION_TRACE flag, since logcat I/O on every recomposition adds overhead and can leak parameter values.

Why is my composable recomposing even though the parameter did not change?▼

The logcat diff will show the parameter as unchanged with a reason like parent restart scope re-invoked. If strong-skipping equals matched, the body is skipped; otherwise the parameter type may be unstable, requiring stability diagnosis and type stabilization.

When should I not use runtime recomposition tracing?▼

Skip it when debug-only counts suffice, since Layout Inspector is faster to set up. It also does not replace CI gating: use stabilityCheck to fail builds on future stability regressions, and use Macrobenchmark with FrameTimingMetric for per-frame timing rather than recomposition counts.