fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
3.64k stars 256 forks source link

Unhandled Exception: Bad state; out-of-sync code #1926

Closed dm107 closed 3 weeks ago

dm107 commented 3 weeks ago

Describe the bug

Running the flutter app results in an unhandled exception when using reqwest (async and sync). The reason is: content hash on Dart side (...) is different from Rust side (...) But the compilation of Rust passed without errors, as well flutter_rust_bridge_codegen generate After removing the reqwest client everything works fine.

Steps to reproduce

  1. Create a new app with flutter_rust_bridge_codegen create my_app
  2. Add the following code to simple.rs
    
    use reqwest::blocking::Client;

[flutter_rust_bridge::frb(sync)] // Synchronous mode for simplicity of the demo

pub fn greet(name: String) -> String { format!("Hello, {name}!") }

[flutter_rust_bridge::frb(init)]

pub fn init_app() { // Default utilities - feel free to customize flutter_rust_bridge::setup_default_user_utils(); }

pub struct SimpleApi { client: Client, }

impl SimpleApi { pub fn new() -> Self { Self { client: Client::new(), } } }

3. Add reqwest to dependencies

reqwest = { version = "0.12.4", features = ["blocking", "json"] }

4. Generate *flutter_rust_bridge_codegen generate*
5. Run *flutter run*

### Logs

```shell
E/flutter (17651): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: Content hash on Dart side (1147114678) is different from Rust side (-1918914929), indicating out-of-sync code. This may happen when, for example, the Dart code is hot-restarted/hot-reloaded without recompiling Rust code. (Note: This is just a sanity check. Even if content hash does not change, the code may still change and needs to be recompiled)
E/flutter (17651): #0      BaseEntrypoint._sanityCheckContentHash (package:flutter_rust_bridge/src/main_components/entrypoint.dart:96:7)
E/flutter (17651): #1      BaseEntrypoint.initImpl (package:flutter_rust_bridge/src/main_components/entrypoint.dart:52:5)
E/flutter (17651): <asynchronous suspension>
E/flutter (17651): #2      RustLib.init (package:my_app/src/rust/frb_generated.dart:25:5)
E/flutter (17651): <asynchronous suspension>
E/flutter (17651): #3      main (package:my_app/main.dart:6:3)

Expected behavior

No response

Generated binding code

No response

OS

Windows 11

Version of flutter_rust_bridge_codegen

v2.0.0-dev.33

Flutter info

[√] Flutter (Channel stable, 3.19.6, on Microsoft Windows [Version 10.0.22631.3447], locale de-DE)
    • Flutter version 3.19.6 on channel stable at D:\Entwicklung\Flutter\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 54e66469a9 (3 weeks ago), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.31.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\Users\[name]\AppData\Local\Android\sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: D:\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-b2043.56-10550314)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.9.6)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.9.34728.123
    • Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2023.1)
    • Android Studio at D:\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-b2043.56-10550314)

[√] VS Code (version 1.89.0)
    • VS Code at C:\Users\[name]\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.88.0

[√] Connected device (4 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 14 (API 34) (emulator)
    • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [Version 10.0.22631.3447]
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 124.0.6367.119
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 124.0.2478.80

[√] Network resources
    • All expected network resources are available.

• No issues found!

Version of clang++

No response

Additional context

No response

welcome[bot] commented 3 weeks ago

Hi! Thanks for opening your first issue here! :smile:

fzyzcjy commented 3 weeks ago

Hi, could you please share a minimal reproducible sample, and also show generate's log? That looks like a bug. In normal scenario, the content hash will be updated in both Rust generated code and Dart generated code, so they should be in sync.

dm107 commented 3 weeks ago

Hey, sure. Here's the debug log:

[2024-05-07T06:59:40.349Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\crates.rs:26] parse manifest_path="\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\Cargo.toml"
[2024-05-07T06:59:40.558Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:31] parse START info=ModuleInfo { visibility: Public, file_path: "\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\lib.rs", module_path: ["crate"] }
[2024-05-07T06:59:40.559Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:150] parse_syn_item_mod module_path=["crate", "api"]                                                                                            
[2024-05-07T06:59:40.559Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:202] parse_syn_item_mod_contentless module_path=["crate", "api"]                                                                                
[2024-05-07T06:59:40.560Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:205] file_path_candidates "api" "\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\lib.rs" ["\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\api.rs", "\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\api\\mod.rs", "\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\lib\\api.rs", "\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\lib\\api\\mod.rs"]
[2024-05-07T06:59:40.562Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\reader.rs:22] read_rust_file rust_file_path="\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\api\\mod.rs" module=Some("api")                                              
[2024-05-07T06:59:40.563Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\commands\cargo_expand.rs:31] CachedCargoExpand execute manifest_dir= rust_crate_dir="\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust"                                                          
[2024-05-07T06:59:40.565Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:216] Trying to parse "\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\api\\mod.rs"                                                          
[2024-05-07T06:59:40.566Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:31] parse START info=ModuleInfo { visibility: Public, file_path: "\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\api\\mod.rs", module_path: ["crate", "api"] }
[2024-05-07T06:59:40.566Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:150] parse_syn_item_mod module_path=["crate", "api", "simple"]                                                                                  
[2024-05-07T06:59:40.566Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:180] parse_syn_item_mod_contentful module_path=["crate", "api", "simple"]                                                                       
[2024-05-07T06:59:40.567Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:31] parse START info=ModuleInfo { visibility: Public, file_path: "\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\api\\mod.rs", module_path: ["crate", "api", "simple"] }
[2024-05-07T06:59:40.568Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:101] parse_syn_item_struct_or_enum item_ident=Ident { sym: SimpleApi, span: bytes(1230..1239) }                                                 
[2024-05-07T06:59:40.568Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:77] parse END info=ModuleInfo { visibility: Public, file_path: "\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\api\\mod.rs", module_path: ["crate", "api", "simple"] }
[2024-05-07T06:59:40.569Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:77] parse END info=ModuleInfo { visibility: Public, file_path: "\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\api\\mod.rs", module_path: ["crate", "api"] }
[2024-05-07T06:59:40.569Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:150] parse_syn_item_mod module_path=["crate", "frb_generated"]                                                                                  
[2024-05-07T06:59:40.570Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:202] parse_syn_item_mod_contentless module_path=["crate", "frb_generated"]                                                                      
[2024-05-07T06:59:40.570Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:205] file_path_candidates "frb_generated" "\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\lib.rs" ["\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\frb_generated.rs", "\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\frb_generated\\mod.rs", "\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\lib\\frb_generated.rs", "\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\lib\\frb_generated\\mod.rs"]
[2024-05-07T06:59:40.571Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\reader.rs:22] read_rust_file rust_file_path="\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\frb_generated.rs" module=Some("frb_generated")                               
[2024-05-07T06:59:40.571Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\commands\cargo_expand.rs:31] CachedCargoExpand execute manifest_dir= rust_crate_dir="\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust"                                                          
[2024-05-07T06:59:40.572Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:216] Trying to parse "\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\frb_generated.rs"                                                     
[2024-05-07T06:59:40.577Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:31] parse START info=ModuleInfo { visibility: Inherited, file_path: "\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\frb_generated.rs", module_path: ["crate", "frb_generated"] }
[2024-05-07T06:59:40.578Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:101] parse_syn_item_struct_or_enum item_ident=Ident { sym: FrbWrapper, span: bytes(2028..2038) }                                                
[2024-05-07T06:59:40.578Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:101] parse_syn_item_struct_or_enum item_ident=Ident { sym: MoiArc, span: bytes(2702..2708) }                                                    
[2024-05-07T06:59:40.579Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:124] parse_syn_item_struct_or_enum item_type=ItemType { attrs: [], vis: Visibility::Inherited, type_token: Type, ident: Ident { sym: ObjectId, span: bytes(6528..6536) }, generics: Generics { lt_token: None, params: [], gt_token: None, where_clause: None }, eq_token: Eq, ty: Type::Path { qself: None, path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { sym: usize, span: bytes(6539..6544) }, arguments: PathArguments::None }] } }, semi_token: Semi }
[2024-05-07T06:59:40.579Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:124] parse_syn_item_struct_or_enum item_type=ItemType { attrs: [], vis: Visibility::Public(Pub), type_token: Type, ident: Ident { sym: MoiArcPool, span: bytes(6559..6569) }, generics: Generics { lt_token: Some(Lt), params: [GenericParam::Type(TypeParam { attrs: [], ident: Ident { sym: T, span: bytes(6570..6571) }, colon_token: None, bounds: [], eq_token: None, default: None })], gt_token: Some(Gt), where_clause: None }, eq_token: Eq, ty: Type::Path { qself: None, path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { sym: std, span: bytes(6575..6578) }, arguments: PathArguments::None }, PathSep, PathSegment { ident: Ident { sym: sync, span: bytes(6580..6584) }, arguments: PathArguments::None }, PathSep, PathSegment { ident: Ident { sym: RwLock, span: bytes(6586..6592) }, arguments: PathArguments::AngleBracketed { colon2_token: None, lt_token: Lt, args: [GenericArgument::Type(Type::Path { qself: None, path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { sym: MoiArcPoolInner, span: bytes(6593..6608) }, arguments: PathArguments::AngleBracketed { colon2_token: None, lt_token: Lt, args: [GenericArgument::Type(Type::Path { qself: None, path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { sym: T, span: bytes(6609..6610) }, arguments: PathArguments::None }] } })], gt_token: Gt } }] } })], gt_token: Gt } }] } }, semi_token: Semi }
[2024-05-07T06:59:40.580Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:101] parse_syn_item_struct_or_enum item_ident=Ident { sym: MoiArcPoolInner, span: bytes(6629..6644) }                                           
[2024-05-07T06:59:40.581Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:101] parse_syn_item_struct_or_enum item_ident=Ident { sym: IdGenerator, span: bytes(6937..6948) }                                               
[2024-05-07T06:59:40.581Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:101] parse_syn_item_struct_or_enum item_ident=Ident { sym: MoiArcPoolValue, span: bytes(7521..7536) }                                           
[2024-05-07T06:59:40.582Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:124] parse_syn_item_struct_or_enum item_type=ItemType { attrs: [Attribute { pound_token: Pound, style: AttrStyle::Outer, bracket_token: Bracket, meta: Meta::NameValue { path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { sym: doc, span: bytes(7945..7986) }, arguments: PathArguments::None }] }, eq_token: Eq, value: Expr::Lit { attrs: [], lit: Lit::Str { token: " Please refer to `RustOpaque` for doc." } } } }], vis: Visibility::Public(Pub), type_token: Type, ident: Ident { sym: RustOpaqueMoi, span: bytes(8000..8013) }, generics: Generics { lt_token: Some(Lt), params: [GenericParam::Type(TypeParam { attrs: [], ident: Ident { sym: T, span: bytes(8014..8015) }, colon_token: None, bounds: [], eq_token: None, default: None })], gt_token: Some(Gt), where_clause: None }, eq_token: Eq, ty: Type::Path { qself: None, path: Path { leading_colon: Some(PathSep), segments: [PathSegment { ident: Ident { sym: flutter_rust_bridge, span: bytes(8029..8048) }, arguments: PathArguments::None }, PathSep, PathSegment { ident: Ident { sym: for_generated, span: bytes(8050..8063) }, arguments: PathArguments::None }, PathSep, PathSegment { ident: Ident { sym: RustOpaqueBase, span: bytes(8065..8079) }, arguments: PathArguments::AngleBracketed { colon2_token: None, lt_token: Lt, args: [GenericArgument::Type(Type::Path { qself: None, path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { sym: T, span: bytes(8080..8081) }, arguments: PathArguments::None }] } }), Comma, GenericArgument::Type(Type::Path { qself: None, path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { sym: MoiArc, span: bytes(8083..8089) }, arguments: PathArguments::AngleBracketed { colon2_token: None, lt_token: Lt, args: [GenericArgument::Type(Type::Path { qself: None, path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { sym: T, span: bytes(8090..8091) }, arguments: PathArguments::None }] } })], gt_token: Gt } }] } })], gt_token: Gt } }] } }, semi_token: Semi }
[2024-05-07T06:59:40.582Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:124] parse_syn_item_struct_or_enum item_type=ItemType { attrs: [Attribute { pound_token: Pound, style: AttrStyle::Outer, bracket_token: Bracket, meta: Meta::NameValue { path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { sym: doc, span: bytes(8099..8211) }, arguments: PathArguments::None }] }, eq_token: Eq, value: Expr::Lit { attrs: [], lit: Lit::Str { token: " A wrapper to support [arbitrary Rust types](https://cjycode.com/flutter_rust_bridge/guides/types/arbitrary)." } } } }], vis: Visibility::Public(Pub), type_token: Type, ident: Ident { sym: RustOpaque, span: bytes(8225..8235) }, generics: Generics { lt_token: Some(Lt), params: [GenericParam::Type(TypeParam { attrs: [], ident: Ident { sym: T, span: bytes(8236..8237) }, colon_token: None, bounds: [], eq_token: None, default: None })], gt_token: Some(Gt), where_clause: None }, eq_token: Eq, ty: Type::Path { qself: None, path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { sym: RustOpaqueMoi, span: bytes(8241..8254) }, arguments: PathArguments::AngleBracketed { colon2_token: None, lt_token: Lt, args: [GenericArgument::Type(Type::Path { qself: None, path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { sym: T, span: bytes(8255..8256) }, arguments: PathArguments::None }] } })], gt_token: Gt } }] } }, semi_token: Semi }
[2024-05-07T06:59:40.583Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:124] parse_syn_item_struct_or_enum item_type=ItemType { attrs: [Attribute { pound_token: Pound, style: AttrStyle::Outer, bracket_token: Bracket, meta: Meta::NameValue { path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { sym: doc, span: bytes(8313..8358) }, arguments: PathArguments::None }] }, eq_token: Eq, value: Expr::Lit { attrs: [], lit: Lit::Str { token: " Please refer to `RustAutoOpaque` for doc." } } } }], vis: Visibility::Public(Pub), type_token: Type, ident: Ident { sym: RustAutoOpaqueMoi, span: bytes(8372..8389) }, generics: Generics { lt_token: Some(Lt), params: [GenericParam::Type(TypeParam { attrs: [], ident: Ident { sym: T, span: bytes(8390..8391) }, colon_token: None, bounds: [], eq_token: None, default: None })], gt_token: Some(Gt), where_clause: None }, eq_token: Eq, ty: Type::Path { qself: None, path: Path { leading_colon: Some(PathSep), segments: [PathSegment { ident: Ident { sym: flutter_rust_bridge, span: bytes(8405..8424) }, arguments: PathArguments::None }, PathSep, PathSegment { ident: Ident { sym: for_generated, span: bytes(8426..8439) }, arguments: PathArguments::None }, PathSep, PathSegment { ident: Ident { sym: RustAutoOpaqueBase, span: bytes(8441..8459) }, arguments: PathArguments::AngleBracketed { colon2_token: None, lt_token: Lt, args: [GenericArgument::Type(Type::Path { qself: None, path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { sym: T, span: bytes(8460..8461) }, arguments: PathArguments::None }] } }), Comma, GenericArgument::Type(Type::Path { qself: None, path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { sym: MoiArc, span: bytes(8471..8477) }, arguments: PathArguments::AngleBracketed { colon2_token: None, lt_token: Lt, args: [GenericArgument::Type(Type::Path { qself: None, path: Path { leading_colon: Some(PathSep), segments: [PathSegment { ident: Ident { sym: flutter_rust_bridge, span: bytes(8480..8499) }, arguments: PathArguments::None }, PathSep, PathSegment { ident: Ident { sym: for_generated, span: bytes(8501..8514) }, arguments: PathArguments::None }, PathSep, PathSegment { ident: Ident { sym: RustAutoOpaqueInner, span: bytes(8516..8535) }, arguments: PathArguments::AngleBracketed { colon2_token: None, lt_token: Lt, args: [GenericArgument::Type(Type::Path { qself: None, path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { sym: T, span: bytes(8536..8537) }, arguments: PathArguments::None }] } })], gt_token: Gt } }] } })], gt_token: Gt } }] } })], gt_token: Gt } }] } }, semi_token: Semi }
[2024-05-07T06:59:40.584Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:124] parse_syn_item_struct_or_enum item_type=ItemType { attrs: [Attribute { pound_token: Pound, style: AttrStyle::Outer, bracket_token: Bracket, meta: Meta::NameValue { path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { sym: doc, span: bytes(8546..8612) }, arguments: PathArguments::None }] }, eq_token: Eq, value: Expr::Lit { attrs: [], lit: Lit::Str { token: " Usually this is unneeded, and just write down arbitrary types." } } } }, Attribute { pound_token: Pound, style: AttrStyle::Outer, bracket_token: Bracket, meta: Meta::NameValue { path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { sym: doc, span: bytes(8617..8697) }, arguments: PathArguments::None }] }, eq_token: Eq, value: Expr::Lit { attrs: [], lit: Lit::Str { token: " However, when you need arbitrary types at places that are not supported yet," } } } }, Attribute { pound_token: Pound, style: AttrStyle::Outer, bracket_token: Bracket, meta: Meta::NameValue { path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { sym: doc, span: bytes(8702..8748) }, arguments: PathArguments::None }] }, eq_token: Eq, value: Expr::Lit { attrs: [], lit: Lit::Str { token: " use `RustOpaqueOpaque<YourArbitraryType>`." } } } }], vis: Visibility::Public(Pub), type_token: Type, ident: Ident { sym: RustAutoOpaque, span: bytes(8762..8776) }, generics: Generics { lt_token: Some(Lt), params: [GenericParam::Type(TypeParam { attrs: [], ident: Ident { sym: T, span: bytes(8777..8778) }, colon_token: None, bounds: [], eq_token: None, default: None })], gt_token: Some(Gt), where_clause: None }, eq_token: Eq, ty: Type::Path { qself: None, path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { sym: RustAutoOpaqueMoi, span: bytes(8782..8799) }, arguments: PathArguments::AngleBracketed { colon2_token: None, lt_token: Lt, args: [GenericArgument::Type(Type::Path { qself: None, path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { sym: T, span: bytes(8800..8801) }, arguments: PathArguments::None }] } })], gt_token: Gt } }] } }, semi_token: Semi }
[2024-05-07T06:59:40.585Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:101] parse_syn_item_struct_or_enum item_ident=Ident { sym: StreamSink, span: bytes(10457..10467) }                                              
[2024-05-07T06:59:40.585Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:101] parse_syn_item_struct_or_enum item_ident=Ident { sym: FLUTTER_RUST_BRIDGE_HANDLER, span: bytes(13325..13352) }                             
[2024-05-07T06:59:40.586Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:150] parse_syn_item_mod module_path=["crate", "frb_generated", "io"]                                                                            
[2024-05-07T06:59:40.586Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:180] parse_syn_item_mod_contentful module_path=["crate", "frb_generated", "io"]                                                                 
[2024-05-07T06:59:40.587Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:31] parse START info=ModuleInfo { visibility: Inherited, file_path: "\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\frb_generated.rs", module_path: ["crate", "frb_generated", "io"] }
[2024-05-07T06:59:40.587Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:77] parse END info=ModuleInfo { visibility: Inherited, file_path: "\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\frb_generated.rs", module_path: ["crate", "frb_generated", "io"] }
[2024-05-07T06:59:40.588Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:77] parse END info=ModuleInfo { visibility: Inherited, file_path: "\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\frb_generated.rs", module_path: ["crate", "frb_generated"] }
[2024-05-07T06:59:40.589Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\source_graph\module_parser.rs:77] parse END info=ModuleInfo { visibility: Public, file_path: "\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust\\src\\lib.rs", module_path: ["crate"] }
[2024-05-07T06:59:40.592Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\function_parser\mod.rs:70] parse_function function name: Ident { sym: greet, span: bytes(76..81) }
[2024-05-07T06:59:40.592Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\function_parser\mod.rs:70] parse_function function name: Ident { sym: init_app, span: bytes(305..313) }                                                                       
[2024-05-07T06:59:40.593Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\function_parser\mod.rs:70] parse_function function name: Ident { sym: new, span: bytes(482..485) }                                                                            
[2024-05-07T06:59:40.593Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\type_parser\enum_or_struct.rs:61] Treat SimpleApi as opaque by compute_default_opaque                                                                                         
[2024-05-07T06:59:40.595Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\type_parser\enum_or_struct.rs:61] Treat SimpleApi as opaque by compute_default_opaque                                                                                         
[2024-05-07T06:59:40.595Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\codegen\parser\type_parser\enum_or_struct.rs:61] Treat SimpleApi as opaque by compute_default_opaque                                                                                         
[2024-05-07T06:59:40.601Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\commands\format_dart.rs:13] execute format_dart paths=["lib\\src\\rust\\api\\simple.dart", "lib\\src\\rust\\frb_generated.dart", "lib\\src\\rust\\frb_generated.io.dart", "lib\\src\\rust\\frb_generated.web.dart"] line_length=80                                                                                                                                          
[2024-05-07T06:59:40.603Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\commands\command_runner.rs:129] execute command: bin=powershell args="-noprofile -command & \"dart\" \"format\" \"--line-length\" \"80\" \"lib\\\\src\\\\rust\\\\api\\\\simple.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.io.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.web.dart\"" current_dir=Some("\\\\?\\D:\\Entwicklung\\Flutter\\my_app") cmd="powershell" "-noprofile" "-command" "& \"dart\" \"format\" \"--line-length\" \"80\" \"lib\\\\src\\\\rust\\\\api\\\\simple.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.io.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.web.dart\""                                                     
[2024-05-07T06:59:41.319Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\commands\command_runner.rs:140] command="powershell" "-noprofile" "-command" "& \"dart\" \"format\" \"--line-length\" \"80\" \"lib\\\\src\\\\rust\\\\api\\\\simple.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.io.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.web.dart\"" stdout=Formatted lib\\src\\rust\\api\\simple.dart  
Formatted lib\\src\\rust\\frb_generated.dart
Formatted lib\\src\\rust\\frb_generated.io.dart
Formatted lib\\src\\rust\\frb_generated.web.dart
Formatted 4 files (4 changed) in 0.25 seconds.
 stderr=
[2024-05-07T06:59:41.320Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\commands\format_rust.rs:9] execute format_rust paths=["src\\frb_generated.rs", "src\\frb_generated.io.rs", "src\\frb_generated.web.rs"]                                                      
[2024-05-07T06:59:41.321Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\commands\command_runner.rs:129] execute command: bin=powershell args="-noprofile -command & \"rustfmt\" \"--edition\" \"2018\" \"src\\\\frb_generated.rs\" \"src\\\\frb_generated.io.rs\" \"src\\\\frb_generated.web.rs\"" current_dir=Some("\\\\?\\D:\\Entwicklung\\Flutter\\my_app\\rust") cmd="powershell" "-noprofile" "-command" "& \"rustfmt\" \"--edition\" \"2018\" \"src\\\\frb_generated.rs\" \"src\\\\frb_generated.io.rs\" \"src\\\\frb_generated.web.rs\""                                                                                    
[2024-05-07T06:59:41.653Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\commands\command_runner.rs:140] command="powershell" "-noprofile" "-command" "& \"rustfmt\" \"--edition\" \"2018\" \"src\\\\frb_generated.rs\" \"src\\\\frb_generated.io.rs\" \"src\\\\frb_generated.web.rs\"" stdout= stderr=
[2024-05-07T06:59:41.654Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\utils\dart_repository\dart_repo.rs:22] Guessing toolchain the runner is run into                                                                                                             
[2024-05-07T06:59:41.655Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\utils\dart_repository\dart_repo.rs:71] Checking presence of flutter_rust_bridge in dependencies at \\?\D:\Entwicklung\Flutter\my_app                                                         
[2024-05-07T06:59:41.656Z DEBUG C:\Users\[name]\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.33\src\library\utils\dart_repository\dart_repo.rs:103] Checking presence of flutter_rust_bridge in dependencies at \\?\D:\Entwicklung\Flutter\my_app                                                        
[3.5s] Parse                                                                                                                                                                   
  └── [3.2s] Run cargo expand                                                                                                                                                  
  └── [0.2s] Parse source graph                                                                                                                                                
[0.0s] Generate                                                                                                                                                                
[1.1s] Polish                                                                                                                                                                  
  └── [0.7s] Run Dart formatter                                                                                                                                                
  └── [0.3s] Run Rust formatter                                                                                                                                                
  └── [0.0s] Auto upgrade                                                                                                                                                      
Done!

What kind of reproducible sample do you need? Are my steps not sufficient?

And by the way. I've noticed that generate --watch doesn't seem to create any new files when I add a new Rust file. I have to restart generate

fzyzcjy commented 3 weeks ago

What kind of reproducible sample do you need? Are my steps not sufficient?

I must have been too tired and did not realize your full reproducible steps! I will check it now.

fzyzcjy commented 3 weeks ago

I cannot reproduce it, both have same hash:

(base) ➜  my_app cat rust/src/frb_generated.rs | grep HASH
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = 1147114678;
(base) ➜  my_app cat lib/src/rust/frb_generated.dart | grep ContentHash
  int get rustContentHash => 1147114678;

Could you please try to run generate again and flutter run?

dm107 commented 3 weeks ago

I have the same hash, so the my error confused me. (A hash error is still being reported) Now I have recreated the project and found the reason. It occurs when executing flutter run Its due openSSL

SEVERE: ================================================================================
SEVERE: Cargokit BuildTool failed with error:
SEVERE: --------------------------------------------------------------------------------
SEVERE: External Command: rustup "run" "stable" "cargo" "build" "--manifest-path" "D:\Entwicklung\Flutter\new_app\rust\Cargo.toml" "-p" "rust_lib_new_app" "--target" "x86_64-linux-android" "--target-dir" "D:\Entwicklung\Flutter\new_app\build\rust_lib_new_app/build"
SEVERE: Returned Exit Code: 101
SEVERE: --------------------------------------------------------------------------------
SEVERE: STDOUT:
SEVERE: --------------------------------------------------------------------------------
SEVERE: STDERR:
SEVERE: Compiling openssl-sys v0.9.102
SEVERE:    Compiling futures-util v0.3.29
SEVERE:    Compiling pin-project v1.1.5
SEVERE: error: failed to run custom build command for `openssl-sys v0.9.102`
SEVERE:
SEVERE: Caused by:
SEVERE:   process didn't exit successfully: `D:\Entwicklung\Flutter\new_app\build\rust_lib_new_app/build\debug\build\openssl-sys-5f76f1108c33e524\build-script-main` (exit code:

My standalone Rust is working, I need to find out why... So I think its not a flutter_rust_bridge problem.

fzyzcjy commented 3 weeks ago

I see, then it looks like maybe e.g. cargokit does not stop flutter run under compilation error.

So I think its not a flutter_rust_bridge problem.

Totally agree!

github-actions[bot] commented 1 week ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.