Recomposition Tracking
Track Jetpack Compose recompositions per composable in real time.
Recomposition Tracking
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.core.ui.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
The trackRecomposition modifier and RecompositionTracker API live in the wormaceptor-core-ui artifact, which is pulled in transitively by wormaceptor-persistence (debug only). To keep release builds compiling, isolate the call behind a debug-only source set or a thin extension you no-op in release.
import com.azikar24.wormaceptor.core.ui.trackRecomposition as wormaTrackRecomposition
fun Modifier.trackRecomposition(name: String): Modifier =
this.wormaTrackRecomposition(name)fun Modifier.trackRecomposition(name: String): Modifier = thisNow your composables can call Modifier.trackRecomposition("Name") everywhere and the release variant becomes a no-op with zero runtime cost.
Programmatic Access
If you need to read tracking data outside the Recomposition Inspector UI, use the RecompositionTracker singleton (debug builds only).
import com.azikar24.wormaceptor.core.ui.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 session. |
RecompositionTracker.getTopRecomposers(limit) | List<RecompositionData> | The hottest recomposers, sorted by rate. |
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. The modifier itself becomes a cheap SideEffect recording into a singleton, so leaving it in tagged composables when the feature is disabled costs only a map lookup.
See Feature Toggles for how to compose feature sets.