Skip to content

need to support deferred libraries in VM / incremental compiler at least as noops #32245

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

Closed
mraleph opened this issue Feb 20, 2018 · 6 comments
Closed
Assignees
Labels
customer-flutter front-end-kernel legacy-area-front-end Legacy: Use area-dart-model instead. P0 A serious issue requiring immediate resolution
Milestone

Comments

@mraleph
Copy link
Member

mraleph commented Feb 20, 2018

If you change flutter_gallery lib/main.dart into this:

import 'package:flutter/widgets.dart';

import 'gallery/app.dart' deferred as foo;

void main() {
  runApp(new foo.GalleryApp());
}

and try to run it in --preview-dart-2 mode then it explodes in both compiler and VM

[        ] compiler message: NoSuchMethodError: The getter 'dependencies' was called on null.
[        ] compiler message: Receiver: null
[        ] compiler message: Tried calling: dependencies
[        ] compiler message: #0      Object.noSuchMethod (dart:core-patch/dart:core/object_patch.dart:46)
[        ] compiler message: #1      BinaryBuilder.readLibraryDependencyReference (package:kernel/binary/ast_from_binary.dart:535)
[        ] compiler message: #2      BinaryBuilder.readExpression (package:kernel/binary/ast_from_binary.dart:1180)
[        ] compiler message: #3      BinaryBuilder.readExpressionOption (package:kernel/binary/ast_from_binary.dart:1168)
[        ] compiler message: #4      BinaryBuilder.readVariableDeclaration (package:kernel/binary/ast_from_binary.dart:1788)
[        ] compiler message: #5      BinaryBuilder.readExpression (package:kernel/binary/ast_from_binary.dart:1385)
[        ] compiler message: #6      BinaryBuilder.readExpressionList (package:kernel/binary/ast_from_binary.dart:1162)
[        ] compiler message: #7      BinaryBuilder.readArguments (package:kernel/binary/ast_from_binary.dart:1742)
[        ] compiler message: #8      BinaryBuilder.readExpression (package:kernel/binary/ast_from_binary.dart:1278)
[        ] compiler message: #9      BinaryBuilder.readStatement (package:kernel/binary/ast_from_binary.dart:1464)
[        ] compiler message: #10     BinaryBuilder.readStatementList (package:kernel/binary/ast_from_binary.dart:1442)
[        ] compiler message: #11     BinaryBuilder.readBlock (package:kernel/binary/ast_from_binary.dart:1606)
[        ] compiler message: #12     BinaryBuilder.readStatement (package:kernel/binary/ast_from_binary.dart:1466)
[        ] compiler message: #13     BinaryBuilder.readStatementOption (package:kernel/binary/ast_from_binary.dart:1457)
[        ] compiler message: #14     BinaryBuilder._setLazyLoadFunction.<anonymous closure> (package:kernel/binary/ast_from_binary.dart:1119)
[        ] compiler message: #15     FunctionNode._buildLazy (package:kernel/ast.dart:1918)
[        ] compiler message: #16     FunctionNode.body (package:kernel/ast.dart:1923)
[        ] compiler message: #17     BinaryPrinter.visitFunctionNode (package:kernel/binary/ast_to_binary.dart:881)
[        ] compiler message: #18     FunctionNode.accept (package:kernel/ast.dart:1978)
[        ] compiler message: #19     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:220)
[        ] compiler message: #20     LimitedBinaryPrinter.writeNode (package:kernel/binary/limited_ast_to_binary.dart:55)
[        ] compiler message: #21     BinaryPrinter.writeOptionalNode (package:kernel/binary/ast_to_binary.dart:228)
[        ] compiler message: #22     BinaryPrinter.visitProcedure (package:kernel/binary/ast_to_binary.dart:770)
[        ] compiler message: #23     Procedure.accept (package:kernel/ast.dart:1640)
[        ] compiler message: #24     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:220)
[        ] compiler message: #25     LimitedBinaryPrinter.writeNode (package:kernel/binary/limited_ast_to_binary.dart:55)
[        ] compiler message: #26     BinaryPrinter.writeNodeList (package:kernel/binary/ast_to_binary.dart:212)
[        ] compiler message: #27     BinaryPrinter.visitLibrary (package:kernel/binary/ast_to_binary.dart:584)
[        ] compiler message: #28     Library.accept (package:kernel/ast.dart:409)
[        ] compiler message: #29     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:220)
[        ] compiler message: #30     LimitedBinaryPrinter.writeNode (package:kernel/binary/limited_ast_to_binary.dart:55)
[        ] compiler message: #31     List.forEach (dart:core-patch/dart:core/growable_array.dart:274)
[        ] compiler message: #32     BinaryPrinter.writeList (package:kernel/binary/ast_to_binary.dart:204)
[        ] compiler message: #33     LimitedBinaryPrinter.writeLibraries (package:kernel/binary/limited_ast_to_binary.dart:49)
[        ] compiler message: #34     BinaryPrinter.writeProgramFile (package:kernel/binary/ast_to_binary.dart:300)
[        ] compiler message: #35     _FrontendCompiler.compile (package:frontend_server/server.dart:202)
[        ] compiler message: <asynchronous suspension>
[        ] compiler message: #36     starter.<anonymous closure> (package:frontend_server/server.dart:379)
[        ] compiler message: <asynchronous suspension>
[        ] compiler message: #37     _RootZone.runUnaryGuarded (dart:async/zone.dart:1316)
[        ] compiler message: #38     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:330)
[        ] compiler message: #39     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:257)
[        ] compiler message: #40     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68)
[        ] compiler message: #41     _EventSinkWrapper.add (dart:async/stream_transformers.dart:15)
[        ] compiler message: #42     _StringAdapterSink.add (dart:convert/string_conversion.dart:268)
[        ] compiler message: #43     _LineSplitterSink._addLines (dart:convert/line_splitter.dart:154)
[        ] compiler message: #44     _LineSplitterSink.addSlice (dart:convert/line_splitter.dart:129)
[        ] compiler message: #45     StringConversionSinkMixin.add (dart:convert/string_conversion.dart:189)
[        ] compiler message: #46     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120)
[        ] compiler message: #47     _RootZone.runUnaryGuarded (dart:async/zone.dart:1316)
[        ] compiler message: #48     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:330)
[        ] compiler message: #49     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:257)
[        ] compiler message: #50     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68)
[        ] compiler message: #51     _EventSinkWrapper.add (dart:async/stream_transformers.dart:15)
[        ] compiler message: #52     _StringAdapterSink.add (dart:convert/string_conversion.dart:268)
[        ] compiler message: #53     _StringAdapterSink.addSlice (dart:convert/string_conversion.dart:273)
[        ] compiler message: #54     _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:348)
[        ] compiler message: #55     _Utf8ConversionSink.add (dart:convert/string_conversion.dart:341)
[        ] compiler message: #56     _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:86)
[        ] compiler message: #57     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120)
[        ] compiler message: #58     _RootZone.runUnaryGuarded (dart:async/zone.dart:1316)
[        ] compiler message: #59     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:330)
[        ] compiler message: #60     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:257)
[        ] compiler message: #61     _StreamController&&_SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:763)
[        ] compiler message: #62     _StreamController._add (dart:async/stream_controller.dart:639)
[        ] compiler message: #63     _StreamController.add (dart:async/stream_controller.dart:585)
[        ] compiler message: #64     _Socket._onData (dart:io-patch/socket_patch.dart:1654)
[        ] compiler message: #65     _RootZone.runUnaryGuarded (dart:async/zone.dart:1316)
[        ] compiler message: #66     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:330)
[        ] compiler message: #67     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:257)
[        ] compiler message: #68     _StreamController&&_SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:763)
[        ] compiler message: #69     _StreamController._add (dart:async/stream_controller.dart:639)
[        ] compiler message: #70     _StreamController.add (dart:async/stream_controller.dart:585)
[        ] compiler message: #71     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1231)
[        ] compiler message: #72     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:784)
[        ] compiler message: #73     _microtaskLoop (dart:async/schedule_microtask.dart:41)
[        ] compiler message: #74     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
[        ] compiler message: #75     _runPendingImmediateCallback (dart:isolate-patch/dart:isolate/isolate_patch.dart:113)
[        ] compiler message: #76     _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:166)
[  +34 ms] Updating files
[+1664 ms] DevFS: Sync finished
[        ] Synced 7.9MB.
[   +1 ms] _flutter.listViews: {}
[  +25 ms] Connected to _flutterView/0xe879e4a0.
[        ] 🔥  To hot reload your app on the fly, press "r". To restart the app entirely, press "R".
[        ] An Observatory debugger and profiler on Nexus 5X is available at: http://127.0.0.1:8108/
[        ] For a more detailed help message, press "h". To quit, press "q".
[+272225 ms] I/FlutterActivityDelegate(32520): onResume setting current activity to this
[ +543 ms] E/flutter (32520): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] error: Unsupported tag at this point: 14.
[        ] E/flutter (32520): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Dart_GetClosure expects argument 'library' to be non-null.
[+87581 ms] I/FlutterActivityDelegate(32036): onResume setting current activity to this
[  +48 ms] I/OpenGLRenderer(32036): Initialized EGL, version 1.4
[+1618 ms] I/FlutterActivityDelegate(32647): onResume setting current activity to this
[ +467 ms] E/flutter (32647): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] error: Unsupported tag at this point: 14.
[        ] E/flutter (32647): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Dart_GetClosure expects argument 'library' to be non-null.

Note: intl package generates code that contains deferred so there are Flutter apps in a wild that use deferred. If we don't have time to support deferred we should at least fix it to be a no-op when FlutterTarget is used.

This issue was revealed when I tried to run this Flutter application: https://github.com/brianegan/flutter_architecture_samples/tree/master/example/built_redux

@mraleph mraleph added P0 A serious issue requiring immediate resolution customer-flutter area-kernel legacy-area-front-end Legacy: Use area-dart-model instead. labels Feb 20, 2018
@mraleph mraleph changed the title need to support deferred libraries in VM / incremental compiler need to support deferred libraries in VM / incremental compiler at least as noops Feb 20, 2018
@sigmundch
Copy link
Member

A related bug #31938 (there is no deserialization in cpp for deferred instructions)

@jensjoha
Copy link
Contributor

I've fixed the explosion in the compiler (currently in commit queue).

dart-bot pushed a commit that referenced this issue Feb 21, 2018
This CL adds a test that bootstraps from a dill with a deferred library
in it. Before this CL it crashed, see bug #32245.

This CL "double fixes" the problem:
a) When lazy loading a dill file the _currentLibrary variable wasn't set
   properly. This has been fixed.
b) When bootstrapping from a dill file, (almost) everything in the dill
   will be included in the output so lazy loading it doesn't make sense.

Bug: 32245.
Change-Id: I94980608e19633fd31b522651a4a05b9cf7beabd
Reviewed-on: https://dart-review.googlesource.com/42600
Commit-Queue: Jens Johansen <[email protected]>
Reviewed-by: Kevin Millikin <[email protected]>
dart-bot pushed a commit that referenced this issue Feb 22, 2018
Introduce no-op LoadLibrary, CheckLibraryIsLoaded into kernel_binary_flowgraph.cc

Bug: #32245
Change-Id: If93a4d717844dcb8a5d45d0237660ec764a6f738
Reviewed-on: https://dart-review.googlesource.com/42461
Reviewed-by: Vyacheslav Egorov <[email protected]>
Reviewed-by: Kevin Millikin <[email protected]>
Commit-Queue: Alexander Aprelev <[email protected]>
@aam
Copy link
Contributor

aam commented Feb 23, 2018

ec7029d patched VM side of things(deserialization, generation of no-op for deferred operations).

@dgrove
Copy link
Contributor

dgrove commented Feb 23, 2018

Is there any work remaining here?

@aam
Copy link
Contributor

aam commented Feb 23, 2018

@dgrove , ideally we add better support for deferred operations which means generating runtime calls(load, isLoaded) to corresponding LibraryPrefix objects.

@aam
Copy link
Contributor

aam commented Feb 23, 2018

Created #32298 to track remaining(non-P0) work. Closing this.

@aam aam closed this as completed Feb 23, 2018
@JekCharlsonYu JekCharlsonYu added this to the I/O Beta 2 milestone Feb 23, 2018
@kmillikin kmillikin added legacy-area-front-end Legacy: Use area-dart-model instead. front-end-kernel and removed legacy-area-front-end Legacy: Use area-dart-model instead. labels Sep 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-flutter front-end-kernel legacy-area-front-end Legacy: Use area-dart-model instead. P0 A serious issue requiring immediate resolution
Projects
None yet
Development

No branches or pull requests

8 participants