Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native "dropped so far" perf monitor count constantly increases

I originally noticed this issue in my completed app, but have installed the default react-native app to test, and I'm seeing the "dropped so far" number in the perf monitor constantly creep up even though nothing is happening.

Is this number supposed to increase constantly?

dropped so far

like image 954
Dave Irvine Avatar asked Sep 12 '17 09:09

Dave Irvine


Video Answer


2 Answers

Yes, though it's not always constant.

(I'm making the assumption that you mean constant as in the same value, although if you just mean it as it never stops, then you can ignore the extra extra explanation behind how it works.)

To understand the logic of dropped so far, you can look at the React Native codebase. You will find the code for the perf monitor in the FpsView.java file. In it, you can see what variable (droppedUIFrames) is being used for the dropped so far code (line 67). If you follow this all the way back, you get to the FPSMonitorRunnable class which uses the mTotalFramesDropped variable to keep track of frames dropped so far (line 79). In this class, you just have a loop updating the variables being reported. The line you'll be interested in is this one on line 90:

mTotalFramesDropped += mFrameCallback.getExpectedNumFrames() - mFrameCallback.getNumFrames();

From this, you can see that yes, this value is a counter that simply increases but never gets reset while the perf monitor is running. You can also see that it isn't constant (fixed value); in your case, it probably happens to appear constant because you are on the "hello world" screen where nothing interesting is happening.

like image 99
Michael Cheng Avatar answered Oct 18 '22 21:10

Michael Cheng


So based on Michael Cheng's answer I delved into the RN code a bit more, and dug out EXPECTED_FRAME_TIME which is set to 16.9, a-la the classic 60fps magic number.

The reason the dropped frames counter was constantly (i.e continually) increasing was that RN expects to run at 60fps and thinks any framerate less than this means dropped frames.

however, having tested this particular tablet with various "framerate" testing apps, the tablet's native framerate appears to be 51.9fps. I don't know why that is, it seems a particularly arbitrary number, but in all my testing the framerate never went above 52 and mostly hovered at 51.

So to answer my question, "dropped so far" means how many frames have been less than 60fps, and "should it increase continually?"; yes if the device is only capable of drawing less than 60fps anyway.

like image 29
Dave Irvine Avatar answered Oct 18 '22 20:10

Dave Irvine