firebase-android-sdk icon indicating copy to clipboard operation
firebase-android-sdk copied to clipboard

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

Open polivmi1 opened this issue 2 years ago • 5 comments

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.

polivmi1 avatar Nov 07 '23 17:11 polivmi1

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

google-oss-bot avatar Nov 07 '23 17:11 google-oss-bot

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.

argzdev avatar Nov 07 '23 17:11 argzdev

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

mlykotom avatar Apr 11 '24 14:04 mlykotom

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.

sindrenm avatar May 13 '24 21:05 sindrenm