KhronosGroup / glTF-Validator

Tool to validate glTF assets.
Apache License 2.0
360 stars 60 forks source link

Experimenting with GLTF as a dependency - Error building release dart2js #71

Closed JeromePuttemans closed 6 years ago

JeromePuttemans commented 6 years ago

Hello,

I'm learning to build a 'webgl' project of my own and use 'GLTF' as a dependency. My project build correctly in debug with dartdevc but not in release with dart2js.

The base project 'gltf' project build correctly both in release with dartdevc and build with dart2j !!

Dart VM version: 2.0.0-dev.30.0 (Thu Feb 22 14:08:47 2018 +0100) on "windows_x64"

As said in https://github.com/dart-lang/sdk/issues/32334

But after removing all aspects of mirrors in my project, I still have the problem, I definitively don't understand the real problem.

Here is my puspec.yaml:

name: 'webgl'
version: 0.0.5
description: Building a webgl API

environment:
  sdk: '>=2.0.0-dev.30.0 <2.0.0'

dependencies:
  browser: '^0.10.0+2'
  dart_to_js_script_rewriter: '^1.0.3'
  vector_math: '^2.0.5'
  gltf:
    path: ../gltf
#    git: git://github.com/KhronosGroup/glTF-Validator.git
  datgui: "^0.2.0+1"
  logging: "^0.11.3+1"
  stack_trace: "^1.8.2"

dev_dependencies:
  test: '>=0.12.0 <0.13.0'

transformers:
 - dart_to_js_script_rewriter
 - $dart2js:
     commandLineOptions: [--trust-primitives, --trust-type-annotations]

web:
  compiler:
    debug: dartdevc

and the error log:

C:\tools\dart-sdk\bin\pub.bat build --mode=release --output=build
Loading source assets...
Loading dart_to_js_script_rewriter transformers...
Building webgl...
[Info from Dart2JS]:
Compiling webgl|web/gltf/main.dart...
[Error from Dart2JS on webgl|web/gltf/main.dart]:
web\packages\gltf\src\base\gltf.dart:94:3:
Runtime type information not available for type_variable_local(toSafeList.T) in (parameter(fromMap#map), parameter(fromMap#context), BoxLocal(_box_0), ..., variable(fromMap#extensionsUsed), variable(fromMap#extensionsRequired)) for factory_constructor(Gltf#fromMap).
  factory Gltf.fromMap(Map<String, Object> map, Context context) {
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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 (build number could not be determined), and

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

Build error:
Transform Dart2JS on webgl|web/gltf/main.dart threw error: Assertion failure: Runtime type information not available for type_variable_local(toSafeList.T) in (parameter(fromMap#map), parameter(fromMap#context), BoxLocal(_box_0), ..., variable(fromMap#extensionsUsed), variable(fromMap#extensionsRequired)) for factory_constructor(Gltf#fromMap).
package:compiler_unsupported/src/diagnostics/invariant.dart 55            failedAt
package:compiler_unsupported/src/ssa/locals_handler.dart 328              LocalsHandler.readLocal
package:compiler_unsupported/src/ssa/builder.dart 1922                    SsaAstGraphBuilder.visitFunctionExpression.<fn>
package:compiler_unsupported/src/elements/common.dart 388                 ElementX&AstElementMixin&AnalyzableElementX&ClassElementCommon.forEachInstanceField.fieldFilter
package:compiler_unsupported/src/elements/common.dart 356                 ElementX&AstElementMixin&AnalyzableElementX&ClassElementCommon.forEachMember.<fn>
package:front_end/src/fasta/util/link_implementation.dart 124             LinkEntry.forEach
package:compiler_unsupported/src/elements/modelx.dart 2985                ClassElementX.forEachLocalMember
package:compiler_unsupported/src/elements/common.dart 356                 ElementX&AstElementMixin&AnalyzableElementX&ClassElementCommon.forEachMember
package:compiler_unsupported/src/elements/common.dart 392                 ElementX&AstElementMixin&AnalyzableElementX&ClassElementCommon.forEachInstanceField
package:compiler_unsupported/src/universe/codegen_world_builder.dart 605  ElementCodegenWorldBuilderImpl.forEachInstanceField
package:compiler_unsupported/src/ssa/builder.dart 1919                    SsaAstGraphBuilder.visitFunctionExpression
package:compiler_unsupported/src/tree/nodes.dart 1209                     FunctionExpression.accept
package:compiler_unsupported/src/ssa/builder.dart 1624                    SsaAstGraphBuilder.visit
package:compiler_unsupported/src/ssa/builder.dart 1933                    SsaAstGraphBuilder.visitFunctionDeclaration
package:compiler_unsupported/src/tree/nodes.dart 1127                     FunctionDeclaration.accept
package:compiler_unsupported/src/ssa/builder.dart 1624                    SsaAstGraphBuilder.visit
package:compiler_unsupported/src/ssa/builder.dart 1670                    SsaAstGraphBuilder.visitBlock
package:compiler_unsupported/src/tree/nodes.dart 980                      Block.accept
package:compiler_unsupported/src/ssa/builder.dart 769                     SsaAstGraphBuilder.buildMethod
package:compiler_unsupported/src/ssa/builder.dart 319                     SsaAstGraphBuilder.build
package:compiler_unsupported/src/ssa/builder.dart 114                     SsaAstBuilder.build.<fn>.<fn>
package:compiler_unsupported/src/compiler.dart 1156                       CompilerDiagnosticReporter.withCurrentElement
package:compiler_unsupported/src/ssa/builder.dart 105                     SsaAstBuilder.build.<fn>
package:compiler_unsupported/src/common/tasks.dart 63                     CompilerTask.measure
package:compiler_unsupported/src/ssa/builder.dart 99                      SsaAstBuilder.build
package:compiler_unsupported/src/ssa/ssa.dart 91                          SsaBuilderTask.build
package:compiler_unsupported/src/ssa/ssa.dart 43                          SsaFunctionCompiler.compile
package:compiler_unsupported/src/js_backend/backend.dart 846              JavaScriptBackend.codegen
package:compiler_unsupported/src/js_backend/element_strategy.dart 176     ElementCodegenWorkItem.run
package:compiler_unsupported/src/compiler.dart 784                        Compiler.emptyQueue.<fn>.<fn>.<fn>.<fn>.<fn>
package:compiler_unsupported/src/common/tasks.dart 178                    CompilerTask.measureSubtask
package:compiler_unsupported/src/compiler.dart 784                        Compiler.emptyQueue.<fn>.<fn>.<fn>.<fn>
package:compiler_unsupported/src/common/tasks.dart 178                    CompilerTask.measureSubtask
package:compiler_unsupported/src/compiler.dart 782                        Compiler.emptyQueue.<fn>.<fn>.<fn>
package:compiler_unsupported/src/compiler.dart 1156                       CompilerDiagnosticReporter.withCurrentElement
package:compiler_unsupported/src/compiler.dart 780                        Compiler.emptyQueue.<fn>.<fn>
package:compiler_unsupported/src/enqueue.dart 511                         EnqueuerStrategy.processWorkItem
package:compiler_unsupported/src/js_backend/enqueuer.dart 224             CodegenEnqueuer.forEach
package:compiler_unsupported/src/compiler.dart 776                        Compiler.emptyQueue.<fn>
package:compiler_unsupported/src/common/tasks.dart 178                    CompilerTask.measureSubtask
package:compiler_unsupported/src/compiler.dart 775                        Compiler.emptyQueue
package:compiler_unsupported/src/compiler.dart 797                        Compiler.processQueue.<fn>
package:compiler_unsupported/src/common/tasks.dart 178                    CompilerTask.measureSubtask
package:compiler_unsupported/src/compiler.dart 794                        Compiler.processQueue
package:compiler_unsupported/src/compiler.dart 640                        Compiler.compileLoadedLibraries.<fn>
package:compiler_unsupported/src/common/tasks.dart 178                    CompilerTask.measureSubtask
package:compiler_unsupported/src/compiler.dart 534                        Compiler.compileLoadedLibraries
package:compiler_unsupported/src/compiler.dart 488                        Compiler.runInternal
===== asynchronous gap ===========================
package:compiler_unsupported/src/compiler.dart 313                        Compiler.run.<fn>.<fn>
dart:async                                                                new Future.sync
package:compiler_unsupported/src/compiler.dart 313                        Compiler.run.<fn>
package:compiler_unsupported/src/common/tasks.dart 178                    CompilerTask.measureSubtask
package:compiler_unsupported/src/compiler.dart 310                        Compiler.run
package:compiler_unsupported/src/apiimpl.dart 265                         CompilerImpl.run.<fn>.<fn>
Build failed.

Thank you

lexaknyazev commented 6 years ago

Could you check if your project uses .runtimeType anywhere? There's a related compiler bug.

JeromePuttemans commented 6 years ago

Yes, thank you. You're right, when I remove the .runtimeType, the project builds correclty ! Can you point me to the problematic compiler issue ?

lexaknyazev commented 6 years ago

That issue will probably never be fixed because it is related to the old compiler pipeline. With the new compiler front-end, code with .runtimeType builds fine.

You can try it like this (code needs to be built manually for now, without pub build):

$ dart2js --use-kernel your_app.dart --out=your_app.dart.js

AFAIU, the new compiler will soon be enabled by default.

lexaknyazev commented 6 years ago

@JeromePuttemans The code should compile fine by default as of 2.0.0-dev.39.0.

JeromePuttemans commented 6 years ago

@lexaknyazev
Nice, thanks for the info.