https://kotlinlang.org logo
#compose
Title
# compose
k

Karthi

04/08/2022, 1:14 AM
Hi, I am looking for way to add screen trace log for firebase performance metric to compose screens (similar to slow rendering/frozen frames metric of activity and fragment). Any idea where we should start and stop the trace?
m

MR3Y

04/08/2022, 1:32 AM
Not sure if it is the best way but you can start the trace on every successful composition:
Copy code
@Composable
inline fun TraceCompositions() {
        SideEffect { Trace.beginSection() }
}
And stop the trace within a DisposableEffect, something like:
Copy code
@Composable
inline fun TraceCompositions() {
        SideEffect { Trace.beginSection() }
 DisposableEffect() {

        onDispose {
        Trace.endSection()
        }
    }
}
9 Views