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
- Firebase Performance only tracks Activities, hiding Fragment level bottlenecks
- FrameMetricsAggregator collects frame timing when Fragments are visible, not just created
- BaseFragment pattern with lifecycle aware tracer pinpoints exact slow rendering sources
- Distribution data shows frame counts per millisecond for precise performance analysis
A lifecycle aware BaseFragment with FrameMetricsAggregator gives you per Fragment frame rate metrics that Firebase Performance doesn't provide out of the box.
About This Article
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.
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.
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.