Tracking bug for work on supporting WASM libraries in Dart.
Does wasmer have support for interface types, like wasmtime?
https://hacks.mozilla.org/2019/08/webassembly-interface-types/
I don't think so, but it sounds like this is an early stage proposal, so we probably shouldn't rely on it yet.
I investigated both wasmtime and wasmer (as well as some other stuff), and the reason I chose wasmer is that it's way easier to integrate with C++. I'm still just prototyping though.
Super excited to see this going! Let us know if we can be of any help :)
how about these?
https://www.youtube.com/watch?v=Qn_4F3foB3Q
Standardizing WASI: A system interface to run WebAssembly outside the web: https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/
WebAssembly Interface Types: Interoperate with All the Things!: https://hacks.mozilla.org/2019/08/webassembly-interface-types/
For everybody tracking this issue. We are currently evaluating how to move multiplatform Dart<->WASM interop forward. Similarly to our FFI work we would like to collect some examples of code that people would like to use in their Dart applications via WASM. So if you have one that is open source please leave a comment here or on #37355 with a link and which platforms you would like to use it on (Flutter on iOS/Android/Desktop/Web, Dart Web), please also include information on whether you have tried to compile this library to WASM before. Thank you.
@mraleph Thats great news!
One of my initial use cases would be to use the existing emscripten port for libgit compiled to WASM to avoid the need of having to build separate native libs for every platform the Flutter app using the lib needs to run on (eg. Android, iOS, MacOS, Linux, etc)
@maks Great to know! I have a quick question: does your Flutter app run on Web? If the app is only on non-Web platforms (Android, iOS, ...), it seems Dart FFI can support your use cases.
@kaikai4989 well yes I could use FFI, but that's the reason I want to use WASM is as I said to avoid having to build the native lib to use with FFI for android (NDK), iOS, Linux, MacOS, etc
That was why I posted, that I think one of the use cases for people will be using WASM instead of FFI to avoid the need to build native shared libs for every platform they want to support with their Flutter app. Being able to also run on web is for me just an added bonus of using WASM.
In addition to the portability aspect, WASM brings sandboxing/security guarantees as well as a fully managed memory model that you don't get with FFI. WASM is simply the better, more secure, and more future-proof option for client-side shared libraries.
We are currently using CanvasKit, which is Skia compiled to WebAssembly using emscripten, in Flutter for Web.
We use CanvasKit by loading the JavaScript wrapper script and calling into it with dart:js (since we're developing a Dart SDK library dart:ui we can't use package:js). dart:js has significant performance downsides caused by encoding and decoding all of the arguments and return values and copying buffer contents.
If we had direct access to the WASM, we could avoid having to use the wrapper script and JS interop.
@maks WASM support for libgit2 is maintained here:
Most helpful comment
For everybody tracking this issue. We are currently evaluating how to move multiplatform Dart<->WASM interop forward. Similarly to our FFI work we would like to collect some examples of code that people would like to use in their Dart applications via WASM. So if you have one that is open source please leave a comment here or on #37355 with a link and which platforms you would like to use it on (Flutter on iOS/Android/Desktop/Web, Dart Web), please also include information on whether you have tried to compile this library to WASM before. Thank you.