Grindr Wesley Ong Apr 19, 2020

Measuring Frame Rate Performance Per Fragment in Android

Article Summary

Wesley Ong from Grindr Engineering tackles a blind spot in Android performance monitoring: Firebase tracks frame rates per Activity, but what about the Fragments inside them?

When your HomeActivity shows 50% slow rendering but contains multiple Fragments in a TabLayout, you're stuck guessing which Fragment is the culprit. Ong built a solution using FrameMetricsAggregator to track frame rate performance at the Fragment level, giving teams the granular data they need to fix UI jank.

Key Takeaways

Critical Insight

A lifecycle aware BaseFragment with FrameMetricsAggregator gives you per Fragment frame rate metrics that Firebase Performance doesn't provide out of the box.

The article includes a complete GitHub implementation with an interesting approach to handling Fragment visibility changes that most developers miss.

About This Article

Problem

Firebase Performance Monitoring only tracks frame rates at the Activity level. When an Activity shows 50% slow rendering, developers can't tell which Fragment in a TabLayout is actually causing the problem.

Solution

Wesley Ong built a FragmentFramerateTracer using FrameMetricsAggregator. It collects data when Fragments become VISIBLE and stops when they turn INVISIBLE. The sparse array distribution data tracks frame counts for each millisecond duration.

Impact

Teams at Grindr Engineering can now see frame rates for individual Fragments through logcat output. Instead of guessing which Fragment is causing rendering slowdowns in a shared Activity, they can pinpoint the exact bottleneck.