RecompositionTracer


Collects recomposition flow events.

Tracks the causal flow between state reads/writes and recomposition of RecomposeScopes by connecting to recomposition lifecycle and Snapshot state events.

The traces are recorded in the Perfetto trace format through a provided TraceCollector.

NOTE: Recomposition tracing captures a stack trace and instance string on all state reads and writes, which results a significant overhead. Avoid using it in production.

Summary

Nested types

Records recomposition flow events.

Public constructors

android

Public functions

CancellationHandle
installTracing(coroutineContext: CoroutineContext)

Installs recomposition tracing.

android

Public constructors

RecompositionTracer

RecompositionTracer(traceCollector: RecompositionTracer.TraceCollector)
Parameters
traceCollector: RecompositionTracer.TraceCollector

receives recomposition trace events

Public functions

installTracing

fun installTracing(coroutineContext: CoroutineContext): CancellationHandle

Installs recomposition tracing.

Registers observers and starts recording events using the caller's coroutine context. The method returns after the recomposer observer is installed.

Parameters
coroutineContext: CoroutineContext

context to run the observer in

Returns
CancellationHandle

a CancellationHandle to stop tracing and dispose of registered observers