sentry-react-native icon indicating copy to clipboard operation
sentry-react-native copied to clipboard

Use RN performance API (JS bundle start time)

Open krystofwoldrich opened this issue 2 years ago • 3 comments

Description

Starting RN 0.72 there is a new Performance API that measures app start time and also measures the js bundle start time.

### Todo:
- [ ] Compare start time to our measurements
- [ ] Use RN measurements when available
- [ ] Add JSBundle Execution span

krystofwoldrich avatar Mar 22 '23 11:03 krystofwoldrich

We can consider replacing our approach with this API when its available at runtime, for back compatibility, we can use ours instead. The API gives more insights as its able to measure the bundle loading.

marandaneto avatar Mar 24 '23 13:03 marandaneto

Tested with 0.72.4 and only got zeros. Will have to investigate why before implementing.

{"_endTime": 0, "_executeJavaScriptBundleEntryPointEnd": 0, "_executeJavaScriptBundleEntryPointStart": 0, "_startTime": 0}

RN Team added more measurements since the initial issue. https://github.com/facebook/react-native/pull/38858/files#diff-af2cc8e2446df8183ad3ec780c463f6b7d9e39f45c86721dfd532c8a373c1d01

krystofwoldrich avatar Sep 26 '23 15:09 krystofwoldrich

We can extract RN performance metrics on the native layers.

Example from iOS: https://github.com/facebook/react-native/blob/d09c02f9e2d468e4d0bde51890e312ae7003a3e6/packages/react-native/React/Base/RCTBridge.mm#L353-L356

Useful metric: ReactInstanceInit time, BridgeStart time, BundleLoad time -> https://github.com/facebook/react-native/blob/d09c02f9e2d468e4d0bde51890e312ae7003a3e6/packages/react-native/React/Base/RCTPLTag.h#L8-L31

krystofwoldrich avatar Jan 23 '24 16:01 krystofwoldrich