Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CP] [dart2wasm] Generate source maps #56239

Closed
mkustermann opened this issue Jul 15, 2024 · 6 comments
Closed

[CP] [dart2wasm] Generate source maps #56239

mkustermann opened this issue Jul 15, 2024 · 6 comments
Assignees
Labels
area-dart2wasm Issues for the dart2wasm compiler. cherry-pick-approved Label for approved cherrypick request cherry-pick-merged Cherry-pick has been merged to the stable or beta branch. cherry-pick-review Issue that need cherry pick triage to approve type-enhancement A request for a change that isn't a bug

Comments

@mkustermann
Copy link
Member

Commit(s) to merge

We'd like the source map support for dart2wasm to be included in the next stable to be released (which current beta will be the base for I assume).

Target

beta

Prepared changelist for beta/stable

https://dart-review.googlesource.com/c/sdk/+/375660

Issue Description

Flutter web developers get only names in stack traces but no line numbers.

What is the fix

Cherry-pick the source map support.

Why cherry-pick

To make stack traces more readable in local development we'd like users of dart2wasm to get source map support. Due to infrequent releases of stable, we'd like to cherry-pick this into the beta (which I assume will become the upcoming stable)

Risk

Low

Issue link(s)

#55763

Extra Info

No response

@mkustermann mkustermann added the cherry-pick-review Issue that need cherry pick triage to approve label Jul 15, 2024
@mkustermann
Copy link
Member Author

/cc @kevmoo @osa1

If this gets accepted, flutter may want to cherry-pick flutter/flutter#151643 to flutter/flutter in their beta/stable.

@dart-github-bot
Copy link
Collaborator

Summary: Dart2wasm currently lacks source map support, making stack traces in Flutter web development unreadable. This issue proposes cherry-picking source map support into the beta release to improve stack trace readability for developers.

@dart-github-bot dart-github-bot added area-dart2wasm Issues for the dart2wasm compiler. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-enhancement A request for a change that isn't a bug labels Jul 15, 2024
@vsmenon
Copy link
Member

vsmenon commented Jul 15, 2024

lgtm

@sigmundch
Copy link
Member

LGTM - we discussed this at the scrum meeting today and concluded to move forward with the CP (together with the flutter CP as well)

@itsjustkevin itsjustkevin added the cherry-pick-approved Label for approved cherrypick request label Jul 15, 2024
@itsjustkevin
Copy link
Contributor

@mkustermann cherry-pick approved, please merge.

copybara-service bot pushed a commit that referenced this issue Jul 19, 2024
This implements generating source maps for the generated Wasm files.

Copying dart2js's command line interface, a source map file with the
name `<program name>.wasm.map` is generated unless `--no-source-maps` is
passed.

When a source map is generated, the generated .wasm file gets a new
section `sourceMappingURL` with the contents `<program name>.wasm.map`.

This section seems to be undocumented, but Chrome and binaryen recognize
it as the URI to the source map file. Chrome is then loads it
automatically in the DevTools.

- `wasm_builder` package is updated with the new `source_map` library,
  which describes the source mapping entries.

- `wasm_builder`'s `InstructionsBuilder` is updated with the new public
  members:

  - `startSourceMapping`: starts mapping the instructions generated to
    the given source code.

  - `stopSourceMapping`: stops mapping the instructions generated to a
    source code. These instructions won't have a mapping in the source
    map.

- `CodeGenerator` sets the source file URI and location in the file
  when:

  - Starting compiling a new member
  - Compiling an expression and statement

Bug: #55763
Change-Id: Ieb24796b4b17a735b846793617664a453f1061ce
Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/370500
Cherry-pick-request: #56239
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375660
Reviewed-by: Ömer Ağacan <[email protected]>
Commit-Queue: Martin Kustermann <[email protected]>
@mkustermann
Copy link
Member Author

@mkustermann cherry-pick approved, please merge.

Merged.

@itsjustkevin itsjustkevin added the cherry-pick-merged Cherry-pick has been merged to the stable or beta branch. label Jul 19, 2024
@lrhn lrhn removed the triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. label Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-dart2wasm Issues for the dart2wasm compiler. cherry-pick-approved Label for approved cherrypick request cherry-pick-merged Cherry-pick has been merged to the stable or beta branch. cherry-pick-review Issue that need cherry pick triage to approve type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

8 participants