-
Notifications
You must be signed in to change notification settings - Fork 309
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
Web support #589
Web support #589
Conversation
Awesome job! Looking forward to merging it! - Feel free to ping me (or click "request review" button) when it is ready, cannot wait for that :) |
Btw I see some refactors in the PR, e.g. migrate to clap, use bail instead of assert, etc. What about making it a separate PR such that we can merge it firstly? That will make this main PR smaller and more focused on one problem (the web support problem). |
May I know what to merge? Not see PR in allo_isolate yet. Anyway just bump cargo.toml in this pr is sufficient |
No, I'm still unsure if I should merge this code at all, it introduces a lot of dependencies to support just a single platform. Maybe if I could get some feedback later on the shims then I can consider merging the code. |
Which dependencies? Maybe we can use cargo's conditional dependencies to make it optional |
Definitely, they are already target-gated to WASM. They are in frb_rust/Cargo.toml if you want to double check. |
So, maybe I do a code review on this draft even before it is mark as done? Because this is a very nontrivial PR, and early feedback instead of feedbacks after everything is done can save time and work needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is big work! I only reviewed part of it today and will look at it again later. As we all know code-review is critical to ensure code quality, so I will definitely review all, no worries ;) (And to avoid providing a ton of review to stress you...)
Remark: No worries about the code review comments - I am just leaving them here to provide early feedback :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! Looked at it a bit deeper, and only find some minor points that may need a bit of discussions
No I agree, it's a big one so I will also need to be more thorough than usual in my tests. |
Btw, we already have a ton of e2e tests (in the frb_dart .dart), so as long as we can run them in Web, we automatically get a lot of confidence :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little bit more review
Btw I am thinking about posting the news (frb supports web) after this PR is merged in Rust & Dart subreddit, since this new feature strengthens the lib a lot :) What do you think? |
Hopefully my comment is more helpful than unhelpful given the PR is still in the works and I'm aware that the documentation is not yet updated: I got curious and tried installing and running After this I successfully ran
Again, hopefully this is of use 😄 |
@mz2 Judging from the errors, seems that, when running the web platform, the example fail to use conditional import to completely avoid importing any files that uses native feature (i.e. dart:ffi). |
(Continuing noting my observations, let me know if this is just too early / not even supposed to work and I should not bother yet!)
Yep, that was it, thanks. The example doesn't take care of conditional imports yet. I was able to get the example application to run with the following (not sure if there is a more idiomatic solution, or some import that would itself take care of this): import 'package:flutter_rust_bridge_example/bridge_generated.dart'
if (dart.library.html) 'package:flutter_rust_bridge_example/bridge_generated.web.dart';
import 'dart:ffi' if (dart.library.html) './dylib_stub.dart'; ...where late final dylib = kIsWeb
? {} as WasmModule // just put this here to get it to build as a test, since I have not worked out how to generate the wasm module successfully for the example...
: Platform.isIOS
? DynamicLibrary.process()
: Platform.isMacOS
? DynamicLibrary.executable()
: DynamicLibrary.open(path);
late final api = FlutterRustBridgeExampleImpl(dylib as dynamic); Again, I am guessing there's an abstraction intended to solve this either already somewhere or coming up. Like this the code runs but of course doesn't work right yet, since I don't know how to get the wasm for the example built successfully. Is that meant to work? I tried the following, issued in
|
That is what I expected For other errors, I guess it is because the work is still WIP - the wire types have not been constructed fully yet. I am just guessing and @Desdaemon is the expert on this question, surely :) |
Awesome, well thanks a lot for all your effort on this, I can't wait to give this a spin and I bet I'm not the only one :-) |
You are right - I also can't wait to try it :) |
e4e84c6
to
4644ef6
Compare
Should be the last batch of changes to be reviewed by @fzyzcjy before merging. |
Excellent job! Now we are very close to the exciting moment of adding this big feature :) I will try to have as little issues as possible, and defer to future backlog as well.
|
4d05038
to
f02f84a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe in you, so only roughly look at the code and do not check the details :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All done!
Only 4 conversations (2 new, 2 reopened), with no more than file or function renaming or removing a comment line etc.
I will sleep now and check inbox after ~8 hours :)
- Rename `wasm2api_body` to `wire2api_jsvalue` - Run library unit tests in CI - Update Scoop manifest
Ready to merge! (After #678 since otherwise cannot release a new version with CI passing) |
Ah if you are resolving conflicts then I do not do it Anyway the code is OK and will be merged once master turns green |
🎉 |
Closes #315. Continues from #386.
Additions:
--wasm
flag to emit WASM-specific files--dart-decl-output
--inline-rust
to inline platform modules into a single fileChanges:
Internal changes:
Checklist
frb_example/pure_dart
example).book
folder) are modified as well.