wang-bin / fvp

Flutter video player plugin for all desktop+mobile platforms. download prebuilt examples from github actions. https://pub.dev/packages/fvp
BSD 3-Clause "New" or "Revised" License
197 stars 31 forks source link

Building with --wasm fails when using fvp #97

Closed uldall closed 5 months ago

uldall commented 5 months ago

Describe the bug Using the following command to build for Web fails when fvp is used: flutter build web --wasm

Expected behavior The build succeeds.

Log

$ flutter build web --wasm

┌─ New feature ────────────────────────────────────────────────────────────────────────────┐
│   WebAssembly compilation is new. Understand the details before deploying to production. │
│   See https://flutter.dev/wasm for more information.                                     │
└──────────────────────────────────────────────────────────────────────────────────────────┘

Warning: In index.html:26: Local variable for "serviceWorkerVersion" is deprecated. Use "{{flutter_service_worker_version}}" template token instead.
Warning: In index.html:46: "FlutterLoader.loadEntrypoint" is deprecated. Use "FlutterLoader.load" instead.
Target dart2wasm failed: ProcessException: Process exited abnormally with exit code 64:
*NOTE*: Compilation to WasmGC is experimental.
The support may change, or be removed, with no advance notice.

Unhandled exception:
Constant InstanceConstant(const _FfiAbiSpecificMapping{_FfiAbiSpecificMapping.nativeTypes: const <Type?>[Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32,
Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32]}) references field _FfiAbiSpecificMapping.nativeTypes which is not retained
#0      _TreeShakerConstantVisitor.visitInstanceConstant.<anonymous closure> (package:vm/transformations/type_flow/transformer.dart:2257)
#1      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633)
#2      _TreeShakerConstantVisitor.visitInstanceConstant (package:vm/transformations/type_flow/transformer.dart:2255)
#3      InstanceConstant.accept (package:kernel/ast.dart:14144)
#4      _TreeShakerConstantVisitor.analyzeConstant (package:vm/transformations/type_flow/transformer.dart:2190)
#5      _TreeShakerConstantVisitor.visitInstanceConstant.<anonymous closure> (package:vm/transformations/type_flow/transformer.dart:2260)
#6      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633)
#7      _TreeShakerConstantVisitor.visitInstanceConstant (package:vm/transformations/type_flow/transformer.dart:2255)
#8      InstanceConstant.accept (package:kernel/ast.dart:14144)
#9      _TreeShakerConstantVisitor.analyzeConstant (package:vm/transformations/type_flow/transformer.dart:2190)
#10     _TreeShakerPass1.visitConstant (package:vm/transformations/type_flow/transformer.dart:1558)
#11     ConstantExpression.transformOrRemoveChildren (package:kernel/ast.dart:8723)
#12     RemovingTransformer.defaultTreeNode (package:kernel/visitor.dart:2164)
#13     TreeVisitor1Default.defaultExpression (package:kernel/visitor.dart:739)
#14     ExpressionVisitor1DefaultMixin.visitConstantExpression (package:kernel/visitor.dart:2368)
#15     ConstantExpression.accept1 (package:kernel/ast.dart:8707)
#16     RemovingTransformer.transformOrRemove (package:kernel/visitor.dart:1917)
#17     RemovingTransformer.transformList (package:kernel/visitor.dart:2141)
#18     RemovingTransformer.transformExpressionList (package:kernel/visitor.dart:2067)
#19     TreeShaker.addClassUsedInType (package:vm/transformations/type_flow/transformer.dart:878)
#20     _TreeShakerTypeVisitor.visitInterfaceType (package:vm/transformations/type_flow/transformer.dart:1098)
#21     InterfaceType.accept (package:kernel/ast.dart:11536)
#22     visitList (package:kernel/ast.dart:14913)
#23     FunctionType.visitChildren (package:kernel/ast.dart:11646)
#24     RecursiveVisitor.defaultNode (package:kernel/visitor.dart:1725)
#25     VisitorDefaultMixin.visitSupertype (package:kernel/visitor.dart:1501)
#26     DartTypeVisitorDefaultMixin.visitInvalidType (package:kernel/visitor.dart:781)
#27     FunctionType.accept (package:kernel/ast.dart:11637)
#28     visitList (package:kernel/ast.dart:14913)
#29     InterfaceType.visitChildren (package:kernel/ast.dart:11545)
#30     _TreeShakerTypeVisitor.visitInterfaceType (package:vm/transformations/type_flow/transformer.dart:1099)
#31     InterfaceType.accept (package:kernel/ast.dart:11536)
#32     visitList (package:kernel/ast.dart:14913)
#33     InterfaceType.visitChildren (package:kernel/ast.dart:11545)
#34     _TreeShakerTypeVisitor.visitInterfaceType (package:vm/transformations/type_flow/transformer.dart:1099)
#35     InterfaceType.accept (package:kernel/ast.dart:11536)
#36     _TreeShakerPass1.visitDartType (package:vm/transformations/type_flow/transformer.dart:1247)
#37     VariableDeclaration.transformOrRemoveChildren (package:kernel/ast.dart:10817)
#38     RemovingTransformer.defaultTreeNode (package:kernel/visitor.dart:2164)
#39     TreeVisitor1Default.defaultExpression (package:kernel/visitor.dart:739)
#40     StatementVisitor1DefaultMixin.visitVariableDeclaration (package:kernel/visitor.dart:2597)
#41     VariableDeclaration.accept1 (package:kernel/ast.dart:10795)
#42     RemovingTransformer.transformOrRemove (package:kernel/visitor.dart:1917)
#43     RemovingTransformer.transformList (package:kernel/visitor.dart:2141)
#44     RemovingTransformer.transformStatementList (package:kernel/visitor.dart:2095)
#45     AssertBlock.transformOrRemoveChildren (package:kernel/ast.dart:9311)
#46     RemovingTransformer.defaultTreeNode (package:kernel/visitor.dart:2164)
#47     TreeVisitor1Default.defaultExpression (package:kernel/visitor.dart:739)
#48     StatementVisitor1DefaultMixin.visitBlock (package:kernel/visitor.dart:2546)
#49     Block.accept1 (package:kernel/ast.dart:9250)
#50     RemovingTransformer.transform (package:kernel/visitor.dart:1881)
#51     BlockExpression.transformOrRemoveChildren (package:kernel/ast.dart:8853)
#52     RemovingTransformer.defaultTreeNode (package:kernel/visitor.dart:2164)
#53     TreeVisitor1Default.defaultExpression (package:kernel/visitor.dart:739)
#54     ExpressionVisitor1DefaultMixin.visitBlockExpression (package:kernel/visitor.dart:2402)
#55     BlockExpression.accept1 (package:kernel/ast.dart:8835)
#56     RemovingTransformer.transformOrRemove (package:kernel/visitor.dart:1917)
#57     RemovingTransformer.transformOrRemoveExpression (package:kernel/visitor.dart:1890)
#58     Field.transformOrRemoveChildren (package:kernel/ast.dart:2559)
#59     _TreeShakerPass1.visitField (package:vm/transformations/type_flow/transformer.dart:1319)
#60     Field.accept1 (package:kernel/ast.dart:2530)
#61     RemovingTransformer.transformOrRemove (package:kernel/visitor.dart:1917)
#62     RemovingTransformer.transformList (package:kernel/visitor.dart:2141)
#63     RemovingTransformer.transformFieldList (package:kernel/visitor.dart:2041)
#64     _TreeShakerPass1.visitClass (package:vm/transformations/type_flow/transformer.dart:1285)
#65     Class.accept1 (package:kernel/ast.dart:1472)
#66     RemovingTransformer.transformOrRemove (package:kernel/visitor.dart:1917)
#67     RemovingTransformer.transformList (package:kernel/visitor.dart:2141)
#68     RemovingTransformer.transformClassList (package:kernel/visitor.dart:1996)
#69     Library.transformOrRemoveChildren (package:kernel/ast.dart:622)
#70     RemovingTransformer.defaultTreeNode (package:kernel/visitor.dart:2164)
#71     TreeVisitor1DefaultMixin.visitLibrary (package:kernel/visitor.dart:680)
#72     Library.accept1 (package:kernel/ast.dart:588)
#73     RemovingTransformer.transformOrRemove (package:kernel/visitor.dart:1917)
#74     RemovingTransformer.transformList (package:kernel/visitor.dart:2141)
#75     RemovingTransformer.transformLibraryList (package:kernel/visitor.dart:1960)
#76     Component.transformOrRemoveChildren (package:kernel/ast.dart:14779)
#77     _TreeShakerPass1.transformComponent (package:vm/transformations/type_flow/transformer.dart:1156)
#78     TreeShaker.transformComponent (package:vm/transformations/type_flow/transformer.dart:831)
#79     transformComponent (package:vm/transformations/type_flow/transformer.dart:134)
#80     compileToModule (package:dart2wasm/compile.dart:156)
<asynchronous suspension>
#81     generateWasm (package:dart2wasm/generate_wasm.dart:24)
<asynchronous suspension>
#82     main (file:///b/s/w/ir/x/w/sdk/pkg/dart2wasm/bin/dart2wasm.dart:10)
<asynchronous suspension>
  Command: /home/uldall/git/flutter/bin/cache/dart-sdk/bin/dart compile wasm --packages=.dart_tool/package_config.json
  --extra-compiler-option=--dart-sdk=/home/uldall/git/flutter/bin/cache/dart-sdk
  --extra-compiler-option=--platform=/home/uldall/git/flutter/bin/cache/flutter_web_sdk/kernel/dart2wasm_platform.dill --extra-compiler-option=--delete-tostring-package-uri=dart:ui
  --extra-compiler-option=--delete-tostring-package-uri=package:flutter --extra-compiler-option=--import-shared-memory --extra-compiler-option=--shared-memory-max-pages=32768
  -Ddart.vm.product=true -DFLUTTER_WEB_CANVASKIT_URL=https://www.gstatic.com/flutter-canvaskit/55eae6864b296dd9f43b2cc7577ec256e5c32a8d/ -DFLUTTER_WEB_AUTO_DETECT=false
  -DFLUTTER_WEB_USE_SKIA=false -DFLUTTER_WEB_USE_SKWASM=true
  --extra-compiler-option=--depfile=/home/uldall/git/zoolander/.dart_tool/flutter_build/5c5fce35a7df90664eb2e1ee3b00fbe6/dart2wasm.d -O4 --no-name-section -o
  /home/uldall/git/zoolander/.dart_tool/flutter_build/5c5fce35a7df90664eb2e1ee3b00fbe6/main.dart.wasm
  /home/uldall/git/zoolander/.dart_tool/flutter_build/5c5fce35a7df90664eb2e1ee3b00fbe6/main.dart
#0      RunResult.throwException (package:flutter_tools/src/base/process.dart:125:5)
#1      _DefaultProcessUtils.run (package:flutter_tools/src/base/process.dart:321:19)
<asynchronous suspension>
#2      Dart2WasmTarget.build (package:flutter_tools/src/build_system/targets/web.dart:329:5)
<asynchronous suspension>
#3      _BuildInstance._invokeInternal (package:flutter_tools/src/build_system/build_system.dart:875:9)
<asynchronous suspension>
#4      Future.wait.<anonymous closure> (dart:async/future.dart:524:21)
<asynchronous suspension>
#5      _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:813:32)
<asynchronous suspension>
#6      Future.wait.<anonymous closure> (dart:async/future.dart:524:21)
<asynchronous suspension>
#7      _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:813:32)
<asynchronous suspension>
#8      FlutterBuildSystem.build (package:flutter_tools/src/build_system/build_system.dart:642:16)
<asynchronous suspension>
#9      WebBuilder.buildWeb (package:flutter_tools/src/web/compile.dart:92:34)
<asynchronous suspension>
#10     BuildWebCommand.runCommand (package:flutter_tools/src/commands/build_web.dart:230:5)
<asynchronous suspension>
#11     FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1394:27)
<asynchronous suspension>
#12     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#13     CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#14     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:372:9)
<asynchronous suspension>
#15     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#16     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:308:5)
<asynchronous suspension>
#17     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:130:9)
<asynchronous suspension>
#18     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#19     main (package:flutter_tools/executable.dart:93:3)
<asynchronous suspension>

Compiling lib/main.dart for the Web...                             29.5s
Error: Failed to compile application for the Web.
uldall commented 5 months ago

I suspect that ffi is somehow incorrectly imported/used even for the web build.

uldall commented 5 months ago

See this comment: https://github.com/dart-lang/sdk/issues/55763#issuecomment-2137201725

wang-bin commented 5 months ago

try master branch

uldall commented 5 months ago

I changed my fvp dependency to:

  fvp:
    git:
      url: https://github.com/wang-bin/fvp.git
      ref: 680c2523447928bc70e587893b5c775b4c4b56c2

and it solved the issue. Thank you!

wang-bin commented 5 months ago

new version released