Skip to content
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

Crashing bug with pkg/js and dart2js #24974

Closed
kevmoo opened this issue Nov 18, 2015 · 9 comments
Closed

Crashing bug with pkg/js and dart2js #24974

kevmoo opened this issue Nov 18, 2015 · 9 comments
Assignees
Labels
P0 A serious issue requiring immediate resolution web-dart2js web-js-interop Issues that impact all js interop

Comments

@kevmoo
Copy link
Member

kevmoo commented Nov 18, 2015

The chartjs.dart project with some recent changes from @jacob314 crashes without the work-around items commented out by this commit

google/chartjs.dart@d38ec4b

@kevmoo kevmoo added web-dart2js P0 A serious issue requiring immediate resolution web-js-interop Issues that impact all js interop labels Nov 18, 2015
@kevmoo
Copy link
Member Author

kevmoo commented Nov 18, 2015

@kevmoo
Copy link
Member Author

kevmoo commented Nov 18, 2015

NoSuchMethodError: method not found: 'orderedForEachParameter'
Receiver: null
Arguments: [Closure: (ParameterElement) => dynamic]
#0      Object._noSuchMethod (dart:core-patch/object_patch.dart:42)
#1      Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
#2      JsInteropAnalysis.processJsInteropAnnotationsInLibrary.<anonymous closure>.<anonymous closure> (file:///b/build/slave/dart-sdk-mac-dev/build/sdk/pkg/compiler/lib/src/js_backend/js_interop_analysis.dart:145)
#3      ElementX&AstElementMixin&AnalyzableElementX&ClassElementCommon.forEachMember.<anonymous closure> (file:///b/build/slave/dart-sdk-mac-dev/build/sdk/pkg/compiler/lib/src/elements/common.dart:323)
#4      LinkEntry.forEach (file:///b/build/slave/dart-sdk-mac-dev/build/sdk/pkg/compiler/lib/src/util/link_implementation.dart:120)
#5      ClassElementX.forEachLocalMember (file:///b/build/slave/dart-sdk-mac-dev/build/sdk/pkg/compiler/lib/src/elements/modelx.dart:2751)
#6      ElementX&AstElementMixin&AnalyzableElementX&ClassElementCommon.forEachMember (file:///b/build/slave/dart-sdk-mac-dev/build/sdk/pkg/compiler/lib/src/elements/common.dart:323)
#7      JsInteropAnalysis.processJsInteropAnnotationsInLibrary.<anonymous closure> (file:///b/build/slave/dart-sdk-mac-dev/build/sdk/pkg/compiler/lib/src/js_backend/js_interop_analysis.dart:128)
#8      LinkEntry.forEach (file:///b/build/slave/dart-sdk-mac-dev/build/sdk/pkg/compiler/lib/src/util/link_implementation.dart:120)
#9      LibraryElementX.forEachLocalMember (file:///b/build/slave/dart-sdk-mac-dev/build/sdk/pkg/compiler/lib/src/elements/modelx.dart:1262)
#10     JsInteropAnalysis.processJsInteropAnnotationsInLibrary (file:///b/build/slave/dart-sdk-mac-dev/build/sdk/pkg/compiler/lib/src/js_backend/js_interop_analysis.dart:108)
#11     Iterable.forEach (dart:core/iterable.dart:217)
#12     JsInteropAnalysis.onQueueClosed (file:///b/build/slave/dart-sdk-mac-dev/build/sdk/pkg/compiler/lib/src/js_backend/js_interop_analysis.dart:54)
#13     JavaScriptBackend.onQueueClosed (file:///b/build/slave/dart-sdk-mac-dev/build/sdk/pkg/compiler/lib/src/js_backend/backend.dart:2525)
#14     Compiler.processQueue (file:///b/build/slave/dart-sdk-mac-dev/build/sdk/pkg/compiler/lib/src/compiler.dart:1128)
#15     Compiler.compileLoadedLibraries (file:///b/build/slave/dart-sdk-mac-dev/build/sdk/pkg/compiler/lib/src/compiler.dart:996)
#16     Compiler.runCompiler.<anonymous closure> (file:///b/build/slave/dart-sdk-mac-dev/build/sdk/pkg/compiler/lib/src/compiler.dart:869)
#17     _RootZone.runUnary (dart:async/zone.dart:1149)
#18     _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:502)
#19     _Future._propagateToListeners (dart:async/future_impl.dart:585)
#20     _Future._completeWithValue (dart:async/future_impl.dart:376)
#21     _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:430)
#22     _microtaskLoop (dart:async/schedule_microtask.dart:43)
#23     _microtaskLoopEntry (dart:async/schedule_microtask.dart:52)
#24     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:96)
#25     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)

@sigmundch
Copy link
Member

Here is a small repro of the issue:

import 'package:js/js.dart';

@JS()
@anonymous
class A {
  external bool get value;
  external factory A({bool value});
}

void main() {}

I'll be adding this regression test to our repo shortly.

I believe Jacob's workaround helps because the @JS() external get workaround is typed dynamic, so we think the return value could be anything marked with @JS.

@sigmundch
Copy link
Member

Just sent out a possible fix: https://codereview.chromium.org/1458313002/

@sigmundch
Copy link
Member

FYI - I just validated and the chart example works with the patch

@jacob314
Copy link
Member

The intent of the dart2js implementation of JS interop is any time you get
back something from interop you should be assuming that any types that have
@js are implemented. Your fix will generate more efficient output but I do
worry it will lead to unexpected bugs for cases where users cross cast from
one JS interop type to another.

On Thu, Nov 19, 2015 at 4:41 PM, sigmundch [email protected] wrote:

FYI - I just validated and the chart example works with the patch


Reply to this email directly or view it on GitHub
#24974 (comment).

@sigmundch
Copy link
Member

Interesting - so cross-cast would work as long as the two JS types were included independently, but the cast on itself will not be enough to include the casted type.

I just created a CL with the alternative approach where we include all JS types as soon as you make any call through JS-interop. It can't treeshake any interop type, but side-casts would work.

https://codereview.chromium.org/1457383003/

@sigmundch
Copy link
Member

Landed in 3fa0cae, and b837d63

I just filed a merge request for it here: #25068

@sigmundch
Copy link
Member

Closing this issue now that it made it to the dev-channel version 1.14.0-dev.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P0 A serious issue requiring immediate resolution web-dart2js web-js-interop Issues that impact all js interop
Projects
None yet
Development

No branches or pull requests

4 participants