I am trying to do Screen Rendering in Firebase. I can see only Main Activity in Firebase Screen Rendering but not able to see Jetpack Compose Screens. Is there any way to show the JetPack Compose screens? It should reflect in Firebase Screen Rendering Section.
In Jetpack compose is there any way to show the Screen Rendering in Firebase Performance Tab. Only its supporting Activity and Fragment how I can do for the Jetpack Compose.
here I added what the Documents says :
How are screen rendering traces generated?
Each screen rendering trace is identified by the name of the view element in your application. The Performance Monitoring client creates screen rendering traces for every Activity or Fragment used by your application.
Each screen rendering trace performs the following actions:
Starts for every activity and fragment class when the object becomes visible on the screen. OnActivityStarted() for activities and OnFragmentResume() for fragments.
Stops for every activity and fragment class when the object is not visible on the screen. OnActivityStopped() for activities and OnFragmentPaused() for fragments.
how it will done in Jetpack Compose.
You can launch the screen tracing as a DisposableEffect
@Composable
fun LaunchTracing(route: String) {
val activity = LocalContext.current as Activity
DisposableEffect(key1 = route) {
val trace = Trace.create(Constants.SCREEN_TRACE_PREFIX + route).apply { start() }
val recorder = FrameMetricsRecorder(activity).apply { start() }
onDispose {
val metrics = recorder.stop()
if (metrics.isAvailable)
ScreenTraceUtil.addFrameCounters(trace, metrics.get())
else
Log.e("TRACING", "Unable to record trace for '$route'")
trace.stop()
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With