flutter / devtools

Performance tools for Flutter
https://flutter.dev/docs/development/tools/devtools/
BSD 3-Clause "New" or "Revised" License
1.56k stars 321 forks source link

Suggestion: Show global variables in variable window #5295

Open annagrin opened 1 year ago

annagrin commented 1 year ago

Currently the vm service protocol exposes globals per library in https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md#library

We have an occasional ask from customers for exposing global variables for inspection in dart DevTools. Would it be possible to add them to the variable window (and separate globals and locals into different groups)?

VM service implementations currently support evaluation of globals (that are available in the current scope) in the evaluation box, so it seems feasible to show globals upfront.

Note: might need additional support from implementations of VmServiceInterface. On web platform, for example, globals are lazily in created in JavaScript and will require calling a getter. In this case we could show a ... next to a global name and call the getter on click.

annagrin commented 1 year ago

/cc @elliette

kenzieschmoll commented 1 year ago

@DanTup does VS code support this use case?

DanTup commented 1 year ago

Not currently, but I don't see why we couldn't show them in the Variables window alongside the locals (we currently show a "Locals" section, so we could add "Globals" alongside it - and presumably show those from the library containing the current frame?).

DanTup commented 1 year ago

Some basic support (which I expect won't cover web based on the comments above) for this has landed in DDS for VS Code/DAP clients. It'll show up in Flutter master after the next DDS release/roll.

Screenshot 2023-02-28 at 17 22 25