Recomposition Tracking
Track Jetpack Compose recompositions per composable in real time.
WormaCeptor tracks how often each Compose function recomposes during a session, then surfaces the results in the Recomposition Inspector screen. You opt composables in by tagging them with a Modifier.trackRecomposition("name").
import com.azikar24.wormaceptor.api.compose.trackRecomposition
@Composable
fun ProductCard(product: Product) {
Card(modifier = Modifier.trackRecomposition("ProductCard")) {
// ...
}
}Open the Recomposition Inspector from the WormaCeptor tools grid to see live counts, rates per second, and the top recomposers.
Release Build Safety
Modifier.trackRecomposition lives in wormaceptor-client, so it compiles in every build type. It looks up the tracker by reflection: in release builds, where the debug-only implementation is absent, the lookup fails and the modifier returns this with no Compose overhead. No debug/release source-set wrappers are needed.
Programmatic Access
If you need to read tracking data outside the Recomposition Inspector UI, use the RecompositionTracker singleton. It lives in wormaceptor-feature-recomposition, pulled in transitively by wormaceptor-persistence, so call it from debug-only code.
import com.azikar24.wormaceptor.feature.recomposition.RecompositionTracker
val total = RecompositionTracker.getTotalRecompositions()
val top = RecompositionTracker.getTopRecomposers(limit = 5)
val rate = RecompositionTracker.getRate("ProductCard")
RecompositionTracker.reset()API Reference
| Member | Returns | Description |
|---|---|---|
Modifier.trackRecomposition(name) | Modifier | Records a recomposition event each time the host composable recomposes. |
RecompositionTracker.record(name) | Unit | Manually records a recomposition. Usually invoked by the modifier. |
RecompositionTracker.getAll() | Map<String, RecompositionData> | Snapshot of every tracked composable. |
RecompositionTracker.getRate(name) | Float | Recompositions per second for name over the last 3 seconds. |
RecompositionTracker.getTopRecomposers(limit) | List<RecompositionData> | The hottest recomposers, sorted by recent rate, then count. limit defaults to 10. |
RecompositionTracker.getSessionDuration() | Long | Millis since the first recorded event, or 0 before any. |
RecompositionTracker.getTotalRecompositions() | Long | Sum of recomposition counts across every tracked composable. |
RecompositionTracker.reset() | Unit | Clears all tracking data and resets the session timer. |
Disabling
Recomposition tracking is part of the COMPOSE_RECOMPOSITION_INSPECTOR feature. Drop it from the Feature set passed to WormaCeptorApi.init(...) to hide the inspector entry. In debug builds the modifier still records through a SideEffect into a singleton, so leaving it in tagged composables when the feature is disabled costs only a map update.
See Feature Toggles for how to compose feature sets.