-
Notifications
You must be signed in to change notification settings - Fork 3
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
Supported when compiling Flutter with --wasm? #8
Comments
Hi Robert. |
@vm75 this woule be great, I compiled some c++ code using emscripten and it runs fine with |
Hi Vijay, sorry for only getting back at you now. @CaptainDario I started working on a solution... The idea was to create a way to easily use Rust (or we can extend it to C++) with Flutter on the web. I looked at flutter_rust_bridge but they also have the same WASM issue. This worked for me using WASM but it's waaaay incomplete and messy. But the point is, I proved it can be done. https://github.com/robmllze/df_rust_interop_web We can team up and make a proper interop! I understand the WASM basics now after a bit of investigation. I would love to contribute on projects! I've been completely solo for years and it's getting lonely! XD I have more packages here that I'm maintaining (trying) but it's a lot of unpaid work for a single dev! https://github.com/DevCetra/ |
@CaptainDario @robmllze , i was able to run wasm on vanilla Dart as well as Flutter.
I am incorporating it into Sweph, and that will give an idea of how to create a Flutter plugin using universal_ffi |
@robmllze |
@CaptainDario , I think the wasms may be invisible to each other. There may not be an easy solution for this. |
This is awesome, thanks!
What do you mean by this? |
@vm75 Thanks for your help, however I'm already running my project with --wasm for performance. The idea is, if we can add reusable .wasm modules to our code, we essentially can hide parts of the code from some of our temporary contractors who are working on the project. You can basically create proprietary packages without revealing the source code. Kind of like a DLL or shared library. We can also code part of the project in systems programming languages like Rust, specifically parts that Dart is always going to be slow at. I was able to do a quick experiment and I successfully managed to get this process working. I haven't had time to turn this into a package yet. The wasms all run on the main thread by default, and they can communicate via things like SharedArrayBuffer or you can just take the output of one function from a module and send it as input to another function in another module in Dart. |
Thanks @robmllze . It is an interesting way to use wasm. I did realist that we can use dart and stitch multiple wasms together. It is a bummer that it is not straightforward to share memory between wasms (especially standalone wasm). I do plan to try some hacks there eventually. |
@CaptainDario methods in once wasm cannot directly call into methods of another wasm. Even sharing memory between wasms is tricky. As @robmllze mentioned, there are some workarounds. When using --wasm, I understand that the main dart code itself becomes a wasm. So I got confused on how it will share memory, etc. I will also play around with --wasm and see. |
wasm_ffi needs some changes for wasm-loading to work from dart2wasm. I've just spent a full day investigating this possibility and have concluded that it's more than a week of work for me (with zero experience in wasm FFI). Basically, what I find is that the "wasmExports" lookup looks very different, and the js_interop_unsafe return values are a bit different on the wasm target, so the first problem I ran into was In any case, I'd love to see some progress here and I'm happy to test any potential improvements. |
Hi mate,
Great package. I'd like to see more development going into this. I can contribute. Quick, question:
I managed to make some Rust code work, via
lookupFunction
. I can run my app throughflutter run -d chrome
, however, when I doflutter run -d chrome --wasm
, the lookup throws an error and my function isn't found. Any ideas why this might be?Looking forward to your response,
Robert
The text was updated successfully, but these errors were encountered: