Search code examples
javaandroidaugmented-realityframe-ratearcore

How to measure the frame rate of an ARCore Android app?


I am using the HelloAR sample application. The sample uses ARCore. I am running the sample on an Android Samsung Galaxy Tab S5e.

How can I measure the framerate (Frames Per Second) of my AR app? I need to graph the data, so ideally the output of whatever approach I take will give me some sort of CSV e.g. time,fps

I've tried looking at GameBench, but that requires me to fill out a form and wait for a "specialist" to get back to me... I have also tried dumpsys with framestats, but that only outputs 2 frames and very seldom updates. I have also tried some projects from GitHub (TinyDancer), but that does not work.

Any ideas?


Solution

  • For measuring frame rate in ARCore 1.19 you can use getTimestamp() public method of a public class Frame. At 60 fps, every frame lasts approximately 16.67 ms (or ~16670000 ns).

    public long getTimestamp()
    

    Let's see what official documentation says:

    getTimestamp() method returns the timestamp in nanoseconds when this image was captured. This can be used to detect dropped frames or measure the camera frame rate. The time base of this value is specifically not defined, but it is likely similar to System.nanoTime().

    So, if a time difference between each current and previous frame is ~16670000 nanosec, frame rate is 60 fps. But if a time difference is ~33330000 nanosec, then frame rate is 30 fps.