Skip to content

Commit 95bf36d

Browse files
authored
Merge pull request #4760 from kidroca/kidroca/add-rn-performance-flipper-plugin
Performance tracking with flipper-plugin-performance
2 parents f8ed9b5 + 5201038 commit 95bf36d

File tree

17 files changed

+254
-72
lines changed

17 files changed

+254
-72
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ USE_NGROK=false
1010
USE_WEB_PROXY=false
1111
USE_WDYR=false
1212
CAPTURE_METRICS=false
13+
ONYX_METRICS=false

babel.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require('dotenv').config();
2+
13
const defaultPresets = ['@babel/preset-react', '@babel/preset-env', '@babel/preset-flow'];
24
const defaultPlugins = [
35
// Adding the commonjs: true option to react-native-web plugin can cause styling conflicts
@@ -34,6 +36,27 @@ const metro = {
3436
],
3537
};
3638

39+
/*
40+
* We use Flipper, <React.Profiler> and react-native-performance to capture/monitor stats
41+
* By default <React.Profiler> is disabled in production as it adds small overhead
42+
* When CAPTURE_METRICS is set we're explicitly saying that we want to capture metrics
43+
* To enable the <Profiler> for release builds we add these aliases */
44+
if (process.env.CAPTURE_METRICS) {
45+
const path = require('path');
46+
const profilingRenderer = path.resolve(
47+
__dirname,
48+
'./node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-profiling',
49+
);
50+
51+
metro.plugins.push(['module-resolver', {
52+
root: ['./'],
53+
alias: {
54+
'ReactNativeRenderer-prod': profilingRenderer,
55+
'scheduler/tracing': 'scheduler/tracing-profiling',
56+
},
57+
}]);
58+
}
59+
3760
module.exports = ({caller}) => {
3861
// For `react-native` (iOS/Android) caller will be "metro"
3962
// For `webpack` (Web) caller will be "@babel-loader"

ios/Podfile.lock

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ PODS:
105105
- OpenSSL-Universal (= 1.1.180)
106106
- Flipper-Glog (0.3.6)
107107
- Flipper-PeerTalk (0.0.4)
108+
- flipper-plugin-react-native-performance (0.6.0):
109+
- React
108110
- Flipper-RSocket (1.3.1):
109111
- Flipper-Folly (~> 2.5)
110112
- FlipperKit (0.75.1):
@@ -412,7 +414,7 @@ PODS:
412414
- React-Core
413415
- react-native-document-picker (5.1.0):
414416
- React-Core
415-
- react-native-flipper (0.100.0):
417+
- react-native-flipper (0.103.0):
416418
- React-Core
417419
- react-native-image-picker (4.0.3):
418420
- React-Core
@@ -598,6 +600,7 @@ DEPENDENCIES:
598600
- Flipper-Folly (~> 2.5.3)
599601
- Flipper-Glog (= 0.3.6)
600602
- Flipper-PeerTalk (~> 0.0.4)
603+
- flipper-plugin-react-native-performance (from `../node_modules/flipper-plugin-react-native-performance/ios`)
601604
- Flipper-RSocket (~> 1.3)
602605
- FlipperKit (~> 0.75.1)
603606
- FlipperKit/Core (~> 0.75.1)
@@ -731,6 +734,8 @@ EXTERNAL SOURCES:
731734
:path: "../node_modules/react-native/Libraries/FBLazyVector"
732735
FBReactNativeSpec:
733736
:path: "../node_modules/react-native/React/FBReactNativeSpec"
737+
flipper-plugin-react-native-performance:
738+
:path: "../node_modules/flipper-plugin-react-native-performance/ios"
734739
glog:
735740
:podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec"
736741
onfido-react-native-sdk:
@@ -877,7 +882,7 @@ SPEC CHECKSUMS:
877882
DoubleConversion: cf9b38bf0b2d048436d9a82ad2abe1404f11e7de
878883
EXHaptics: 337c160c148baa6f0e7166249f368965906e346b
879884
FBLazyVector: 7b423f9e248eae65987838148c36eec1dbfe0b53
880-
FBReactNativeSpec: 884d4cc2b011759361797a4035c47e10099393b5
885+
FBReactNativeSpec: d2bbf7ed8374a5ef7e82afdce19c4e50731f1f0e
881886
Firebase: 54cdc8bc9c9b3de54f43dab86e62f5a76b47034f
882887
FirebaseABTesting: 4cb61aeeb50f60680af1c01fff781dfaf9293916
883888
FirebaseAnalytics: 4751d6a49598a2b58da678cc07df696bcd809ab9
@@ -892,6 +897,7 @@ SPEC CHECKSUMS:
892897
Flipper-Folly: 755929a4f851b2fb2c347d533a23f191b008554c
893898
Flipper-Glog: 1dfd6abf1e922806c52ceb8701a3599a79a200a6
894899
Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9
900+
flipper-plugin-react-native-performance: c639bbaf0e0444bab8eeb86dad93651c2e13291e
895901
Flipper-RSocket: 127954abe8b162fcaf68d2134d34dc2bd7076154
896902
FlipperKit: 8a20b5c5fcf9436cac58551dc049867247f64b00
897903
glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62
@@ -923,7 +929,7 @@ SPEC CHECKSUMS:
923929
React-jsinspector: 500a59626037be5b3b3d89c5151bc3baa9abf1a9
924930
react-native-config: d8b45133fd13d4f23bd2064b72f6e2c08b2763ed
925931
react-native-document-picker: 0e3602a4064da040321bafad6848d8b0edcb1d55
926-
react-native-flipper: 1943b82f2e494c77b741eb1ed257b6734a334b83
932+
react-native-flipper: 169e8ba429b73ad637ce007337ce4b415e783799
927933
react-native-image-picker: 4089335b89b625d4e34d53fb249c48a7a791b3ea
928934
react-native-netinfo: 52cf0ee8342548a485e28f4b09e56b477567244d
929935
react-native-pdf: 4b5a9e4465a6a3b399e91dc4838eb44ddf716d1f

package-lock.json

Lines changed: 17 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"react-native-image-picker": "^4.0.3",
8585
"react-native-keyboard-spacer": "^0.4.1",
8686
"react-native-modal": "^11.10.0",
87-
"react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#f3b24dd2c947bb4b9b60dc3718dc170f93f751f0",
87+
"react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#6eadd7f73fca87e6551e43607ec78f645e17ef50",
8888
"react-native-pdf": "^6.2.2",
8989
"react-native-performance": "^2.0.0",
9090
"react-native-permissions": "^3.0.1",
@@ -150,6 +150,7 @@
150150
"eslint-plugin-detox": "^1.0.0",
151151
"eslint-plugin-jest": "^24.1.0",
152152
"flipper-plugin-bridgespy-client": "^0.1.9",
153+
"flipper-plugin-react-native-performance": "^0.6.0",
153154
"html-webpack-plugin": "^4.3.0",
154155
"jest": "^26.5.2",
155156
"jest-circus": "^26.5.2",
@@ -159,7 +160,8 @@
159160
"portfinder": "^1.0.28",
160161
"pusher-js-mock": "^0.3.3",
161162
"react-hot-loader": "^4.12.21",
162-
"react-native-flipper": "^0.100.0",
163+
"react-native-flipper": "^0.103.0",
164+
"react-native-performance-flipper-reporter": "^2.0.0",
163165
"react-native-svg-transformer": "^0.14.3",
164166
"react-test-renderer": "16.13.1",
165167
"rn-async-storage-flipper": "0.0.10",

src/CONFIG.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ export default {
6161
UNREAD: '/favicon-unread.png',
6262
},
6363
CAPTURE_METRICS: lodashGet(Config, 'CAPTURE_METRICS', false),
64+
ONYX_METRICS: lodashGet(Config, 'ONYX_METRICS', false),
6465
};

src/CONST.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/OnyxProvider.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ import ComposeProviders from './ComposeProviders';
77
import CONST from '../CONST';
88
import Log from '../libs/Log';
99
import listenToStorageEvents from '../libs/listenToStorageEvents';
10+
import {canCaptureOnyxMetrics} from '../libs/canCaptureMetrics';
1011

1112
// Initialize the store when the app loads for the first time
1213
Onyx.init({
1314
keys: ONYXKEYS,
1415
safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS],
16+
captureMetrics: canCaptureOnyxMetrics(),
1517
initialKeyStates: {
1618

1719
// Clear any loading and error messages so they do not appear on app startup

0 commit comments

Comments
 (0)