WormaCeptor

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.

src/debug/kotlin/.../TrackRecompositionDebug.kt
import com.azikar24.wormaceptor.core.ui.trackRecomposition as wormaTrackRecomposition

fun Modifier.trackRecomposition(name: String): Modifier =
    this.wormaTrackRecomposition(name)
src/release/kotlin/.../TrackRecompositionRelease.kt
fun Modifier.trackRecomposition(name: String): Modifier = this

Now 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

MemberReturnsDescription
Modifier.trackRecomposition(name)ModifierRecords a recomposition event each time the host composable recomposes.
RecompositionTracker.record(name)UnitManually records a recomposition. Usually invoked by the modifier.
RecompositionTracker.getAll()Map<String, RecompositionData>Snapshot of every tracked composable.
RecompositionTracker.getRate(name)FloatRecompositions per second for name over the session.
RecompositionTracker.getTopRecomposers(limit)List<RecompositionData>The hottest recomposers, sorted by rate.
RecompositionTracker.getSessionDuration()LongMillis since the first recorded event, or 0 before any.
RecompositionTracker.getTotalRecompositions()LongSum of recomposition counts across every tracked composable.
RecompositionTracker.reset()UnitClears 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.

On this page