From 2c1da8804575f0e2f0aa268337f4dbe685da09ce Mon Sep 17 00:00:00 2001 From: Peter Velkov Date: Tue, 28 Jun 2022 15:25:46 +0300 Subject: [PATCH 1/5] Create `scripts/source-map.sh` --- scripts/source-map.sh | 69 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 scripts/source-map.sh diff --git a/scripts/source-map.sh b/scripts/source-map.sh new file mode 100755 index 000000000000..f74c71bad468 --- /dev/null +++ b/scripts/source-map.sh @@ -0,0 +1,69 @@ +#!/bin/bash +set -e +# Source map generating script for android and ios js bundles + +PLATFORM=$1 + +if [[ ! $PLATFORM =~ ^(ios|android)$ ]]; then + error "Unsupported platform '$PLATFORM', possible options are: 'android' or 'ios'" + exit 1 +fi + +SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}") +LOCAL_PACKAGES=$(npm bin) +NODE_MODULES="$SCRIPTS_DIR/../node_modules" +source "$SCRIPTS_DIR/shellUtils.sh"; + +echo $NODE_MODULES + +title "Generating $PLATFORM Source Map File" + +info "" +info "1. Generating packager map" +info "" + +$LOCAL_PACKAGES/react-native bundle \ + --platform $PLATFORM \ + --dev false \ + --entry-file index.js \ + --bundle-output index.$PLATFORM.bundle \ + --sourcemap-output index.$PLATFORM.bundle.packager.map \ + --reset-cache \ + --minify false + +OS_BIN="" + +case "$OSTYPE" in + darwin*) OS_BIN=osx-bin ;; + linux*) OS_BIN=linux64-bin ;; + msys*) OS_BIN=win64-bin ;; + cygwin*) OS_BIN=win64-bin ;; + *) error "unknown: $OSTYPE" ;; +esac + +if [ -z "$OS_BIN" ]; then + error "Failed to match hermes OS-BIN" + exit 1; +fi + +info "" +info "2. Generating hermes map" +info "" +info "Using hermes OS-BIN: '$OS_BIN'" +info "" + +# In react native 0.69 this path needs to change to NODE_MODULES/react-native/sdks/hermesc/$OS_BIN/hermesc +$NODE_MODULES/hermes-engine/$OS_BIN/hermesc -O -emit-binary -output-source-map -out=index.$PLATFORM.bundle.hbc index.$PLATFORM.bundle + +info "" +info "3. Merging source maps" +info "" + +node $NODE_MODULES/react-native/scripts/compose-source-maps.js \ + index.$PLATFORM.bundle.packager.map \ + index.$PLATFORM.bundle.hbc.map \ + -o index.$PLATFORM.bundle.map + +success "" +success "Result ready: 'index.$PLATFORM.bundle.map'" +success "" From d1b6fbd1e5771d46096ccee66dc00bb12154f5c3 Mon Sep 17 00:00:00 2001 From: Peter Velkov Date: Tue, 28 Jun 2022 15:27:40 +0300 Subject: [PATCH 2/5] Add source-map and symbolicate scripts --- package.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 577c627353eb..9e86eb9c1beb 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,11 @@ "gh-actions-build": "./.github/scripts/buildActions.sh", "gh-actions-validate": "./.github/scripts/validateActionsAndWorkflows.sh", "analyze-packages": "ANALYZE_BUNDLE=true webpack --config config/webpack/webpack.common.js --env.envFile=.env.production", - "check-metro-bundler-port": "node config/checkMetroBundlerPort.js" + "check-metro-bundler-port": "node config/checkMetroBundlerPort.js", + "source-map:android": "scripts/source-map.sh android", + "source-map:ios": "scripts/source-map.sh ios", + "symbolicate:android": "npx metro-symbolicate index.android.bundle.map", + "symbolicate:ios": "npx metro-symbolicate index.ios.bundle.packager.map" }, "dependencies": { "@formatjs/intl-getcanonicallocales": "^1.5.8", From baee99af4dbb5fc20c3f5576712ba9a7598f2524 Mon Sep 17 00:00:00 2001 From: Peter Velkov Date: Tue, 28 Jun 2022 15:27:53 +0300 Subject: [PATCH 3/5] Add sample stack traces --- stacktrace.android.txt | 29 +++++++++++++++++++++++++++++ stacktrace.ios.txt | 29 +++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 stacktrace.android.txt create mode 100644 stacktrace.ios.txt diff --git a/stacktrace.android.txt b/stacktrace.android.txt new file mode 100644 index 000000000000..8dca2ab5baa7 --- /dev/null +++ b/stacktrace.android.txt @@ -0,0 +1,29 @@ +.shouldComponentUpdate (address at index.android.bundle:1:2387414:) +.checkShouldComponentUpdate (address at index.android.bundle:1:149741:) +.updateClassComponent (address at index.android.bundle:1:162988:) +.beginWork (address at index.android.bundle:1:195306:) +.performUnitOfWork (address at index.android.bundle:1:181912:) +.workLoopSync (address at index.android.bundle:1:181770:) +.renderRootSync (address at index.android.bundle:1:181654:) +.performSyncWorkOnRoot (address at index.android.bundle:1:179024:) +.flushSyncCallbacks (address at index.android.bundle:1:146548:) +.scheduleUpdateOnFiber (address at index.android.bundle:1:176676:) +.enqueueSetState (address at index.android.bundle:1:191295:) +.anonymous (address at index.android.bundle:1:105772:) +.anonymous (address at index.android.bundle:1:816304:) +.each (address at index.android.bundle:1:799401:) +.keyChanged (address at index.android.bundle:1:816124:) +.anonymous (address at index.android.bundle:1:819487:) +.each (address at index.android.bundle:1:799433:) +.anonymous (address at index.android.bundle:1:819463:) +.tryCallOne (/tmp/hermes/staging/hermes/cmake/intlRelease/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:53:16:) +.anonymous (/tmp/hermes/staging/hermes/cmake/intlRelease/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:139:27:) +.anonymous (address at index.android.bundle:1:216954:) +._callTimer (address at index.android.bundle:1:215853:) +._callReactNativeMicrotasksPass (address at index.android.bundle:1:216057:) +.callReactNativeMicrotasks (address at index.android.bundle:1:218050:) +.__callReactNativeMicrotasks (address at index.android.bundle:1:122690:) +.anonymous (address at index.android.bundle:1:121775:) +.__guard (address at index.android.bundle:1:122531:) +.flushedQueue (address at index.android.bundle:1:121686:) +.invokeCallbackAndReturnFlushedQueue (address at index.android.bundle:1:121629:) diff --git a/stacktrace.ios.txt b/stacktrace.ios.txt new file mode 100644 index 000000000000..f90151c909bc --- /dev/null +++ b/stacktrace.ios.txt @@ -0,0 +1,29 @@ +0 ??? 0x0 shouldComponentUpdate + 199284 (main.jsbundle:199284:30) +1 ??? 0x0 checkShouldComponentUpdate + 5581 (main.jsbundle:5581:109) +2 ??? 0x0 updateClassComponent + 6842 (main.jsbundle:6842:382) +3 ??? 0x0 beginWork$1 + 8980 (main.jsbundle:8980:226) +4 ??? 0x0 performUnitOfWork + 8525 (main.jsbundle:8525:27) +5 ??? 0x0 workLoopSync + 8514 (main.jsbundle:8514:24) +6 ??? 0x0 renderRootSync + 8496 (main.jsbundle:8496:21) +7 ??? 0x0 performSyncWorkOnRoot + 8233 (main.jsbundle:8233:36) +8 ??? 0x0 flushSyncCallbacks + 5165 (main.jsbundle:5165:32) +9 ??? 0x0 scheduleUpdateOnFiber + 8047 (main.jsbundle:8047:345) +10 ??? 0x0 enqueueSetState + 5551 (main.jsbundle:5551:38) +11 ??? 0x0 anonymous + 73232 (main.jsbundle:73232:33) +12 ??? 0x0 anonymous + 63722 (main.jsbundle:63722:47) +13 ??? 0x0 each + 61811 (main.jsbundle:61811:19) +14 ??? 0x0 keyChanged + 63704 (main.jsbundle:63704:29) +15 ??? 0x0 anonymous + 63943 (main.jsbundle:63943:19) +16 ??? 0x0 each + 61805 (main.jsbundle:61805:19) +17 ??? 0x0 anonymous + 63942 (main.jsbundle:63942:31) +18 ??? 0x0 tryCallOne + 53 (InternalBytecode.js:53:1) +19 ??? 0x0 anonymous + 139 (InternalBytecode.js:139:27) +21 ??? 0x0 anonymous + 11428 (main.jsbundle:11428:26) +22 ??? 0x0 _callTimer + 11336 (main.jsbundle:11336:17) +23 ??? 0x0 _callReactNativeMicrotasksPass + 11367 (main.jsbundle:11367:17) +24 ??? 0x0 callReactNativeMicrotasks + 11573 (main.jsbundle:11573:44) +25 ??? 0x0 __callReactNativeMicrotasks + 3189 (main.jsbundle:3189:46) +26 ??? 0x0 anonymous + 3064 (main.jsbundle:3064:45) +27 ??? 0x0 __guard + 3172 (main.jsbundle:3172:15) +28 ??? 0x0 flushedQueue + 3063 (main.jsbundle:3063:21) +29 ??? 0x0 invokeCallbackAndReturnFlushedQueue + 3056 (main.jsbundle:3056:33) From f02c26e29099a58615ed5baf9a75f10f266347b4 Mon Sep 17 00:00:00 2001 From: Peter Velkov Date: Tue, 28 Jun 2022 18:34:57 +0300 Subject: [PATCH 4/5] Delete sample stack traces --- stacktrace.android.txt | 29 ----------------------------- stacktrace.ios.txt | 29 ----------------------------- 2 files changed, 58 deletions(-) delete mode 100644 stacktrace.android.txt delete mode 100644 stacktrace.ios.txt diff --git a/stacktrace.android.txt b/stacktrace.android.txt deleted file mode 100644 index 8dca2ab5baa7..000000000000 --- a/stacktrace.android.txt +++ /dev/null @@ -1,29 +0,0 @@ -.shouldComponentUpdate (address at index.android.bundle:1:2387414:) -.checkShouldComponentUpdate (address at index.android.bundle:1:149741:) -.updateClassComponent (address at index.android.bundle:1:162988:) -.beginWork (address at index.android.bundle:1:195306:) -.performUnitOfWork (address at index.android.bundle:1:181912:) -.workLoopSync (address at index.android.bundle:1:181770:) -.renderRootSync (address at index.android.bundle:1:181654:) -.performSyncWorkOnRoot (address at index.android.bundle:1:179024:) -.flushSyncCallbacks (address at index.android.bundle:1:146548:) -.scheduleUpdateOnFiber (address at index.android.bundle:1:176676:) -.enqueueSetState (address at index.android.bundle:1:191295:) -.anonymous (address at index.android.bundle:1:105772:) -.anonymous (address at index.android.bundle:1:816304:) -.each (address at index.android.bundle:1:799401:) -.keyChanged (address at index.android.bundle:1:816124:) -.anonymous (address at index.android.bundle:1:819487:) -.each (address at index.android.bundle:1:799433:) -.anonymous (address at index.android.bundle:1:819463:) -.tryCallOne (/tmp/hermes/staging/hermes/cmake/intlRelease/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:53:16:) -.anonymous (/tmp/hermes/staging/hermes/cmake/intlRelease/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:139:27:) -.anonymous (address at index.android.bundle:1:216954:) -._callTimer (address at index.android.bundle:1:215853:) -._callReactNativeMicrotasksPass (address at index.android.bundle:1:216057:) -.callReactNativeMicrotasks (address at index.android.bundle:1:218050:) -.__callReactNativeMicrotasks (address at index.android.bundle:1:122690:) -.anonymous (address at index.android.bundle:1:121775:) -.__guard (address at index.android.bundle:1:122531:) -.flushedQueue (address at index.android.bundle:1:121686:) -.invokeCallbackAndReturnFlushedQueue (address at index.android.bundle:1:121629:) diff --git a/stacktrace.ios.txt b/stacktrace.ios.txt deleted file mode 100644 index f90151c909bc..000000000000 --- a/stacktrace.ios.txt +++ /dev/null @@ -1,29 +0,0 @@ -0 ??? 0x0 shouldComponentUpdate + 199284 (main.jsbundle:199284:30) -1 ??? 0x0 checkShouldComponentUpdate + 5581 (main.jsbundle:5581:109) -2 ??? 0x0 updateClassComponent + 6842 (main.jsbundle:6842:382) -3 ??? 0x0 beginWork$1 + 8980 (main.jsbundle:8980:226) -4 ??? 0x0 performUnitOfWork + 8525 (main.jsbundle:8525:27) -5 ??? 0x0 workLoopSync + 8514 (main.jsbundle:8514:24) -6 ??? 0x0 renderRootSync + 8496 (main.jsbundle:8496:21) -7 ??? 0x0 performSyncWorkOnRoot + 8233 (main.jsbundle:8233:36) -8 ??? 0x0 flushSyncCallbacks + 5165 (main.jsbundle:5165:32) -9 ??? 0x0 scheduleUpdateOnFiber + 8047 (main.jsbundle:8047:345) -10 ??? 0x0 enqueueSetState + 5551 (main.jsbundle:5551:38) -11 ??? 0x0 anonymous + 73232 (main.jsbundle:73232:33) -12 ??? 0x0 anonymous + 63722 (main.jsbundle:63722:47) -13 ??? 0x0 each + 61811 (main.jsbundle:61811:19) -14 ??? 0x0 keyChanged + 63704 (main.jsbundle:63704:29) -15 ??? 0x0 anonymous + 63943 (main.jsbundle:63943:19) -16 ??? 0x0 each + 61805 (main.jsbundle:61805:19) -17 ??? 0x0 anonymous + 63942 (main.jsbundle:63942:31) -18 ??? 0x0 tryCallOne + 53 (InternalBytecode.js:53:1) -19 ??? 0x0 anonymous + 139 (InternalBytecode.js:139:27) -21 ??? 0x0 anonymous + 11428 (main.jsbundle:11428:26) -22 ??? 0x0 _callTimer + 11336 (main.jsbundle:11336:17) -23 ??? 0x0 _callReactNativeMicrotasksPass + 11367 (main.jsbundle:11367:17) -24 ??? 0x0 callReactNativeMicrotasks + 11573 (main.jsbundle:11573:44) -25 ??? 0x0 __callReactNativeMicrotasks + 3189 (main.jsbundle:3189:46) -26 ??? 0x0 anonymous + 3064 (main.jsbundle:3064:45) -27 ??? 0x0 __guard + 3172 (main.jsbundle:3172:15) -28 ??? 0x0 flushedQueue + 3063 (main.jsbundle:3063:21) -29 ??? 0x0 invokeCallbackAndReturnFlushedQueue + 3056 (main.jsbundle:3056:33) From 28eb9c49b744ec3b5a098df66f7baf5f8aa550f0 Mon Sep 17 00:00:00 2001 From: Peter Velkov Date: Tue, 28 Jun 2022 19:09:05 +0300 Subject: [PATCH 5/5] Cleanup scripts/source-map.sh --- scripts/source-map.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/source-map.sh b/scripts/source-map.sh index f74c71bad468..0d73800ecbe5 100755 --- a/scripts/source-map.sh +++ b/scripts/source-map.sh @@ -14,15 +14,13 @@ LOCAL_PACKAGES=$(npm bin) NODE_MODULES="$SCRIPTS_DIR/../node_modules" source "$SCRIPTS_DIR/shellUtils.sh"; -echo $NODE_MODULES - title "Generating $PLATFORM Source Map File" info "" info "1. Generating packager map" info "" -$LOCAL_PACKAGES/react-native bundle \ +"$LOCAL_PACKAGES/react-native" bundle \ --platform $PLATFORM \ --dev false \ --entry-file index.js \ @@ -53,13 +51,13 @@ info "Using hermes OS-BIN: '$OS_BIN'" info "" # In react native 0.69 this path needs to change to NODE_MODULES/react-native/sdks/hermesc/$OS_BIN/hermesc -$NODE_MODULES/hermes-engine/$OS_BIN/hermesc -O -emit-binary -output-source-map -out=index.$PLATFORM.bundle.hbc index.$PLATFORM.bundle +"$NODE_MODULES/hermes-engine/$OS_BIN/hermesc" -O -emit-binary -output-source-map -out=index.$PLATFORM.bundle.hbc index.$PLATFORM.bundle info "" info "3. Merging source maps" info "" -node $NODE_MODULES/react-native/scripts/compose-source-maps.js \ +node "$NODE_MODULES/react-native/scripts/compose-source-maps.js" \ index.$PLATFORM.bundle.packager.map \ index.$PLATFORM.bundle.hbc.map \ -o index.$PLATFORM.bundle.map