firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.26k stars 572 forks source link

Performance screen rendering is supported only for activities and fragments - compose support #5522

Open polivmi1 opened 10 months ago

polivmi1 commented 10 months ago

What feature would you like to see?

Many developers have moved from activities and fragments to compose. Compose usually has 1 activity, no fragments and internal navigation using composables. It would be great if we could track Composables (screens) performance and slow + frozen frames.

Something like this isn't working and won't show in the Screen rendering dashboard (it will send the trace and create a link, but it will be empty)

@Composable
fun LaunchTracing(route: String) {
    val activity = LocalContext.current as Activity
    DisposableEffect(key1 = route) {
        val trace = Firebase.performance.newTrace(route).apply { start() }
        val recorder = FrameMetricsRecorder(activity).apply { start() }
        onDispose {
            val metrics = recorder.stop()
            if (metrics.isAvailable)
                ScreenTraceUtil.addFrameCounters(trace, metrics.get())
            trace.stop()
        }
    }
}

How would you use it?

We would be able to monitor performance on separate screens/components.

google-oss-bot commented 10 months ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

argzdev commented 10 months ago

Hi @polivmi1, thanks for reaching out. Yes this is a very reasonable request, we'll be sure to include that in the roadmap in the future. That said, we are unable to promise any timeline yet for this, if others find this useful, adding a thumbs up on this feature can help our engineers prioritize adding this to the roadmap.

mlykotom commented 5 months ago

This should actually work if you prefix your route with Constants.SCREEN_TRACE_PREFIX

sindrenm commented 4 months ago

Is this roadmap you mention publicly available anywhere, @argzdev? I'm thinking something akin to the Compose team's roadmap over at https://developer.android.com/jetpack/androidx/compose-roadmap.