Skip to content

feat: (continued) allow omission of dart-opaque feature #2681

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

Closed
wants to merge 13 commits into from

Conversation

aran
Copy link
Contributor

@aran aran commented Apr 7, 2025

Changes

Fixes #2661

In this implementation flutter_rust_bridge::frb_generated_boilerplate_io and web are still present in the generated code, and now they have a reference to a dart-opaque feature that isn't present by default in the client's Cargo.toml. This can be worked around by adding the feature declaration. Fixing this so the code isn't generated at all would be a much bigger change.

@aran
Copy link
Contributor Author

aran commented Apr 7, 2025

This addresses https://github.com/fzyzcjy/flutter_rust_bridge/actions/runs/14270290721/job/40001795109?pr=2662 by adding a dart-opaque feature across all the Cargo.toml.

The "pseudo-manual" tests using dart-opaque aren't fixed yet, I'm not quite sure what's wrong there or what would be a good way to approach it.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Apr 7, 2025

Hmm, firstly do we have this symbol or is it accidentially removed?

image

@aran
Copy link
Contributor Author

aran commented Apr 8, 2025

Hmm, firstly do we have this symbol or is it accidentially removed?

That symbol is supposed to be gated on dart-opaque, so need to find all the places where dart-opaque is needed but not enabled. Found one more in 3682d0c.

Copy link

codecov bot commented Apr 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.84%. Comparing base (3aeceba) to head (3682d0c).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2681   +/-   ##
=======================================
  Coverage   98.84%   98.84%           
=======================================
  Files         469      469           
  Lines       20498    20510   +12     
=======================================
+ Hits        20262    20274   +12     
  Misses        236      236           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Apr 8, 2025

Looks good! Now we only have 2 failing checks and seems it is still related

image

@aran
Copy link
Contributor Author

aran commented Apr 9, 2025

I had to dig into a couple screens to figure out why the ubuntu CI jobs were "canceled". They failed with:

This is a scheduled Ubuntu 20.04 brownout. Ubuntu 20.04 LTS runner will be removed on 2025-04-15. For more details, see https://github.com/actions/runner-images/issues/11101

@fzyzcjy
Copy link
Owner

fzyzcjy commented Apr 9, 2025

Ah, looks like we need to upgrade the ubuntu version in the CI. Do you have interest in making a PR for this?

@aran
Copy link
Contributor Author

aran commented Apr 9, 2025

Ah, looks like we need to upgrade the ubuntu version in the CI. Do you have interest in making a PR for this?

I put up a quick find/replace PR but if there are issues due to the change I won't have time this week to look into them

@fzyzcjy
Copy link
Owner

fzyzcjy commented Apr 17, 2025

Wow I did not realize CI became green, good job! I will have a review on it hopefully within a day.

@@ -11,3 +11,6 @@ flutter_rust_bridge = REPLACE_ME_RUST_FRB_DEPENDENCY

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(frb_expand)'] }

[features]
dart-opaque = ["flutter_rust_bridge/dart-opaque"]
Copy link
Owner

Choose a reason for hiding this comment

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

nit: this file is for all new projects' Cargo.toml, so it would be great to keep it unchanged

EDIT: Oh I see the reason

This can be worked around by adding the feature declaration.

Hmm, however, it would be great if we do not require all user code to have such a new feature in Cargo.toml :(

EDIT: This seems interesting https://stackoverflow.com/questions/64546459/how-can-my-crate-check-the-selected-features-of-a-dependency - is it possible we somehow utilize this approach

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's an interesting hack. Never would have thought of it. Not sure if it's a good idea but I think it might work as long as the number of actually-needed feature combinations was small.

I would generalize that suggestion and say that it comes down to modifying flutter_rust_bridge::frb_generated_boilerplate_io and flutter_rust_bridge::frb_generated_boilerplate_web not to generate the code requiring dart-opaque. Perhaps that StackOverflow macro approach is the best way to do that, or there might be another way.


[features]
default = ["dart-opaque"]
dart-opaque = ["flutter_rust_bridge/dart-opaque"]
Copy link
Owner

Choose a reason for hiding this comment

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

nit: what about naming it flutter-rust-bridge--dart-opaque or something like that, so that it is more clear we are forwarding to there when we read our test infra code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure of the order of your comments, but just in case: No, this can't be renamed because the generated code from flutter_rust_bridge::frb_generated_boilerplate_* refers to "dart-opaque".

Copy link
Owner

Choose a reason for hiding this comment

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

Oh yes, the "EDIT" above is the last one, so we may use that approach etc.

flutter_rust_bridge = { path = "../../../frb_rust", features = [
"backtrace",
"chrono",
"dart-opaque",
Copy link
Owner

Choose a reason for hiding this comment

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

nit: given that dart_opaque is a default feature, maybe we can keep these lines unchanged

@@ -26,5 +31,7 @@ tokio = { version = "1.34.0", features = ["rt"] }

[features]
internal_feature_for_testing = []
dart-opaque = ["flutter_rust_bridge/dart-opaque"]
Copy link
Owner

Choose a reason for hiding this comment

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

nit: is it possible we delete this line (same as above)

@@ -2,4 +2,4 @@ import 'package:flutter_rust_bridge_utils/flutter_rust_bridge_utils.dart';

void main(List<String> args) async => simpleBuild(args,
// This is solely used for testing
features: ['internal_feature_for_testing']);
features: ['dart-opaque', 'internal_feature_for_testing']);
Copy link
Owner

Choose a reason for hiding this comment

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

nit: (same, can we del it)

@aran
Copy link
Contributor Author

aran commented Apr 18, 2025

Unfortunately I'm not going to be able to prioritize reworking this to use another approach so I'm going to close it out and maybe revisit another time.

A couple of the semi-related commits like ae8c875 and a75df11 might be independently useful even without the dart-opaque change, not sure.

@aran aran closed this Apr 18, 2025
@fzyzcjy
Copy link
Owner

fzyzcjy commented Apr 19, 2025

Sad to hear that :(

A couple of the semi-related commits like ae8c875 and a75df11 might be independently useful even without the dart-opaque change, not sure.

Yes that looks useful - do you have interest in making one (or two) separate PRs for these?

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.

Allow omission of dart-opaque feature
2 participants