Skip to content

Dart2Js.dart crash Flutter 3.32.0/Dart 3.8.0 #60801

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

Open
devx-ubiquity opened this issue May 27, 2025 · 5 comments
Open

Dart2Js.dart crash Flutter 3.32.0/Dart 3.8.0 #60801

devx-ubiquity opened this issue May 27, 2025 · 5 comments
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. web-dart2js

Comments

@devx-ubiquity
Copy link

I've upgraded Flutter from 3.29.2 to 3.32.0 and I am now facing the following error when I generate the web release version of my app

Note that i disabled all optimizations with the following command line:
flutter build web --base-href "/bsa-services-app/" --target=launcher/launcher.dart -O0
and it's running OK but the generated main.dart.js file is really too big and generated display bugs in some screens of the app
I've tried O1,O2,O3 and O4 optimization options and I still have the same error
The debug version is OK

Command line output:

PS D:\Flutter\Apps\app_bsa_services> flutter build web --base-href "/bsa-services-app/" --target=launcher/launcher.dart
Target dart2js failed: ProcessException: Process exited abnormally with exit code 253:
Uncaught exception in diagnostic handler: FormatException: Unexpected extension byte (at offset 0)
#0 _Utf8Decoder.convertSingle (dart:convert-patch/convert_patch.dart:1855)
#1 Utf8Decoder.convert (dart:convert/utf.dart:351)
#2 Utf8BytesSourceFile.slowText (package:compiler/src/io/source_file.dart:189)
#3 SourceFile.lineStarts (package:compiler/src/io/source_file.dart:65)
#4 SourceFile.kernelSource (package:compiler/src/io/source_file.dart:32)
#5 SourceFile.getLocationMessage (package:compiler/src/io/source_file.dart:115)
#6 FormattingDiagnosticHandler.report (package:compiler/src/source_file_provider.dart:302)
#7 Compiler.callUserHandler. (package:compiler/src/compiler.dart:990)
#8 CompilerTask.measure (package:compiler/src/common/tasks.dart:67)
#9 Compiler.callUserHandler (package:compiler/src/compiler.dart:989)
#10 Compiler._reportDiagnosticMessage (package:compiler/src/compiler.dart:969)
#11 Compiler.reportDiagnostic (package:compiler/src/compiler.dart:948)
#12 DiagnosticReporter._reportDiagnostic (package:compiler/src/diagnostics/diagnostic_listener.dart:175)
#13 DiagnosticReporter.onError (package:compiler/src/diagnostics/diagnostic_listener.dart:330)
#14 Compiler.run. (package:compiler/src/compiler.dart:252)

#15 compile. (package:compiler/compiler_api.dart:273)

#16 compile.compilationDone (package:compiler/src/dart2js.dart:761)

#17 main (package:compiler/src/dart2js.dart:1310)

The compiler crashed: Stack Overflow
#0 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#1 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#2 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#3 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#4 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#5 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#6 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#7 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#8 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#9 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#10 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#11 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#12 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#13 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#14 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#15 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#16 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#17 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#18 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#19 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#20 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#21 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#22 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#23 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#24 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#25 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#26 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#27 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#28 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#29 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#30 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#31 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#32 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#33 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#34 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#35 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#36 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#37 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#38 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#39 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#40 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#41 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#42 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#43 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
...
...
#6982 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#6983 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#6984 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#6985 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#6986 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#6987 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#6988 SsaTypeConversionInserter.collectTargets (package:compiler/src/ssa/optimize.dart)
#6989 SsaTypeConversionInserter.visitIdentity (package:compiler/src/ssa/optimize.dart)
#6990 HIdentity.accept (package:compiler/src/ssa/nodes.dart)
#6991 HBaseVisitor.visitBasicBlock (package:compiler/src/ssa/nodes.dart)
#6992 HGraphVisitor.visitDominatorTree (package:compiler/src/ssa/nodes.dart)
#6993 SsaVariableAllocator.visitGraph (package:compiler/src/ssa/variable_allocator.dart)
#6994 SsaOptimizerTask.optimize.runPhase. (package:compiler/src/ssa/optimize.dart)
#6995 CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart)
#6996 SsaOptimizerTask.optimize.runPhase (package:compiler/src/ssa/optimize.dart)
#6997 SsaOptimizerTask.optimize. (package:compiler/src/ssa/optimize.dart)
#6998 CompilerTask.measure (package:compiler/src/common/tasks.dart)
#6999 SsaOptimizerTask.optimize (package:compiler/src/ssa/optimize.dart)
#7000 SsaFunctionCompiler.compile (package:compiler/src/ssa/ssa.dart)
#7001 OnDemandCodegenResults.getCodegenResults (package:compiler/src/common/codegen.dart)
#7002 JsBackendStrategy.generateCode (package:compiler/src/js_model/js_strategy.dart)
#7003 KernelCodegenWorkItem.run (package:compiler/src/js_model/js_strategy.dart)
#7004 Compiler.emptyQueue..... (package:compiler/src/compiler.dart)
#7005 CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart)
#7006 Compiler.emptyQueue.... (package:compiler/src/compiler.dart)
#7007 CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart)
#7008 Compiler.emptyQueue... (package:compiler/src/compiler.dart)
#7009 DiagnosticReporter.withCurrentElement (package:compiler/src/diagnostics/diagnostic_listener.dart)
#7010 Compiler.emptyQueue.. (package:compiler/src/compiler.dart)
#7011 CodegenEnqueuer._forEach (package:compiler/src/js_backend/enqueuer.dart)
#7012 Compiler.emptyQueue. (package:compiler/src/compiler.dart)
#7013 CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart)
#7014 Compiler.emptyQueue (package:compiler/src/compiler.dart)
#7015 Compiler.processQueue. (package:compiler/src/compiler.dart)
#7016 CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart)
#7017 Compiler.processQueue (package:compiler/src/compiler.dart)
#7018 Compiler.runCodegenEnqueuer (package:compiler/src/compiler.dart)
#7019 Compiler.runSequentialPhases (package:compiler/src/compiler.dart)
#7020 _SuspendState._createAsyncStarCallback. (dart:async-patch/async_patch.dart)
#7021 _microtaskLoop (dart:async/schedule_microtask.dart)
#7022 _startMicrotaskLoop (dart:async/schedule_microtask.dart)
#7023 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart)
#7024 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart)
Command: E:\Flutter\SDK\bin\cache\dart-sdk\bin\dart.exe compile js --platform-binaries=E:\Flutter\SDK\bin\cache\flutter_web_sdk\kernel --invoker=flutter_tool -Ddart.vm.product=true -DFLUTTER_VERSION=3.32.0 -DFLUTTER_CHANNEL=stable
-DFLUTTER_GIT_URL=https://github.com/flutter/flutter.git -DFLUTTER_FRAMEWORK_REVISION=be698c48a6 -DFLUTTER_ENGINE_REVISION=1881800949 -DFLUTTER_DART_VERSION=3.8.0 -DFLUTTER_WEB_USE_SKIA=true -DFLUTTER_WEB_USE_SKWASM=false
-DFLUTTER_WEB_CANVASKIT_URL=https://www.gstatic.com/flutter-canvaskit/18818009497c581ede5d8a3b8b833b81d00cebb7/ --native-null-assertions --no-source-maps -O4 -o
D:\Flutter\Apps\app_bsa_services.dart_tool\flutter_build\8fe78b29beb1647a4a53b1bd1a61a717\main.dart.js D:\Flutter\Apps\app_bsa_services.dart_tool\flutter_build\8fe78b29beb1647a4a53b1bd1a61a717\app.dill
#0 RunResult.throwException (package:flutter_tools/src/base/process.dart:118:5)
#1 _DefaultProcessUtils.run (package:flutter_tools/src/base/process.dart:344:19)

#2 Dart2JSTarget.build (package:flutter_tools/src/build_system/targets/web.dart:205:5)

#3 _BuildInstance._invokeInternal (package:flutter_tools/src/build_system/build_system.dart:873:9)

#4 Future.wait. (dart:async/future.dart:525:21)

#5 _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:811:32)

#6 Future.wait. (dart:async/future.dart:525:21)

#7 _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:811:32)

#8 FlutterBuildSystem.build (package:flutter_tools/src/build_system/build_system.dart:629:16)

#9 WebBuilder.buildWeb (package:flutter_tools/src/web/compile.dart:91:34)

#10 BuildWebCommand.runCommand (package:flutter_tools/src/commands/build_web.dart:246:5)

#11 FlutterCommand.run. (package:flutter_tools/src/runner/flutter_command.dart:1551:27)

#12 AppContext.run. (package:flutter_tools/src/base/context.dart:154:19)

#13 CommandRunner.runCommand (package:args/command_runner.dart:212:13)

#14 FlutterCommandRunner.runCommand. (package:flutter_tools/src/runner/flutter_command_runner.dart:494:9)

#15 AppContext.run. (package:flutter_tools/src/base/context.dart:154:19)

#16 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:431:5)

#17 run.. (package:flutter_tools/runner.dart:98:11)

#18 AppContext.run. (package:flutter_tools/src/base/context.dart:154:19)

#19 main (package:flutter_tools/executable.dart:102:3)

Compiling launcher/launcher.dart for the Web... 91,9s
Error: Failed to compile application for the Web.
PS D:\Flutter\Apps\app_bsa_services>

Flutter doctor output:

E:\Flutter\SDK\bin\flutter.bat doctor --verbose
[√] Flutter (Channel stable, 3.32.0, on Microsoft Windows [version 10.0.19045.5854], locale fr-FR) [2,1s]
• Flutter version 3.32.0 on channel stable at E:\Flutter\SDK
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision be698c48a6 (8 days ago), 2025-05-19 12:59:14 -0700
• Engine revision 1881800949
• Dart version 3.8.0
• DevTools version 2.45.1

[√] Windows Version (10 Professionnel pour les Stations de travail 64 bits, 22H2, 2009) [11,4s]

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [9,1s]
• Android SDK at E:\Flutter\AndroidTools\SDK
• Platform android-35, build-tools 34.0.0
• ANDROID_SDK_ROOT = E:\Flutter\AndroidTools\SDK
• Java binary at: E:\Flutter\AndroidTools\Studio\jbr\bin\java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: flutter config --jdk-dir="path/to/jdk".
• Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)
• All Android licenses accepted.

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

[X] Visual Studio - develop Windows apps [659ms]
X Visual Studio not installed; this is necessary to develop Windows apps.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 2024.3.2) [37ms]
• Android Studio at E:\Flutter\AndroidTools\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 21.0.6+-13368085-b895.109)

[√] IntelliJ IDEA Community Edition (version 2024.2) [33ms]
• IntelliJ at E:\SpringBoot\IDE\Intellij
• 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

[√] IntelliJ IDEA Ultimate Edition (version 2023.3) [32ms]
• IntelliJ at E:\IDE\IntelliJ
• 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

[√] Connected device (3 available) [629ms]
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [version 10.0.19045.5854]
• Chrome (web) • chrome • web-javascript • Google Chrome 136.0.7103.114
• Edge (web) • edge • web-javascript • Microsoft Edge 136.0.3240.76

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

! Doctor found issues in 1 category.
Process finished with exit code 0

@sigmundch sigmundch added web-dart2js area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. labels May 27, 2025
@fishythefish
Copy link
Member

Thanks for the report! Do you have a code example that we can use to reproduce the issue?

cc @rakudrama

@devx-ubiquity
Copy link
Author

No, sorry. The code is too big ( ~200K lines of dart code).
This is the first time I've encountered this problem since using flutter ( 2018) . Note also that the code is not open source. Impossible for me to identify the code responsible for the crash. The code was compiled successfully in javascript with Flutter version 3.29.2. Perhaps you could provide me with a more verbose version of dart2js.

@sigmundch
Copy link
Member

Given the history of changes to optimize.dart, my guess is that the regression probably started with 9505e95, which added many more recursive cases to collectTargets.

@rakudrama
Copy link
Member

@sigmundch that was my conclusion too.

@devx-ubiquity
Copy link
Author

So I can expect a fix in the next patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. web-dart2js
Projects
None yet
Development

No branches or pull requests

4 participants