Skip to content

[Proposal] Hotfix into stable: Dart compiler crashes while building for web #100038

Description

@dopecoder

Steps to Reproduce

  1. Running flutter build web crashes the dart compiler.

This issues has been fixes in dart-sdk: dart-lang/sdk#47916

Would it be possible to bring this as a hotfix into flutter? I see that the dart version in flutter master channel is 2.17.0-182.0.dev. But this fix mentioned is included in dart versions starting from 2.17.0-188.0.dev.

Or is there a way to change the dart version in flutter sdk?

Note: This issue exists in flutter stable channel as well, but the logs included is with master channel

Basic Repro

abstract class A {
  const factory A() = B;
}

abstract class B implements A {
  const factory B() = C;
}

class C implements B {
  const C();
}

main() {
  A.new;
}

Note: This crashes the flutter dart2js compiler, works fine with android and iOS.

Logs

Logs
 Target dart2js failed: Exception: Warning: The 'dart2js' entrypoint script is deprecated, please use 'dart compile js' instead.
           lib/app/pages/signals/application/signal-actor-bloc/signal-actor-bloc.cg.freezed.dart:5940:17:
           Internal Error: The compiler crashed when compiling this element.
             const factory _ReportInaccurateSignalFailure(SignalsFailure failure) =
                           ^
           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.17.0-182.0.dev), and
           
           * the entire message you see here (including the full stack trace
             below as well as the source location above).
           
           The compiler crashed: NoSuchMethodError: The getter 'boxedVariables' was called on null.
           Receiver: null
           Tried calling: boxedVariables
           #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5)
           #1      JsKernelToElementMap.makeRecordContainer (package:compiler/src/js_model/element_map_impl.dart:1770:14)
           #2      ClosureDataBuilder.createClosureEntities.processModel (package:compiler/src/js_model/closure.dart:329:23)
           #3      ClosureDataBuilder.createClosureEntities.<anonymous closure>.<anonymous closure>
(package:compiler/src/js_model/closure.dart:389:9)
           #4      CompilerDiagnosticReporter.withCurrentElement (package:compiler/src/compiler.dart:1025:15)
           #5      ClosureDataBuilder.createClosureEntities.<anonymous closure> (package:compiler/src/js_model/closure.dart:388:17)
           #6      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:579:13)
           #7      ClosureDataBuilder.createClosureEntities (package:compiler/src/js_model/closure.dart:387:19)
           #8      JsClosedWorldBuilder.convertClosedWorld (package:compiler/src/js_model/js_world_builder.dart:161:41)
           #9      JsBackendStrategy.createJClosedWorld (package:compiler/src/js_model/js_strategy.dart:174:52)
           #10     Compiler.closeResolution (package:compiler/src/compiler.dart:610:25)
           #11     Compiler.computeClosedWorld (package:compiler/src/compiler.dart:470:9)
           #12     Compiler.compileFromKernel.<anonymous closure>.<anonymous closure> (package:compiler/src/compiler.dart:572:17)
           #13     CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart:181:35)
           #14     Compiler.compileFromKernel.<anonymous closure> (package:compiler/src/compiler.dart:571:44)
           #15     CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart:181:35)
           #16     Compiler.compileFromKernel (package:compiler/src/compiler.dart:570:14)
           #17     Compiler.runInternal (package:compiler/src/compiler.dart:372:17)
           <asynchronous suspension>
           #18     main (package:compiler/src/dart2js.dart:1392:3)
           <asynchronous suspension>
           
           
[  +17 ms] Compiling lib/main.dart for the Web... (completed in 30.2s)
[   +1 ms] "flutter web" took 31,363ms.
[   +4 ms] Exception: Failed to compile application for the Web.
[        ] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      buildWeb (package:flutter_tools/src/web/compile.dart:81:5)
           <asynchronous suspension>
           #2      BuildWebCommand.runCommand (package:flutter_tools/src/commands/build_web.dart:112:5)
           <asynchronous suspension>
           #3      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1165:27)
           <asynchronous suspension>
           #4      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #5      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
           <asynchronous suspension>
           #6      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9)
           <asynchronous suspension>
           #7      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #8      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
           <asynchronous suspension>
           #9      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
           <asynchronous suspension>
           #10     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #11     main (package:flutter_tools/executable.dart:94:3)
           <asynchronous suspension>
           
           
[  +90 ms] ensureAnalyticsSent: 88ms
[   +1 ms] Running shutdown hooks
[        ] Shutdown hooks complete
[        ] exiting with code 1

[✓] Flutter (Channel master, 2.11.0-0.0.pre.871, on macOS 12.2.1 21D62 darwin-x64, locale en-US)
    • Flutter version 2.11.0-0.0.pre.871 at /Users/nithinrao/fvm/versions/beta
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4f4c7816c3 (55 minutes ago), 2022-03-14 07:35:07 +0100
    • Engine revision 6239bfb884
    • Dart version 2.17.0 (build 2.17.0-182.0.dev)
    • DevTools version 2.11.1

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc5)
    • Android SDK at /Users/nithinrao/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0-rc5
    • ANDROID_SDK_ROOT = /Users/nithinrao/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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 11.0.11+0-b60-7590822)

[✓] VS Code (version 1.65.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.36.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 12.2.1 21D62 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 99.0.4844.51

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: proposalA detailed proposal for a change to Flutterdependency: dartDart team may need to help usplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer version

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions