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

[dart2wasm] Add support detection mechanism #59951

Open
mkustermann opened this issue Jan 22, 2025 · 0 comments
Open

[dart2wasm] Add support detection mechanism #59951

mkustermann opened this issue Jan 22, 2025 · 0 comments
Labels
area-dart2wasm Issues for the dart2wasm compiler.

Comments

@mkustermann
Copy link
Member

The initial WasmGC support has landed in the spec and our compiler can rely on everything in it. Though the wasm spec will be evolving over time and we want to be able to take advantage of newer features. In many cases it may not be possible to polyfill those features (e.g. usage of new instructions, new builtins that aren't polyfillable, etc).

Because of this I'd like to us to introduce a support detection mechanism that users can call to detect if their environment allows running dart2wasm compiled code.

One way could be to make this part of the public API of our <app>.mjs e.g.

const bundle = await import('app.mjs');
if (bundle.supportsCurrentEnvironment()) {
  const compiledApp = await bundle.compileStreaming(fetch('app.wasm');
  const appInstance = await compiledApp.instantiate(...);
  appInstance.invokeMain();
} else {
  // fall back to JS
}

The downside of making this part of the <app>.mjs file is that users first have to load the mjs file (which may not be that small) in order to detect whether the wasm can be used before loading the actual wasm file (or loading the wasm file concurrently but possibly not use it).

So we could also emit an extra file

app.mjs
app.wasm
app.wasm.maps
app.support.mjs (New)

that has such an API function in it.

Then we as Dart team can decide when we start requiring new things (based on data of browser support and browser version usages out there) and/or allow the invoker of dart2wasm to tell us to use newer features.

/cc @osa1
/cc @kevmoo
/cc @yjbanov @eyebrowsoffire what mechanism would work best for flutter?

@mkustermann mkustermann added the area-dart2wasm Issues for the dart2wasm compiler. label Jan 22, 2025
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.
Projects
None yet
Development

No branches or pull requests

1 participant