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.74k stars 267 forks source link

Rust can't calls Dart in debug mode on web since dev.39 #2183

Open svr2kos2 opened 2 days ago

svr2kos2 commented 2 days ago

Describe the bug

call a dart function from rust cause error.

Steps to reproduce

Follow manul https://cjycode.com/flutter_rust_bridge/guides/direction/rust-call-dart

Logs

Error
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 296:3   throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 29:3    assertFailed
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart 120:59   assertInterop
dart-sdk/lib/_internal/js_dev_runtime/private/js_helper.dart 835:31           assertInterop$
dart-sdk/lib/_internal/js_dev_runtime/private/js_array.dart 212:7             forEach]
dart-sdk/lib/_internal/js_dev_runtime/private/js_helper.dart 840:51           assertInteropArgs
dart-sdk/lib/_internal/js_shared/lib/js_util_patch.dart 109:3                 callMethod$
packages/flutter_rust_bridge/src/generalized_frb_rust_binding/_web.dart 56:7  dartOpaqueDart2RustEncode
packages/flutter_rust_bridge/src/dart_opaque/_common.dart 16:35               encodeDartOpaque
packages/frbv2_test/src/rust/frb_generated.dart 320:50                        sse_encode_DartOpaque
packages/frbv2_test/src/rust/frb_generated.dart 311:5                         sse_encode_DartFn_Inputs_String_Output_String_AnyhowException
packages/frbv2_test/src/rust/frb_generated.dart 140:9                         <fn>
packages/flutter_rust_bridge/src/main_components/handler.dart 16:17           executeNormal
packages/frbv2_test/src/rust/frb_generated.dart 137:20                        crateApiSimpleRustFunction
packages/frbv2_test/src/rust/api/simple.dart 14:26                            rustFunction
packages/frbv2_test/main.dart 30:11                                           callback_test
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54            runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5            _async
packages/frbv2_test/main.dart 29:21                                           callback_test
packages/frbv2_test/main.dart 17:5                                            build
packages/flutter/src/widgets/framework.dart 5557:22                           build
packages/flutter/src/widgets/framework.dart 5487:15                           performRebuild
packages/flutter/src/widgets/framework.dart 5203:7                            rebuild
packages/flutter/src/widgets/framework.dart 5469:5                            [_firstBuild]
packages/flutter/src/widgets/framework.dart 5463:5                            mount
packages/flutter/src/widgets/framework.dart 4340:15                           inflateWidget
packages/flutter/src/widgets/framework.dart 3849:18                           updateChild
packages/flutter/src/widgets/framework.dart 5512:16                           performRebuild
packages/flutter/src/widgets/framework.dart 5203:7                            rebuild
packages/flutter/src/widgets/framework.dart 5469:5                            [_firstBuild]
packages/flutter/src/widgets/framework.dart 5463:5                            mount
packages/flutter/src/widgets/framework.dart 4340:15                           inflateWidget
packages/flutter/src/widgets/framework.dart 3849:18                           updateChild
packages/flutter/src/widgets/framework.dart 5512:16                           performRebuild
packages/flutter/src/widgets/framework.dart 5650:11                           performRebuild
packages/flutter/src/widgets/framework.dart 5203:7                            rebuild
packages/flutter/src/widgets/framework.dart 5469:5                            [_firstBuild]
packages/flutter/src/widgets/framework.dart 5641:11                           [_firstBuild]
packages/flutter/src/widgets/framework.dart 5463:5                            mount
packages/flutter/src/widgets/framework.dart 4340:15                           inflateWidget
packages/flutter/src/widgets/framework.dart 3849:18                           updateChild
packages/flutter/src/widgets/framework.dart 5512:16                           performRebuild
packages/flutter/src/widgets/framework.dart 5203:7                            rebuild
packages/flutter/src/widgets/framework.dart 5469:5                            [_firstBuild]
packages/flutter/src/widgets/framework.dart 5463:5                            mount
packages/flutter/src/widgets/framework.dart 4340:15                           inflateWidget
packages/flutter/src/widgets/framework.dart 3849:18                           updateChild
packages/flutter/src/widgets/framework.dart 5512:16                           performRebuild
packages/flutter/src/widgets/framework.dart 5203:7                            rebuild
packages/flutter/src/widgets/framework.dart 5469:5                            [_firstBuild]
packages/flutter/src/widgets/framework.dart 5463:5                            mount
packages/flutter/src/widgets/framework.dart 4340:15                           inflateWidget
packages/flutter/src/widgets/framework.dart 3849:18                           updateChild
packages/flutter/src/widgets/view.dart 291:16                                 [_updateChild]
packages/flutter/src/widgets/view.dart 314:5                                  mount
packages/flutter/src/widgets/framework.dart 4340:15                           inflateWidget
packages/flutter/src/widgets/framework.dart 3849:18                           updateChild
packages/flutter/src/widgets/framework.dart 5512:16                           performRebuild
packages/flutter/src/widgets/framework.dart 5203:7                            rebuild
packages/flutter/src/widgets/framework.dart 5469:5                            [_firstBuild]
packages/flutter/src/widgets/framework.dart 5463:5                            mount
packages/flutter/src/widgets/framework.dart 4340:15                           inflateWidget
packages/flutter/src/widgets/framework.dart 3849:18                           updateChild
packages/flutter/src/widgets/binding.dart 1581:16                             [_rebuild]
packages/flutter/src/widgets/binding.dart 1550:5                              mount
packages/flutter/src/widgets/binding.dart 1503:16                             <fn>
packages/flutter/src/widgets/framework.dart 2845:11                           buildScope
packages/flutter/src/widgets/binding.dart 1502:12                             attach
packages/flutter/src/widgets/binding.dart 1239:26                             attachToBuildOwner
packages/flutter/src/widgets/binding.dart 1221:5                              attachRootWidget
packages/flutter/src/widgets/binding.dart 1207:7                              <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/isolate_helper.dart 48:11       internalCallback

Expected behavior

works normally like dev.38

Generated binding code

No response

OS

Win 22631.2428

Version of flutter_rust_bridge_codegen

v2.0.0-dev.39~v2.0.0

Flutter info

• Flutter version 3.22.2 on channel stable at C:\workspace\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 761747bfc5 (4 weeks ago), 2024-06-05 22:15:13 +0200
    • Engine revision edd8546116
    • Dart version 3.4.3
    • DevTools version 2.34.3  

• Chrome (web)      • chrome  • web-javascript • Google Chrome 126.0.6478.127
• Edge (web)        • edge    • web-javascript • Microsoft Edge 126.0.2592.87

Version of clang++

No response

Additional context

No response

fzyzcjy commented 2 days ago

Hi, could you please provide a minimal reproducible sample? The tests are run in CI for every commit, which seems to pass.

svr2kos2 commented 2 days ago

rust_call_dart Only modified main.dart and simple.rs

And I just found out that build and run with release mode is totally fine. Only crash on debug mode.

fzyzcjy commented 2 days ago

Great, feel free to PR (I am happy to provide hints about debugging), alternatively I will work on it in the next batch!

svr2kos2 commented 2 days ago

Saddly I'm not familiar with flutter and js, I‘ll first try to figure out how this works. Thanks for your contribution to this awesome project❤️

fzyzcjy commented 2 days ago

You are welcome and it's OK!

fzyzcjy commented 2 days ago

Btw for completeness (I guess you already know it): The workaround is to use dev.38 before it is fixed.