facebook / metro

🚇 The JavaScript bundler for React Native
https://metrobundler.dev
MIT License
5.17k stars 614 forks source link

RAM Bundles: Incorrect line mappings #399

Open mikeewhite opened 5 years ago

mikeewhite commented 5 years ago

The line mappings resolved from metro-symbolicate for RAM bundled applications appear to be broken.

I've created a simple example repository which uses the latest release of React Native (v0.59.5) and includes four crash scenarios (each one can be triggered by pressing the corresponding button).

Before enabling RAM bundles, I grabbed the line and column numbers from the top frame from each resulting stacktrace and converted them using the symbolicate.js script in metro-symbolicate and got the expected mappings, i.e.

I repeated the same test after enabling RAM bundles but passing the associated filenames for each frame into symbolicate.js, e.g.

./symbolicate.js <path-to-source-map> 364.js 1 250 

And the resulting mappings are out of alignment (for both iOS and Android):

I've included the command I used to generate the associated source maps in the readme of the example repository.

motiz88 commented 5 years ago

Thanks for the detailed report @mikeewhite!

I gather from your README that you're running separate builds: One as part of running the app, and one to generate a source map. Did I get that right? I suspect this might be at least part of the problem, as the ordering of modules inside a bundle is in general nondeterministic across builds. Would you be able to try again, with both the executed bundle and the source map coming from the same build?

mikeewhite commented 5 years ago

Hi @motiz88 - thanks for the fast response!

Yes, I'm running (for example) react-native run-android ... and react-native ram-bundle ... separately.

How would I go about running the two together? Can I send a cURL request to the running metro server to get the source map?

mikeewhite commented 5 years ago

Hi @motiz88 - I added the following to my example app's android/app/build.gradle:

project.ext.react = [
    extraPackagerArgs: ["--sourcemap-output", "$buildDir/android.release.ram.bundle.map"],
    ...
]

And re-ran react-native run-android --variant release and repeated my tests (using the sourcemap output into my build directory) and got exactly the same results.

Is that a good enough test (to determine whether the nondeterministic build is having an effect)?

motiz88 commented 5 years ago

Thanks @mikeewhite, seems clear that this isn't a nondeterminism issue then.

cc @cpojer - RAM bundle source maps seem to be borked. I've seen similar problems in my own testing.

mikeewhite commented 5 years ago

It looks like this is still an issue in RN v0.60.

@motiz88 @cpojer are there any plans to fix this in the near future?

marandaneto commented 2 years ago

@motiz88 is there something that we can help with to move this forward? thanks.