FrameMetrics — realtime app smoothness tracking

Mirek Stanek
Nov 20, 2016 · 3 min read

This post was originally written on my dev-blog:

A couple months ago, when Android Nougat was announced, among new features like Multi-window, enhanced notifications, VR support, 72 new emojis 👍 and others, there was a new addition to monitoring tools: Frame Metrics API.

On older Android versions when we would like to see graphic performance metrics we had to get them via adb shell, by calling:

$ adb shell dumpsys gfxinfo com.frogermcs.framemetrics

As a result we get:

These statistics are generated for last 120 frames for given application package (hint: this is not always last 2 seconds - frames are drawn only when Android is requested to do this e.g. when layout is changed or animated).

While this data can give us a lot of information about UI performance, accessing it from console isn’t the most convenient way, especially when we would like to use it during automatic app testing. Of course it isn’t impossible, and great example how it can be done is described in Automated Performance Testing Codelab (it’s implemented as a MonkeyRunner script).


FrameMetrics API documentation is pretty clear about what can be measured (chronologic order):

Metrics names are mostly self explaining but if this list looks not complete to you, take a look at FrameMetrics sources to see how each metric is calculated:

There are also great videos where Colt McAnlis explains among the others what VSYNC is or how layout is transformed to GPU commands (FrameMetrics.COMMAND_ISSUE_DURATION). So they also can shed some light on FrameMetrics fields:


Installation is pretty simple — you can copy class to your project or use gradle dependency:

To use it, just register ActivityFrameMetrics as an ActivityLifecycleCallback in your Application class:

By default library prints Logcat warning for every frame which rendering took more than 17ms, and error for more than 34ms.

Default values can be changed with ActivityFrameMetrics.Builder params:

Repo for ActivityFrameMetrics library can be found on Github.

Digging deeper into FrameMetrics

First of all FrameMetrics is just a simple data container written in java but nothing really is measured in it. Instead this data comes as a notification from C++ code which is responsible for view rendering. Good starting point could be ThreadedRenderer class which proxies rendering to render thread.
If you explore C++ code a bit more, at the end probably you’ll find JankTracker class which is responsible for filling up FrameMetrics data (and you will realise that this is exactly the same data which is presented in dumpsys gfxinfo) and FrameInfo class which is C++ data container which is in sync with

What else you can find there is only up to you. Just never stop searching and always be curious.

Thanks for reading!

Mirek Stanek

Written by

Tech Lead at @Azimo. I dream big 🌌 🔭 and build technology for people 💻 💚 👫. #Mobile #AI. More blog posts on