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

Considerations for WebAssembly runtime #39

Open
mingyaulee opened this issue Jul 9, 2021 · 8 comments
Open

Considerations for WebAssembly runtime #39

mingyaulee opened this issue Jul 9, 2021 · 8 comments
Labels
enhancement Enhancement or change to an existing feature spec clarification Needs clarification when specified topic: csp Related to content security policy enforcement

Comments

@mingyaulee
Copy link

Web development is no longer just dominated by JavaScript with the emergence of more WebAssembly runtime and framework.

There are certain limitations when it comes to using WebAssembly to develop an extension, such as longer load time and bigger package size.

With this in mind, decisions such as deprecating persistent background in favour of service worker needs to be reconsidered because if the extension has a fresh start for every event, we will face similar issue of having "cold start" in serverless applications. I have been using Blazor to develop extensions and generally the pages take about 3 seconds to startup. I haven't been developing more advanced scenarios so that is all I can think of so far.

@dotproto
Copy link
Member

#41 touched on a similar request, but I believe it focused more specifically on exposing bindings in Wasm.

On the topic of bindings, as I understand it, projects like Rust have to use tools like wasm-bindgen to create JS bindings that expose DOM and other JS APIs to Rust code. This adds a layer of indirection to Wasm projects that increases the amount of code that browsers must parse, cache, and execute on initial execution, and potentially increases runtime costs. Long term it would be ideal for browsers to expose WebExtension bindings directly to Wasm code, but this is blocked on the Wasm project's interface-types work.

@xeenon xeenon added enhancement Enhancement or change to an existing feature spec clarification Needs clarification when specified labels Sep 2, 2021
@mingyaulee
Copy link
Author

Just to add on to the issue description, after trying to port an extension developed with Blazor to manifest V3, it is not possible to load web assembly because of the restrictive permissions (no wasm-eval, unsafe-eval and sha256 hash permission allowed in V3).

Note: Unsafe eval is required by Chrome to run web assembly right now. WebAssembly/content-security-policy#7

@OluAgunloye
Copy link

#41 touched on a similar request, but I believe it focused more specifically on exposing bindings in Wasm.

On the topic of bindings, as I understand it, projects like Rust have to use tools like wasm-bindgen to create JS bindings that expose DOM and other JS APIs to Rust code. This adds a layer of indirection to Wasm projects that increases the amount of code that browsers must parse, cache, and execute on initial execution, and potentially increases runtime costs. Long term it would be ideal for browsers to expose WebExtension bindings directly to Wasm code, but this is blocked on the Wasm project's interface-types work.

No, lol. This is not a problem w/ WASM.

@didyk
Copy link

didyk commented Oct 7, 2021

Just to add on to the issue description, after trying to port an extension developed with Blazor to manifest V3, it is not possible to load web assembly because of the restrictive permissions (no wasm-eval, unsafe-eval and sha256 hash permission allowed in V3).

Note: Unsafe eval is required by Chrome to run web assembly right now. WebAssembly/content-security-policy#7

Started to move from manifest v2 to v3 and face this problem too

@Rob--W
Copy link
Member

Rob--W commented May 20, 2022

FYI: extensions can now use WebAssembly if they specify 'wasm-unsafe-eval' in their CSP, see #98 (comment). Support for that directive source has landed in Firefox 102 and Chrome 103. More details on support in Firefox and Chromium across browser versions is at https://bugzilla.mozilla.org/show_bug.cgi?id=1766027#c2

@Jack-Works
Copy link

Support for that directive source has landed in Firefox 102 and Chrome 103

Also for Manifest V3?

@Rob--W
Copy link
Member

Rob--W commented May 21, 2022

Support for that directive source has landed in Firefox 102 and Chrome 103

Also for Manifest V3?

Yes, in Firefox and Chromium. See bugs and comments that I have linked before.

@Rob--W
Copy link
Member

Rob--W commented Jul 18, 2022

While 'wasm-unsafe-eval' allows extensions to use wasm, it is not ideal because it also opens the door to arbitrary wasm code from remote sources.

The browser vendors among us are starting to look for ways to enable extensions to only use wasm bundled with the extension. This discussion starts at: WebAssembly/content-security-policy#37 (comment)

@xeenon xeenon added the topic: csp Related to content security policy enforcement label Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement or change to an existing feature spec clarification Needs clarification when specified topic: csp Related to content security policy enforcement
Projects
None yet
Development

No branches or pull requests

7 participants