How to use Android dumpsys framestats

1.4k views Asked by At

I want to measure the FPS of my Android Augmented Reality app. I am trying to follow the documentation for using dumpsys framestats.

This is my procedure:

  1. connect device (Galaxy Tab S5e) via USB to computer (MacBook Pro)
  2. Launch application
  3. Open terminal and enter adb shell dumpsys gfxinfo <PACKAGE_NAME> framestats

I get results. The documentation says that I should get some CSV data (which I do). Here it is:

Flags,IntendedVsync,Vsync,OldestInputEvent,NewestInputEvent,HandleInputStart,AnimationStart,PerformTraversalsStart,DrawStart,SyncQueued,SyncStart,IssueDrawCommandsStart,SwapBuffers,FrameCompleted,DequeueBufferDuration,QueueBufferDuration,
1,270900288236110,270901404902732,9223372036854775807,0,270901406732543,270901407052751,270901407062751,270901480932022,270901488003689,270901488511137,270901489180876,270901502575459,270901504554157,1520000,1026000,
1,270901416955482,270901500288812,9223372036854775807,0,270901507061241,270901507131709,270901507732074,270901524054574,270901524125251,270901524430720,270901524804834,270901531068480,270901534144522,3249000,1831000,

Firstly, why is there only two rows, if:

"Each line of this output represents a frame produced by the app"

If I wait and then rerun the command, I again only get 2 rows. Sometimes the values have updated, but other times they have not...

The documentation says that I can calculate frame time with:

(FRAME_COMPLETED - INTENDED_VSYNC)

So, I thought I could run the ADB command after say, 1 minute, get out a load of frame times and then graph it, but if I only get out 2 frames at a time... and if rerunning the ADB command does not update the data... how can I measure Frametimes? What am I missing here?

2

There are 2 answers

0
Kevin Ding On

Take launching application from launcher for example.

1, animation by launcher ( push button down, and up)

2, starting window animation by system server ( starting a new window, and zoom from icon to fullscreen)

3, animation which swtiches from starting window to real first frame provided by applicatoin(fade old frame out and new frame in)

dumpsys framestats of your applicatoin only include the frames produced by your application (real first frame and so on), not include animation framestats in step 1, 2, 3.

according to your framestats, your applicatoin may have two activiy, one for splashscreen, one for real first page.

because the flags in your framestats are 1.

what does flag mean?

enum {
    // 1 for the first frame following activityOnResume event
    // usually load layout xml, measure, layout and draw
    // it will take very long time, maybe 500ms+ depending on the complexity of your layout
    // user won't feel jank, because there is a starting window, when your frame ready, this will fade in
    WindowVisibilityChanged = 1 << 0, 

    // animation in render thread
    // some animation don't need run choreograher#doFrame
    // directly change the propertiy of display list on the renderthread and redraw
    RTAnimation = 1 << 1,

    // I don't know what this is 
    SurfaceCanvas = 1 << 2,

    // I don't know what this is 
    SkippedFrame = 1 << 3,
};
0
Lynn On

I am writing my bachelor thesis and using this adb command to get framerate. In my experience, the framerate data is updated only when the screen is changed. For example, you have a long list. If you don't scroll it, you only see limited framerate data, but if you scroll it, there will be more framerate data (but the maximum number of frames is 122 )