Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] Performance tracking with flipper-plugin-performance #4760

Merged

Conversation

kidroca
Copy link
Contributor

@kidroca kidroca commented Aug 19, 2021

cc @marcaaron

Details

Adds the Flipper side of react-native-performance where we can see a timeline of our performance updates
image

In order to see some data on the timeline I've integrated the <Performance> component similar to how
it's used on the example project here: https://github.com/oblador/react-native-performance/blob/ccfe4557350a0ef206268e9a50317d9cc2480464/examples/vanilla/App.tsx#L28

Related Issues

$ #4656
$ #4549
$ Expensify/react-native-onyx#101 (package hash should be updated after the onyx PR is merged)

Tests

  1. Update local .env configuration and set CAPTURE_METRICS to true
  2. Reset the metro cache since there's a babel config change npm start -- --reset-cache
  3. Build a debug build with bundled JS (optional) - see how here: [Performance] Improve Android Cold Boot TTI (Time To Interactive) #4656 (comment)
  4. Launch Flipper (desktop app) and install the "Performance" plugin. Search for flipper-plugin-performance
  5. Start the App (kill the metro server if you opted to use the bundled JS bytecode)
  6. Observe data on the Performance timeline in Flipper

QA Steps

N/A

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

image

Mobile Web

image

Desktop

image

iOS

image

Android

image

Onyx captures a lot of measures. We can inspect those on the Flipper Timeline
Update the metro configuration so that when `CAPTURE_METRICS` is `true`
we pass aliases to allow capturing data with the Profiler component
Otherwise React would just skip capturing metrics in release
Copy link
Contributor Author

@kidroca kidroca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some notes on the changes

babel.config.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/libs/Performance.js Show resolved Hide resolved
src/libs/Performance.js Outdated Show resolved Hide resolved
src/libs/actions/App.js Outdated Show resolved Hide resolved
src/pages/home/report/ReportActionsView.js Outdated Show resolved Hide resolved
@kidroca

This comment has been minimized.

@kidroca
Copy link
Contributor Author

kidroca commented Aug 19, 2021

Onyx metrics add a lot of bars to the timeline this might be distracting, we might update the CAPTURE_METRICS variable to be something like

  • all -> capture and show all metrics on the timeline
  • onyx -> show only Onyx metrics
  • app -> show only app metrics
  • app,onyx:get,onyx:set,onyx:mergeCollection -> app and selected Onyx methods
  • false -> no metrics capturing and reporting

@kidroca kidroca changed the title [HOLD] Kidroca/add rn performance flipper plugin Performance tracking with flipper-plugin-performance Aug 20, 2021
@kidroca kidroca changed the title Performance tracking with flipper-plugin-performance [HOLD] Performance tracking with flipper-plugin-performance Aug 20, 2021
@kidroca kidroca marked this pull request as ready for review August 20, 2021 08:11
@kidroca kidroca requested a review from a team as a code owner August 20, 2021 08:11
@MelvinBot MelvinBot requested review from Luke9389 and removed request for a team August 20, 2021 08:11
@kidroca
Copy link
Contributor Author

kidroca commented Aug 20, 2021

Ready for review

Tested on all platforms

  1. Perf metrics are only captured on iOS and Android
  2. Verified the rest of the platform are unaffected by the changes

Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great changes! PR is really awesome! Just had some comments/questions...

babel.config.js Outdated Show resolved Hide resolved
src/components/OnyxProvider.js Outdated Show resolved Hide resolved
src/libs/Performance.js Show resolved Hide resolved
src/libs/Performance.js Show resolved Hide resolved
src/libs/actions/App.js Outdated Show resolved Hide resolved
src/libs/actions/App.js Outdated Show resolved Hide resolved
src/pages/home/report/ReportActionsView.js Outdated Show resolved Hide resolved
src/pages/home/report/ReportActionsView.js Outdated Show resolved Hide resolved
src/pages/home/sidebar/SidebarLinks.js Outdated Show resolved Hide resolved
Copy link
Contributor Author

@kidroca kidroca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replied to the questions
Would push updates on Monday

src/components/OnyxProvider.js Outdated Show resolved Hide resolved
src/libs/Performance.js Show resolved Hide resolved
src/libs/Performance.js Show resolved Hide resolved
src/libs/actions/App.js Outdated Show resolved Hide resolved
src/libs/actions/App.js Outdated Show resolved Hide resolved
src/pages/home/report/ReportActionsView.js Outdated Show resolved Hide resolved
@kidroca kidroca force-pushed the kidroca/add-rn-performance-flipper-plugin branch from 7c0282e to 9ea80ba Compare August 23, 2021 16:45
@kidroca kidroca requested a review from marcaaron August 23, 2021 16:50
@kidroca
Copy link
Contributor Author

kidroca commented Aug 23, 2021

Addressed requested changes. Ready for review

marcaaron
marcaaron previously approved these changes Aug 23, 2021
Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @Luke9389 do you want to take a look at this?

@marcaaron
Copy link
Contributor

react-native-onyx PR merged - Expensify/react-native-onyx@6eadd7f

@kidroca kidroca changed the title [HOLD] Performance tracking with flipper-plugin-performance Performance tracking with flipper-plugin-performance Aug 23, 2021
@kidroca
Copy link
Contributor Author

kidroca commented Aug 23, 2021

Onyx hash updated.
Removed [Hold]
Should this be flagged as [No QA]?

@Luke9389
Copy link
Contributor

Hey, sorry. Getting caught up here.

@Luke9389
Copy link
Contributor

This is an awesome PR @kidroca

Yea, we can flag this as [No QA] I think.
I'm gonna run through the tests you gave and report back.

@Luke9389
Copy link
Contributor

Luke9389 commented Aug 24, 2021

@kidroca are you using flipper with the non-mobile platforms as well?

It worked for me on your branch with iPhone, but I didn't get any devices recognized on Flipper for web.

Here are my iPhone results
Screen Shot 2021-08-23 at 5 36 17 PM

Copy link
Contributor

@Luke9389 Luke9389 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read through the review iterations to get familiar with some of these changes. Tested on my end and looks good.

@marcaaron
Copy link
Contributor

Thanks @Luke9389 Flipper is for native platforms only :) can use Chrome Dev Tools for testing the website - just without as much fanciness. Some things are easier - other things less so.

@marcaaron marcaaron merged commit 95bf36d into Expensify:main Aug 24, 2021
@marcaaron marcaaron changed the title Performance tracking with flipper-plugin-performance [No QA] Performance tracking with flipper-plugin-performance Aug 24, 2021
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@dklymenk
Copy link
Contributor

Hi, I'm sorry to intervene, but I have an issue with web version not building:

ERROR in ./node_modules/react-native-flipper/index.js 35:11
Module parse failed: Unexpected token (35:11)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
See https://webpack.js.org/concepts#loaders
|
| class Connection {
>   connected;
|   pluginId;
|
 @ ./node_modules/react-native-performance-flipper-reporter/src/index.js 1:0-49 90:2-11
 @ ./src/libs/Performance.js
 @ ./src/libs/actions/App.js
 @ ./src/libs/Navigation/NavigationRoot.js
 @ ./src/Expensify.js
 @ ./src/App.js
 @ ./index.js

I made sure my packages are up to date and I haven't done any changes to my .env or anything. Commenting out these 2 lines fixes the problem. I am not exactly sure if this is a missing package issue or that code is not meant to be run on web at all.

Anyway, I am up-to-date on main and last commit at the time of posting is 8a5cf2d.

Thanks.

@kidroca
Copy link
Contributor Author

kidroca commented Aug 24, 2021

I made sure my packages are up to date

So you've installed the new packages with npm install when you pulled main ?
That should have been enough
You can also try running npm ci this would remove node_modules and install the exact dependencies from the -lock file

The code is not supposed to run on web, but the bundler analyzes all require calls as it can't tell if the code would not be used from conditions like if (canCapturePerformanceMetrics())
If you have all packages installed it shouldn't be a problem

Hi, I'm sorry to intervene, but I have an issue with web version not building:
ERROR in ./node_modules/react-native-flipper/index.js 35:11
Module parse failed: Unexpected token (35:11)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
See https://webpack.js.org/concepts#loaders
|
| class Connection {
>   connected;
|   pluginId;
|
 @ ./node_modules/react-native-performance-flipper-reporter/src/index.js 1:0-49 90:2-11
 @ ./src/libs/Performance.js
 @ ./src/libs/actions/App.js
 @ ./src/libs/Navigation/NavigationRoot.js
 @ ./src/Expensify.js
 @ ./src/App.js
 @ ./index.js

I made sure my packages are up to date and I haven't done any changes to my .env or anything. Commenting out these 2 lines fixes the problem. I am not exactly sure if this is a missing package issue or that code is not meant to be run on web at all.

Anyway, I am up-to-date on main and last commit at the time of posting is 8a5cf2d.

Thanks.

@kidroca
Copy link
Contributor Author

kidroca commented Aug 24, 2021

I did another go on mac with npm ci and I get the error as well
Besides the error getting printed on the console everything seems to work while developing (npm run web, npm run desktop)
But then I tried to make a prod bundle with npm run build and the build failed with the same error

The issue is related to this

The code is not supposed to run on web, but the bundler analyzes all require calls as it can't tell if the code would not be used from conditions like if (canCapturePerformanceMetrics())

Because of the above, webpack would follow imports to node_modules/react-native-flipper and fail to parse the file as we exclude most files from node_modules

Adding react-native-flipper here fixes the issue:

const includeModules = [
'react-native-animatable',
'react-native-reanimated',
'react-native-picker-select',
'react-native-web',
'@react-native-picker',
'react-native-modal',
'react-native-onyx',
'react-native-gesture-handler',
].join('|');

This would mean that some unused code gets bundled into the end bundle:
image
image

It doesn't add much, but still I think the right thing to do is not to include unused modules

kidroca added a commit to kidroca/Expensify.cash that referenced this pull request Aug 24, 2021
This prevents an error related to bundling: Expensify#4760 (comment)
marcaaron added a commit that referenced this pull request Aug 24, 2021
…per-plugin

[No QA] Fix regression on web due to #4760
@OSBotify
Copy link
Contributor

🚀 Deployed to production by @roryabraham in version: 1.0.88-2 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

@botify
Copy link

botify commented Sep 1, 2021

This has been deployed to production and is now subject to a 7-day regression period.
If no regressions arise, payment will be issued on 2021-09-08. 🎊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants