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
MIT License
588 stars 17 forks source link

Wrong Calculation of FPS #88

Open atn4z7 opened 1 year ago

atn4z7 commented 1 year ago

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.

BruceSuperProgramer commented 1 year ago

I notice the same problem

MateoParodi commented 1 year ago

Same problem here