Skip to content
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

Is it possible for the output of FRB to be directly called by Android/iOS Native? #2503

Open
lwj1994 opened this issue Jan 17, 2025 · 4 comments
Labels
awaiting Waiting for responses, PR, further discussions, upstream release, etc enhancement New feature or request

Comments

@lwj1994
Copy link

lwj1994 commented Jan 17, 2025

Thanks for this lib. our project is flutter-module mode. we want share code with android&ios&dart. we want reuse the output of FRB. the dartbinding-fork of uniffi-rs is unactive.

@lwj1994 lwj1994 added the enhancement New feature or request label Jan 17, 2025
Copy link

welcome bot commented Jan 17, 2025

Hi! Thanks for opening your first issue here! 😄

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jan 18, 2025

Hi, frb does not directly support Rust to Android/iOS native. But may I know a bit more details about the project - why is the code shared betweeen android/ ios and dart? (we may discuss e.g. if it is possible to be shared only to dart)

@fzyzcjy fzyzcjy added the awaiting Waiting for responses, PR, further discussions, upstream release, etc label Jan 18, 2025
@lwj1994
Copy link
Author

lwj1994 commented Jan 18, 2025

Our project is a hybrid Flutter application based on flutter_boost, with Flutter making up approximately 65% of the codebase. We need to maintain three parts: Android Native, iOS Native, and Flutter.

Currently, we have some common logic processing, such as obtaining image metadata, which returns the image format, width, and height: getImageMeta(). We've implemented getImageMeta separately on both Android and iOS, and Flutter calls these native implementations through channels.
Modifying three platforms—Android, iOS, and Flutter,requires a significant amount of work, making it very costly.

There are many similar scenarios like getImageMeta, and we don't want to repeat the logic implementation every time. Therefore, we want to use Rust to share this logic.

I've looked into mozilla/uniffi-rs. However, it doesn't have official Dart bindings, and the third-party implementations are not very complete. On the other hand, frb is more actively maintained, so I prefer to choose frb. Therefore, I hope frb can extend its capabilities so that both Android and iOS can also benefit from it.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jan 18, 2025

Hmm I see. Some brainstorms:

  • Is it possible to use both frb (for flutter) and uniffi (for android/ios)? Since frb usually needs very minimal (if not zero) configuration and adaptation, usually the frb side can be generated automatically, and you may only need to spend some time handling uniffi's requirements.
  • Is it possible to call android/ios --> flutter --> rust? (the former via flutter's official Pigeon, the latter via frb) This will have lower performance, but if the overhead is negligible (e.g. this is not called a huge number of times) then I guess this is OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting Waiting for responses, PR, further discussions, upstream release, etc enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants