-
Notifications
You must be signed in to change notification settings - Fork 343
Make "rust-async" feature optional #2723
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
base: master
Are you sure you want to change the base?
Conversation
So the reason why CI fails right now is basicaly this:
I sure can generate and push updated bindings but this would probably be wrong. I guess that the protocol for this should be something like: regenerated dart-sys, update dart-sys in Cargo.toml, upgrade FRB_MAIN_DART_VERSION and FRB_MAIN_FLUTTER_VERSION in github workflow, upgrade environment.sdk constraint in frb_dart/pubspec.yaml. So it seems to be out of scope fo this PR. |
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! Only some small suggestions
frb_rust/Cargo.toml
Outdated
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.
it would be great to add some tests e.g. following #2681
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.
Well its not removing rust-async
from default
, but makes it optional, so everything except exporting async
functions should work as before.
I've added frb_example/no_rust_async
which just tests regualr stuff but with rust-async
featrue disabled.
CI will probably fail, Il fix it later, just want to be sure that this apporach is ok. Let me know what you think about this.
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.
Hmm, looks like there is no need to add a new example, but directly use approach in #2681 and use existing examples
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.
Okay, so I guess what you mean is ae8c875 which changes getRustFeaturesOfPackage
to return a list of feature configurations and testDartNative
will iterate through all configuration running tests multiple times.
But the issue is that I cant run all tests in frb_example
two times (with rust-async
and without) cause this PR does not affect code generation. Meaning that if there is an async function exported from Rust its FFI glue will be generated, but it will fail to compile later. And this is the intened behaviour.
So to run all tests two times it will aslo need to hide exported Rust async functions behind a #[cfg]
and then run codegen between test runs. And that would also probalby require some major github workflow or frb_internal
rework.
I've tried to implement this approach and added tests to frb_example/dart_minimal
. It runst two times with and without rust-async
but it only works because there are no async functions in Rust. So tell me what you think about this
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.
@fzyzcjy ping
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.
oops I did not receive any pings :(
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 guess it is because your new commits will make this pr in my github noti inbox, and then I come here and see there are the "New changes since you last viewed" hints and thus I leave :(
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.
Yes I originally meant to mimic that commit and test multi times. Now I see dart_minimal by has async functions, and thus we cannot trivially mimic that approach. I am ok for whichever approach!
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.
Ha, and I've missed you reply somehow :) Only received notification when you've merged master here. I'll take a look at it this week.
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.
Take your time! I will check every notification here; but if I somehow again missed your reply, just ping me on issues (since that one will only be triggered when there are messages, and no commits will trigger).
No worries about that CI failure caused by dart sdk bump, I will handle it |
Fixes #2253
Changes
So I've got pretty much the same issue as described in #2253 - I only use
#[frb(sync)]
, so I want to turn offrust-async
andthreadpool
so there wont be 2*num_cpus threads just hangin there doing nothing. Disablingthreadpool
works fine, but when I try to disablerust-async
I get complation errors:Currently I fix this by having
rust-async
enbled and declaring a customFLUTTER_RUST_BRIDGE_HANDLER
that has no async executor. Thats fine, but I believe that this should be fixed here.So this PR tries to make
rust-async
feature optional and decouple it fromdart-opaque
.Procedure and Checklist
In order to quickly iterate and avoid slowing down development pace by making CI pass, only the following simplified steps are needed, and I (fzyzcjy) will handle the rest of CI / moving the tests currently (will have more automation in the future).
frb_example/dart_minimal
.dart_minimal
's CI green.Utility commands
cargo run --manifest-path /path/to/flutter_rust_bridge/frb_codegen/Cargo.toml -- generate
./frb_internal test-dart-native --package frb_example/dart_minimal