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

Package not working with Flutter 3.24.0 #31

Closed
pepealonso95 opened this issue Aug 9, 2024 · 8 comments · Fixed by #32
Closed

Package not working with Flutter 3.24.0 #31

pepealonso95 opened this issue Aug 9, 2024 · 8 comments · Fixed by #32

Comments

@pepealonso95
Copy link

Seems like js_util is giving issues where the package is no longer compatible with Flutter's latest release.

Target dart2js failed: ProcessException: Process exited abnormally with exit code 253:
           .dart_tool/flutter_build/b7629c0c1f24a1cdb3a354a01092bc2f/main.dart:
           Internal Error: The compiler crashed when compiling this element.
           
           The compiler is broken.
           
           When compiling the above element, the compiler crashed. It is not
           possible to tell if this is caused by a problem in your program or
           not. Regardless, the compiler should not crash.
           
           The Dart team would greatly appreciate if you would take a moment to
           report this problem at http://dartbug.com/new.
           
           Please include the following information:
           
           * the name and version of your operating system,
           
           * the Dart SDK build number (3.5.0), and
           
           * the entire message you see here (including the full stack trace
             below as well as the source location above).
           
           The compiler crashed: Crash when compiling:
           type 'InterfaceType' is not a subtype of type 'FunctionType' in type cast
           
           #0      JsUtilOptimizer._lowerFunctionToJS (package:_js_interop_checks/src/transformations/js_util_optimizer.dart:698:52)
           #1      JsUtilOptimizer.visitStaticInvocation (package:_js_interop_checks/src/transformations/js_util_optimizer.dart:502:20)
           #2      StaticInvocation.accept (package:kernel/ast.dart:6582:44)
           #3      Transformer.transform (package:kernel/visitor.dart:1771:17)
           #4      InstanceSet.transformChildren (package:kernel/ast.dart:4853:15)
           #5      Transformer.defaultTreeNode (package:kernel/visitor.dart:1805:10)
           #6      TreeVisitorDefault.defaultExpression (package:kernel/visitor.dart:618:43)
           #7      ExpressionVisitorDefaultMixin.visitInstanceSet (package:kernel/visitor.dart:109:43)
           #8      InstanceSet.accept (package:kernel/ast.dart:4835:44)
           #9      Transformer.transform (package:kernel/visitor.dart:1771:17)
           #10     ExpressionStatement.transformChildren (package:kernel/ast.dart:9141:20)
           #11     Transformer.defaultTreeNode (package:kernel/visitor.dart:1805:10)
           #12     TreeVisitorDefault.defaultStatement (package:kernel/visitor.dart:622:41)
           #13     StatementVisitorDefaultMixin.visitExpressionStatement (package:kernel/visitor.dart:343:7)
           #14     ExpressionStatement.accept (package:kernel/ast.dart:9128:43)
           #15     Transformer.transform (package:kernel/visitor.dart:1771:17)
           #16     Transformer.transformList (package:kernel/visitor.dart:1788:18)
           #17     Block.transformChildren (package:kernel/ast.dart:9193:7)
           #18     Transformer.defaultTreeNode (package:kernel/visitor.dart:1805:10)
           #19     TreeVisitorDefault.defaultStatement (package:kernel/visitor.dart:622:41)
           #20     StatementVisitorDefaultMixin.visitBlock (package:kernel/visitor.dart:345:31)
           #21     Block.accept (package:kernel/ast.dart:9181:43)
           #22     Transformer.transform (package:kernel/visitor.dart:1771:17)
           #23     FunctionNode.transformChildren (package:kernel/ast.dart:3905:16)
           #24     Transformer.defaultTreeNode (package:kernel/visitor.dart:1805:10)
           #25     TreeVisitorDefaultMixin.visitFunctionNode (package:kernel/visitor.dart:577:45)
           #26     FunctionNode.accept (package:kernel/ast.dart:3872:38)
           #27     Transformer.transform (package:kernel/visitor.dart:1771:17)
           #28     Constructor.transformChildren (package:kernel/ast.dart:2693:18)
           #29     JsUtilOptimizer.defaultMember (package:_js_interop_checks/src/transformations/js_util_optimizer.dart:143:10)
           #30     MemberVisitorDefaultMixin.visitConstructor (package:kernel/visitor.dart:409:43)
           #31     Constructor.accept (package:kernel/ast.dart:2671:40)
           #32     Transformer.transform (package:kernel/visitor.dart:1771:17)
           #33     Transformer.transformList (package:kernel/visitor.dart:1788:18)
           #34     Class.transformChildren (package:kernel/ast.dart:1524:7)
           #35     Transformer.defaultTreeNode (package:kernel/visitor.dart:1805:10)
           #36     TreeVisitorDefaultMixin.visitClass (package:kernel/visitor.dart:556:31)
           #37     Class.accept (package:kernel/ast.dart:1471:38)
           #38     Transformer.transform (package:kernel/visitor.dart:1771:17)
           #39     Transformer.transformList (package:kernel/visitor.dart:1788:18)
           #40     Library.transformChildren (package:kernel/ast.dart:609:7)
           #41     JsUtilOptimizer.visitLibrary (package:_js_interop_checks/src/transformations/js_util_optimizer.dart:135:10)
           #42     Dart2jsTarget.performModularTransformationsOnLibraries (package:compiler/src/kernel/dart2js_target.dart:169:25)
           #43     KernelTarget.runBuildTransformations (package:front_end/src/kernel/kernel_target.dart:1724:19)
           #44     KernelTarget.buildComponent.<anonymous closure> (package:front_end/src/kernel/kernel_target.dart:770:7)
           <asynchronous suspension>
           #45     withCrashReporting (package:front_end/src/base/crash.dart:138:12)
           <asynchronous suspension>
           #46     KernelTarget.buildComponent (package:front_end/src/kernel/kernel_target.dart:699:12)
           <asynchronous suspension>
           #47     _buildInternal (package:front_end/src/kernel_generator_impl.dart:239:19)
           <asynchronous suspension>
           #48     withCrashReporting (package:front_end/src/base/crash.dart:138:12)
           <asynchronous suspension>
           #49     compile.<anonymous closure> (package:front_end/src/api_unstable/dart2js.dart:165:37)
           <asynchronous suspension>
           #50     CompilerContext.clear (package:front_end/src/base/compiler_context.dart:128:3)
           <asynchronous suspension>
           #51     compile (package:front_end/src/api_unstable/dart2js.dart:163:36)
           <asynchronous suspension>
           #52     _loadFromSource (package:compiler/src/phase/load_kernel.dart:318:29)
           <asynchronous suspension>
           #53     run (package:compiler/src/phase/load_kernel.dart:412:36)
           <asynchronous suspension>
           #54     Compiler.loadKernel (package:compiler/src/compiler.dart:392:9)
           <asynchronous suspension>
           #55     Compiler.produceKernel (package:compiler/src/compiler.dart:399:36)
           <asynchronous suspension>
           #56     Compiler.runSequentialPhases (package:compiler/src/compiler.dart:633:20)
           <asynchronous suspension>
           #57     Compiler.runInternal.<anonymous closure> (package:compiler/src/compiler.dart:316:7)
           <asynchronous suspension>
           #58     Compiler.runInternal (package:compiler/src/compiler.dart:315:5)
           <asynchronous suspension>
           #59     Compiler.run.<anonymous closure> (package:compiler/src/compiler.dart:236:11)
           <asynchronous suspension>
           #60     compile.<anonymous closure> (package:compiler/compiler_api.dart:256:30)
           <asynchronous suspension>
           #61     compile.compilationDone (package:compiler/src/dart2js.dart:723:3)
           <asynchronous suspension>
           #62     main (package:compiler/src/dart2js.dart:1226:3)
           <asynchronous suspension>
@pepealonso95
Copy link
Author

tried changing all instances from js_util to js_interop with .toDart but still no luck to get this working with flutter 3.24.0

@xvrh
Copy link
Owner

xvrh commented Aug 12, 2024

😥
It's really a shame that the error message doesn't explain at all what's going on. It may be worth opening a ticket in the dart sdk issue tracker. I we can understand exactly which code is wrong it would help a lot.
I would really like to find a fix for that, unfortunately I personally won't have time to dig a lot into this.

@xvrh
Copy link
Owner

xvrh commented Aug 12, 2024

I opened dart-lang/sdk#56443 hopefully we will get a pointer to the incorrect pattern we use.

@jarrodcolburn
Copy link
Contributor

jarrodcolburn commented Aug 13, 2024

I think the fix to this is going to include refactoring to extenion types specifically on JSObject as suggested in #24
(and incorporating the transition from dart:js_util to dart:js_interop as mentioned in #28) and outlined in https://dart.dev/interop/js-interop/mock. I know that would take a rewrite of how this package is generated from IDL, but now that dart has macros it might be an easier lift.

@xvrh
Copy link
Owner

xvrh commented Aug 13, 2024

@jarrodcolburn we can tweak the generated code as necessary. The problem currently is that the error message doesn't tell us at all what to change.
If someone can manually tweak the generated code and make it pass the compiler, I can adapt the generator myself.

@michaelhly
Copy link

@xvrh here is the compile error:

  Exception: Error when compiling JS (1).
  lib/src/internal_helpers.dart:120:68:
  Error: `Function.toJS` requires a statically known function type, but Type 'Function' is not a precise function type, e.g., `void Function()`.
   - 'Function' is from 'dart:core'.
      _callback = allowInterop(callbackFactory(_wrapZone(_addData))).toJS;
                                                                     ^
  Error: Compilation failed.
  
  
  test/runner/runner.dart 118:5  _compileJs
  ===== asynchronous gap ===========================
  test/runner/runner.dart 76:5   runTests
  

@michaelhly
Copy link

I see that theEventStream class in

class EventStream<T> extends Stream<T> {

is out of date compared to
https://github.com/dart-lang/web/blob/4996dc2acd30ff06f7e500ec76fde8a66db82c0c/lib/src/helpers/events/streams.dart#L106

Perhaps the codgen needs to migrate to package:web?

@xvrh xvrh mentioned this issue Aug 16, 2024
@xvrh xvrh closed this as completed in #32 Aug 16, 2024
@xvrh xvrh closed this as completed in 17d379a Aug 16, 2024
@xvrh
Copy link
Owner

xvrh commented Aug 16, 2024

Thank you @michaelhly for the pointer to what was wrong.
I published v0.4.0 to fix the issue with Dart 3.5 & Flutter 3.24

We were lucky this time, the change was not too big. At some point to support wasm we will probably need to change more stuff in the js binding code.

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 a pull request may close this issue.

4 participants