xvrh / lottie-flutter

Render After Effects animations natively on Flutter. This package is a pure Dart implementation of a Lottie player.
https://pub.dev/packages/lottie
MIT License
1.16k stars 196 forks source link

Dart compiler error on _drawFontTextLine in text_layer.dart #264

Closed Aqua-Ye closed 1 year ago

Aqua-Ye commented 1 year ago

When I try to build my project for web, I get a dart compiler error. Is there any work around you could implement?

../../.pub-cache/hosted/pub.dev/lottie-2.2.0/lib/src/model/layer/text_layer.dart:291:8:
Internal Error: The compiler crashed when compiling this element.
  void _drawFontTextLine(Characters text, TextStyle textStyle,
       ^
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 (2.19.1), and

* the entire message you see here (including the full stack trace
  below as well as the source location above).

The compiler crashed: RangeError (index): Invalid value: Only valid value is 0: 1
#0      List.[] (dart:core-patch/growable_array.dart:264:36)
#1      KernelSsaGraphBuilder._setupStateForInlining.<anonymous closure> (package:compiler/src/ssa/builder.dart:6307:48)
#2      forEachOrderedParameter.handleParameter (package:compiler/src/js_model/element_map.dart:549:6)
#3      forEachOrderedParameterByFunctionNode (package:compiler/src/js_model/element_map.dart:521:6)
#4      forEachOrderedParameter (package:compiler/src/js_model/element_map.dart:557:9)
#5      KernelSsaGraphBuilder._setupStateForInlining (package:compiler/src/ssa/builder.dart:6293:5)
#6      KernelSsaGraphBuilder._enterInlinedMethod (package:compiler/src/ssa/builder.dart:6255:5)
#7      KernelSsaGraphBuilder._doTryInlineMethod.doInlining (package:compiler/src/ssa/builder.dart:6081:7)
#8      KernelSsaGraphBuilder._doTryInlineMethod (package:compiler/src/ssa/builder.dart:6094:7)
#9      KernelSsaGraphBuilder._tryInlineMethod (package:compiler/src/ssa/builder.dart:5851:21)
#10     KernelSsaGraphBuilder._pushDynamicInvocation (package:compiler/src/ssa/builder.dart:5126:11)
#11     KernelSsaGraphBuilder._buildForInIterator.buildCondition (package:compiler/src/ssa/builder.dart:2074:7)
#12     LoopHandler.handleLoop (package:compiler/src/ssa/loop_handler.dart:70:50)
#13     KernelSsaGraphBuilder._buildForInIterator (package:compiler/src/ssa/builder.dart:2105:18)
#14     KernelSsaGraphBuilder.visitForInStatement (package:compiler/src/ssa/builder.dart:1897:7)
#15     ForInStatement.accept (package:kernel/ast.dart:10196:43)
#16     KernelSsaGraphBuilder.visitBlock (package:compiler/src/ssa/builder.dart:1747:17)
#17     Block.accept (package:kernel/ast.dart:9638:43)
#18     KernelSsaGraphBuilder._buildFunctionNode (package:compiler/src/ssa/builder.dart:1255:23)
#19     KernelSsaGraphBuilder.build.<anonymous closure> (package:compiler/src/ssa/builder.dart:453:15)
#20     DiagnosticReporter.withCurrentElement (package:compiler/src/diagnostics/diagnostic_listener.dart:142:15)
#21     KernelSsaGraphBuilder.build (package:compiler/src/ssa/builder.dart:438:21)
#22     KernelSsaBuilder.build.<anonymous closure> (package:compiler/src/js_model/js_strategy.dart:555:22)
#23     CompilerTask.measure (package:compiler/src/common/tasks.dart:66:51)
#24     KernelSsaBuilder.build (package:compiler/src/js_model/js_strategy.dart:537:18)
#25     SsaBuilderTask.build (package:compiler/src/ssa/ssa.dart:364:21)
#26     SsaFunctionCompiler.compile (package:compiler/src/ssa/ssa.dart:91:29)
#27     OnDemandCodegenResults.getCodegenResults (package:compiler/src/common/codegen.dart:420:30)
#28     JsBackendStrategy.generateCode (package:compiler/src/js_model/js_strategy.dart:341:43)
#29     KernelCodegenWorkItem.run (package:compiler/src/js_model/js_strategy.dart:497:29)
#30     Compiler.emptyQueue.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:compiler/src/compiler.dart:809:70)
#31     CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart:181:35)
#32     Compiler.emptyQueue.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:compiler/src/compiler.dart:809:32)
#33     CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart:181:35)
#34     Compiler.emptyQueue.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:compiler/src/compiler.dart:807:28)
#35     DiagnosticReporter.withCurrentElement (package:compiler/src/diagnostics/diagnostic_listener.dart:142:15)
#36     Compiler.emptyQueue.<anonymous closure>.<anonymous closure> (package:compiler/src/compiler.dart:805:18)
#37     CodegenEnqueuer._forEach (package:compiler/src/js_backend/enqueuer.dart:249:12)
#38     CodegenEnqueuer.forEach (package:compiler/src/js_backend/enqueuer.dart:265:5)
#39     Compiler.emptyQueue.<anonymous closure> (package:compiler/src/compiler.dart:801:16)
#40     CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart:181:35)
#41     Compiler.emptyQueue (package:compiler/src/compiler.dart:800:14)
#42     Compiler.processQueue.<anonymous closure> (package:compiler/src/compiler.dart:824:7)
#43     CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart:181:35)
#44     Compiler.processQueue (package:compiler/src/compiler.dart:818:14)
#45     Compiler.runCodegenEnqueuer (package:compiler/src/compiler.dart:555:5)
#46     Compiler.runSequentialPhases (package:compiler/src/compiler.dart:748:23)
<asynchronous suspension>
#47     Compiler.runInternal.<anonymous closure> (package:compiler/src/compiler.dart:352:7)
<asynchronous suspension>
#48     Compiler.runInternal (package:compiler/src/compiler.dart:351:5)
<asynchronous suspension>
#49     Compiler.run.<anonymous closure> (package:compiler/src/compiler.dart:272:11)
<asynchronous suspension>
#50     main (package:compiler/src/dart2js.dart:1435:3)
<asynchronous suspension>

#0      Dart2JSTarget.build (package:flutter_tools/src/build_system/targets/web.dart:246:7)
<asynchronous suspension>
#1      _BuildInstance._invokeInternal (package:flutter_tools/src/build_system/build_system.dart:847:9)
<asynchronous suspension>
#2      Future.wait.<anonymous closure> (dart:async/future.dart:522:21)
<asynchronous suspension>
#3      _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:785:32)
<asynchronous suspension>
#4      Future.wait.<anonymous closure> (dart:async/future.dart:522:21)
<asynchronous suspension>
#5      _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:785:32)
<asynchronous suspension>
#6      FlutterBuildSystem.build (package:flutter_tools/src/build_system/build_system.dart:614:16)
<asynchronous suspension>
#7      buildWeb (package:flutter_tools/src/web/compile.dart:53:32)
<asynchronous suspension>
#8      BuildWebCommand.runCommand (package:flutter_tools/src/commands/build_web.dart:135:5)
<asynchronous suspension>
#9      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1257:27)
<asynchronous suspension>
#10     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#11     CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#12     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:283:9)
<asynchronous suspension>
#13     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#14     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
<asynchronous suspension>
#15     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:64:9)
<asynchronous suspension>
#16     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#17     main (package:flutter_tools/executable.dart:91:3)
<asynchronous suspension>

Compiling lib/main.dart for the Web...                             39.5s
Exception: Failed to compile application for the Web.
[!] Flutter (Channel stable, 3.7.1, on macOS 13.1 22C65 darwin-arm64, locale en-FR)
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7048ed95a5 (5 days ago), 2023-02-01 09:07:31 -0800
    • Engine revision 800594f1f4
    • Dart version 2.19.1
    • DevTools version 2.20.1
xvrh commented 1 year ago

Hello, Can you share the flutter command you use? (I need to know is it a flutter run or flutter build web in debug or release mode). And a small dart repro.

Thanks.

Aqua-Ye commented 1 year ago

It is flutter build web

xvrh commented 1 year ago

Can you provide a reproducible example? I'm trying flutter build web on the example app but I don't see the crash.

Aqua-Ye commented 1 year ago

Yes I'm working on it, but the issue might be complex to reproduce, i'll try to have a minimal example if I can. But as the error states, it's more likely a dart compiler issue.

Aqua-Ye commented 1 year ago

Sorry I can't figure out a minimal example to demonstrate it. I'll close this issue and hope https://github.com/dart-lang/sdk/issues/51246 resolves it...