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

JavaScript fallback for WebAssembly libraries #6814

Closed
wants to merge 4 commits into from

Conversation

murilopereirame
Copy link
Contributor

@murilopereirame murilopereirame commented Apr 2, 2024

Adds the generation of a JavaScript transpile for Argon2 and Liboqs WebAssembly files. This is done through wasm2js that's builtin on emcc.

Closes #6768

Co-authored-by: wec43 wec@tutao.de

murilopereirame and others added 2 commits April 3, 2024 11:47
This commit adds the generation of a JavaScript transpile for the Argon2
WebAssembly file. This is done through wasm2js that's builtin on emcc.

Co-authored-by: wec43 <wec@tutao.de>
This commit adds the generation of a JavaScript transpile for the Liboqs
WebAssembly file. This is done through wasm2js that's builtin on emcc.

Co-authored-by: wec43 <wec@tutao.de>
@murilopereirame murilopereirame changed the title Wasm js fallback 6768 JavaScript fallback for WebAssembly libraries Apr 3, 2024
@murilopereirame murilopereirame marked this pull request as ready for review April 3, 2024 09:49
Co-authored-by: wec43 <wec@tutao.de>
@charlag
Copy link
Contributor

charlag commented Apr 4, 2024

Nice!

I think ideally (and I'm not sure if it's in the scope) we wouldn't need to manually take care of every WASM file. In SDK prototype we have successfully used WASM loader:

plugins: [libDeps(), externalTranslationsPlugin(), wasmLoader({ mode: "deferred" })],

maybe we need another plugin(s) so that we can automatically generate the fallback and add the code that conditionally loads one or another

Copy link
Contributor

@charlag charlag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great job!

I don't think compiled wasm/js should be checked in though. We should also explicitly depend on wasm2js my bad, wasm2js is part of the compilation toolchain

libs/webassembly/Makefile_argon2 Show resolved Hide resolved
Copy link
Contributor

@paw-hub paw-hub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, at least.

We should have test notes, though.

@charlag
Copy link
Contributor

charlag commented Apr 18, 2024

We did agree to remove the compiled artifacts, right?

@charlag
Copy link
Contributor

charlag commented Apr 18, 2024

Also, for documentation purposes, the build system integration/glue generation is tracked at #6835

Copy link
Contributor

@charlag charlag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have another concern, I think right now we will just rollup the fallback JS into the same bundle as the rest of the crypto? it should be separate, maybe it's own chunk

packages/tutanota-utils/lib/WebAssembly.ts Outdated Show resolved Hide resolved
@paw-hub paw-hub self-requested a review April 18, 2024 09:04
@paw-hub paw-hub force-pushed the wasm-js-fallback-6768 branch 2 times, most recently from db3470d to 28ac208 Compare April 18, 2024 10:29
This allows WASM/JS fallbacks to use the same interface and reduce the
extra type casting once initialized.
@murilopereirame
Copy link
Contributor Author

We did agree to remove the compiled artifacts, right?

I remember that for this initial implementation we check in the compiled artifacts and after implementing the integration inside the build process we're going to uncheck them.

@murilopereirame murilopereirame changed the base branch from master to wasm-loader-6835 April 25, 2024 07:50
@murilopereirame murilopereirame force-pushed the wasm-loader-6835 branch 4 times, most recently from b4d3023 to fa91cea Compare April 29, 2024 10:28
@murilopereirame murilopereirame force-pushed the wasm-loader-6835 branch 3 times, most recently from 1d2dba5 to e4e74e1 Compare May 13, 2024 12:09
Base automatically changed from wasm-loader-6835 to master May 22, 2024 08:47
@wrdhub
Copy link
Contributor

wrdhub commented May 22, 2024

pr #6868 has what needs to be merged in, this one can be closed

@wrdhub wrdhub closed this May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add JS fallback for WASM components
4 participants