bamlab / react-native-flipper-performance-monitor

An attempt to have a lighthouse for React Native. Flipper plugin to show a graph of the React Native performance monitor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong Calculation of FPS

atn4z7 opened this issue · comments

Hi guys, thank you so much for this awesome tool. We are using it to measure perf of our mobile app. After a few days of using it on iOS, we realize there is a bug with how the FPS is calculated. Basically, we see the FPS drop to 0 a lot of times while the FPS from React Native pert chart (dev mode) never does. Another thing is that the FPS numbers almost never match the ones from React Native perf chart. From my investigation, it looks like there are 2 things that cause this incorrect calculation of FPS:

1/ React Native pert chart calculates FPS every second while your tool does it every 0.5 second
2/ The error margin 50 ms is not long enough. From my observation, it can go up to 100 ms - 400 ms. Whenever this happens, the FPS will drop to 0.

To work around this issue, we are currently doing this:

flipper-desktop/src/PerfMonitorView.tsx
adjust MEASURE_INTERVAL from 500 to 1000

flipper-desktop/src/utils/getThreadMeasures.ts
adjust INTERVAL from 500 to 1000
adjust ERROR_MARGIN from 50 to 500

flipper-native/ios/FlipperPerformancePlugin.m
adjust else if (frameTimestamp - [frameCountHolder previousTime] >= 1)

With these changes, we are now seeing correct FPS metrics. What are your thoughts? Is this even a correct solution?

Updates: I can confirm this is also an issue on Android.

I notice the same problem

Same problem here