Skip to content

unable to view variables when debugging a flutter web app in IntelliJ #965

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
devoncarew opened this issue Apr 22, 2020 · 9 comments · Fixed by #989
Closed

unable to view variables when debugging a flutter web app in IntelliJ #965

devoncarew opened this issue Apr 22, 2020 · 9 comments · Fixed by #989
Assignees
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures package:dwds

Comments

@devoncarew
Copy link
Member

We get an exception when trying to populate the variables view:

Screen Shot 2020-04-21 at 5 37 51 PM

NoSuchMethodError: The getter 'uri' was called on null.
Receiver: null
Tried calling: uri
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1      ClassHelper._constructClass (package:dwds/src/debugging/classes.dart:72:58)
#2      ClassHelper.forObjectId (package:dwds/src/debugging/classes.dart:61:19)
<asynchronous suspension>
#3      AppInspector.getObject (package:dwds/src/debugging/inspector.dart:316:35)
<asynchronous suspension>
#4      ChromeProxyService.getObject (package:dwds/src/services/chrome_proxy_service.dart:423:19)
#5      VmServerConnection._delegateRequest (package:vm_service/src/vm_service.dart:1288:51)
#6      _rootRunUnary (dart:async/zone.dart:1192:38)
#7      _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#8      _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
#9      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#10     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:266:7)
#11     _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:134:11)
#12     _MapStream._handleData (dart:async/stream_pipe.dart:234:10)
#13     _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:166:13)
#14     _rootRunUnary (dart:async/zone.dart:1192:38)
#15     _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#16     _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
#17     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#18     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:266:7)
#19     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:779:19)
#20     _StreamController._add (dart:async/stream_controller.dart:655:7)
#21     _StreamController.add (dart:async/stream_controller.dart:597:5)
#22     new WebSocketImpl.fromSocket.<anonymous closure> (package:web_socket_channel/src/copy/web_socket_impl.dart:719:21)
#23     _rootRunUnary (dart:async/zone.dart:1192:38)
#24     _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#25     _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
#26     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#27     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:266:7)
#28     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:70:11)
#29     _EventSinkWrapper.add (dart:async/stream_transformers.dart:17:11)
#30     _WebSocketProtocolTransformer._messageFrameEnd (package:web_socket_channel/src/copy/web_socket_impl.dart:316:22)
#31     _WebSocketProtocolTransformer.add (package:web_socket_channel/src/copy/web_socket_impl.dart:214:46)
#32     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:122:24)
#33     _rootRunUnary (dart:async/zone.dart:1192:38)
#34     _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#35     _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
#36     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#37     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:266:7)
#38     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:779:19)
#39     _StreamController._add (dart:async/stream_controller.dart:655:7)
#40     _StreamController.add (dart:async/stream_controller.dart:597:5)
#41     _Socket._onData (dart:io-patch/socket_patch.dart:1982:41)
#42     _rootRunUnary (dart:async/zone.dart:1196:13)
#43     _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#44     _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
#45     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#46     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:266:7)
#47     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:779:19)
#48     _StreamController._add (dart:async/stream_controller.dart:655:7)
#49     _StreamController.add (dart:async/stream_controller.dart:597:5)
#50     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1527:33)
#51     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1019:14)
#52     _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
#53     _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
#54     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#55     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)
@devoncarew devoncarew added package:dwds P1 A high priority bug; for example, a single project is unusable or has many test failures labels Apr 22, 2020
@devoncarew
Copy link
Member Author

This is something we should address - this means you essentially can't debug a flutter web app in IntelliJ.

@devoncarew
Copy link
Member Author

cc @grouma

@grouma grouma self-assigned this Apr 27, 2020
@grouma
Copy link
Member

grouma commented Apr 27, 2020

What's the workflow for using a custom version of package:dwds with Intellij?

@devoncarew
Copy link
Member Author

What's the workflow for using a custom version of package:dwds with Intellij?

Answered on another channel, but essentially add a local path dep in //packages/flutter_tools/pubspec.yaml, run pub get, and delete //bin/cache/flutter_tools.stamp to force the flutter tool to rebuild itself.

@annagrin
Copy link
Contributor

Some addition, in case it might be helpful for debugging or workaround:

I debugged this a bit during trying out expression evaluation, not sure what triggers it on the IDE side, maybe evaluating 'this' in the main scope?

Basically, the debugger is failing to find the libraryId because objectId parameter in the method below with the following callstack and parameters:

ClassHelper.forObjectId: "classes|null|NativeJavaScriptObject"
Inspector.getObject: "classes|null|NativeJavaScriptObject"
ChromeProxyService.getObject: "classes|null|NativeJavaScriptObject"

which causes libraryId on the following line to be "null"

var libraryId = splitId[1];

I suspect that the same or similar issue causes the error in the variables window in VSCode:

image

@grouma grouma assigned annagrin and unassigned grouma May 1, 2020
@annagrin
Copy link
Contributor

annagrin commented May 1, 2020

Dug a little deeper on this. The problem is that we have a don't yet have a way to properly translate frames and scopes from Javascript to dart - the current translation is heuristic-based and largely relies on JavaScript code being close to dart code. In this particular case, we give 'this' as an available variable in the top main scope, which should not be there at all because it does not exist in dart.

VSCode seems to be getting the variables in a slightly different way from IntelliJ, so it is able to display 'this' but not its fields.

Permanent solution will take some time as it will require information from the frontend server to have proper dart representation of frames and scopes in the debugger:

#982

For now, I will work on a temporary workaround (adjust of filtering of the scope) to unblock debugging in IntelliJ and make the 'this' variable disappear in VSCode.

@devoncarew
Copy link
Member Author

Thanks for the investigation!

annagrin pushed a commit to annagrin/flutter that referenced this issue May 12, 2020
DWDS update includes a bug fix where native JavaScript objects are
not included in list of variables avaiable in scopes.
The bug was causing the IntelliJ dart extension to throw exception
while trying to show 'this' varible in static functions, and VSCode
dart extension to diplay the native javascript objects with error
fields inside.

See: dart-lang/webdev#965
@annagrin
Copy link
Contributor

@devoncarew published dwds and updated flutter (flutter/flutter#56958)

@devoncarew
Copy link
Member Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures package:dwds
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants