You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are starting to automatically create GitHub issues from mobile crash reports produced by Firebase Crashlytics for the staging and production mobile apps. These crash reports include stacktraces that are difficult or impossible to follow, because they reference lines in a bundled application, not lines in the source code.
Solution
Generate and include source maps for the staging apps so that stacktraces can reference lines in source code rather than lines from a massive minified bundle. Investigate the drawbacks of including these source maps in the staging app, and consider whether we could also include them in the production app.
Full-transparency: I really don't know much about the topic of source maps, how they work, or their benefits and drawbacks. But I believe having better stacktraces in crash reports would help us to more quickly and successfully trace and fix crashes.
Source maps for iOS/Android should already be generated, the problem is even with source maps Firebase does not accept uploading a source map file, though stack traces can be decoded manually: invertase/react-native-firebase#2327 (comment)
So instead of trying to make Firebase work with source maps (show mapped sources) we can decode the stack trace and create a github issue mapped to original source
As mentioned they should already be generated, but since creating an issue will happen in a different context it should
When an error happens - extract error, stack trace and app version
Use app version so that we can map to the given version source
Update release scripts so they capture source-maps as artifacts. E.g. capture v1.1.77-0.ios/android/web.source.js.map in job artifacts to allow a future pipeline to use them
Alternatively the job should checkout the repository at the given version and generate source maps each time
To generate source maps for iOS/Android we can run the following commands:
to convert it to original source that we can use to create the Github issue
I think Firebase does not support js source maps (in iOS/Android), because in the Firebase Console we have Web/iOS/Android apps and each source is mapped to the underlying architecture, so iOS sources are mapped to iOS code (which is mapped at compile time) and the service knows how to decode that, while with js sources it would be up to react-native-firebase to remap js stack traces before posting crashlytics to Firebase and I guess that's an extra step they don't want to do for various reasons (just my thoughts though, not a fact)
andrew ➜ (main) App cat encodedStackTrace.txt
anonymous (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:2527:489:2527)
onPress (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:2525:1587:2525)
onPress (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:2630:2354:2630)
value (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:2375:2034:2375)
onPress (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:1590:1947:1590)
value (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:197:8496:197)
value (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:197:7752:197)
onResponderRelease (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:197:5671:197)
apply
o (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:51:151:51)
apply
h (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:51:294:51)
apply
g (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:51:348:51)
S (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:51:659:51)
Ne (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:51:14312:51)
forEach
Y (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:51:5326:51)
anonymous (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:51:14660:51)
Pe (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:51:99214:51)
Ce (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:51:14122:51)
Le (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:51:14499:51)
receiveTouches (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:51:15298:51)
apply
value (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:42:3798:42)
anonymous (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:42:674:42)
value (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:42:2504:42)
value (/private/var/containers/Bundle/Application/0B131D53-17FA-4EAC-8C71-F9B65A5D0029/New Expensify.app/main.jsbundle:42:646:42)
I get this as an output
andrew ➜ (main) App npm run symbolicate:ios encodedStackTrace.txt
> new.expensify@1.2.26-0 symbolicate:ios
> npx metro-symbolicate main.jsbundle.map "encodedStackTrace.txt"
null:null:null
Any ideas? I think I remember we might need to do something to the stacktrace before running it through metro-symbolicate?
End of week update: We need to install NodeJS on the web servers, so this is turning into slightly a larger project. Working on doing so now and then will circle back to the specific API layer code once that's done. Otherwise this is working in local testing.
Activity
roryabraham commentedon Jun 2, 2022
cc @AndrewGable
roryabraham commentedon Jun 2, 2022
Full-transparency: I really don't know much about the topic of source maps, how they work, or their benefits and drawbacks. But I believe having better stacktraces in crash reports would help us to more quickly and successfully trace and fix crashes.
roryabraham commentedon Jun 2, 2022
cc @kidroca too, since this seems like something you might be knowledgable about
kidroca commentedon Jun 2, 2022
I think since the code is already open source we should be fine including source maps along the bundled code
There should be a way to tell crashlytics to use source maps. I can work on this and investigate what's needed
No one does 😁
Benefits
Drawbacks
AndrewGable commentedon Jun 2, 2022
Agree no concern because it's open source, this would be great to look into.
roryabraham commentedon Jun 3, 2022
It might be tough for @kidroca to look into the crashlytics piece, because he won't have access to Firebase.
AndrewGable commentedon Jun 3, 2022
Once we get the source maps in place, I'd be happy to check Firebase
kidroca commentedon Jun 14, 2022
web and desktop already include source maps
you can find them this way:
.mapto itHere's the current one for staging: https://staging.new.expensify.com/app-cc32624656c52b1a56be.bundle.js.map

...bundle.jsfile, then "Open in new tab", then append.mapto urlroryabraham commentedon Jun 14, 2022
Nice! Crashlytics is only relevant to iOS/Android for now. Do you know if those apps ship with a source map?
kidroca commentedon Jun 14, 2022
Source maps for iOS/Android should already be generated, the problem is even with source maps Firebase does not accept uploading a source map file, though stack traces can be decoded manually: invertase/react-native-firebase#2327 (comment)
So instead of trying to make Firebase work with source maps (show mapped sources) we can decode the stack trace and create a github issue mapped to original source
If sending/using source maps was possible it would have been explained here: https://rnfirebase.io/crashlytics/usage
Generating source maps
As mentioned they should already be generated, but since creating an issue will happen in a different context it should
v1.1.77-0.ios/android/web.source.js.mapin job artifacts to allow a future pipeline to use themTo generate source maps for iOS/Android we can run the following commands:
iOS
react-native bundle \ --dev false \ --platform ios \ --entry-file index.ios.js \ --bundle-output main.jsbundle \ --sourcemap-output main.jsbundle.mapAndroid
react-native bundle \ --dev false \ --platform android \ --entry-file index.android.js \ --bundle-output index.android.bundle \ --sourcemap-output index.android.bundle.mapThe build process probably already generates these so we should just find where and expose them as build artifacts
Symbolicating - decoding minified stack trace to original source
Covered in: https://reactnative.dev/docs/symbolication
Given a piece of text containing minified stack trace (we'll be getting this from Firebase somehow)
We run
npx metro-symbolicate android/app/build/generated/sourcemaps/react/release/index.android.bundle.map < stacktrace.txtto convert it to original source that we can use to create the Github issue
I think Firebase does not support
jssource maps (in iOS/Android), because in the Firebase Console we have Web/iOS/Android apps and each source is mapped to the underlying architecture, so iOS sources are mapped to iOS code (which is mapped at compile time) and the service knows how to decode that, while with js sources it would be up to react-native-firebase to remap js stack traces before posting crashlytics to Firebase and I guess that's an extra step they don't want to do for various reasons (just my thoughts though, not a fact)kidroca commentedon Jun 14, 2022
Feature request for
react-native-firebaseto use source maps for Crashlytics: https://invertase.canny.io/react-native-firebase/p/crashlytics-to-take-in-javascript-soucemap38 remaining items
AndrewGable commentedon Nov 10, 2022
Working on this now.
AndrewGable commentedon Nov 10, 2022
Made good progress on the API side of things, but running into issues when decoding. @kidroca or @roryabraham if you spot something, let me know...
1.2.24.0found here: https://github.com/Expensify/App/actions/runs/3395575377main.jsbundle.map.getAttachmentName#10907 and same versionencodedStackTrace.txtAny ideas? I think I remember we might need to do something to the stacktrace before running it through
metro-symbolicate?JmillsExpensify commentedon Nov 11, 2022
Adding this to WAQ based on recent discussion.
AndrewGable commentedon Nov 11, 2022
Ah OK I see from the PR:
So seeing some better results with this command:
AndrewGable commentedon Nov 11, 2022
Discussing internally but sounds like we need to configure our API to run this command further than we initially expected. Working on it!
AndrewGable commentedon Nov 12, 2022
End of week update: We need to install NodeJS on the web servers, so this is turning into slightly a larger project. Working on doing so now and then will circle back to the specific API layer code once that's done. Otherwise this is working in local testing.
AndrewGable commentedon Nov 15, 2022
After discussion we wanted a different solution than the initial one proposed for NodeJS. Working on an alternative solution.
AndrewGable commentedon Nov 16, 2022
Closing per https://github.com/Expensify/Expensify/issues/243479, tl;dr we are turning off Firebase crashes for the time being.