-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
"Global evaluation is not supported", possible regression #52574
Comments
This example seems to work fine in devtools, I am able to print the value of |
cc @DanTup |
I am seeing the issue on the latest stable channel release of Flutter (3.10.2) when debugging with VSCode. |
Do you see this with your example above? I can reproduce "Global evaluation is not supported" when not paused, but using the example above and being paused I can evaluate ![]() There are two known (but distinct) issues I can reproduce: 1. In the latest SDKs, some variables cannot be evaluated and show "OptimizedOut"There's an issue about that at #52430. I think that might be a VM issue as it occurs in both legacy and SDK debug adapters (although how the error appears is slightly different) 2. Global evaluation is not supported (that is, you cannot evaluate expressions if execution is not paused)This has never been properly supported, but in the legacy debug adapters there were some hacks to try and make it work for some cases. We would pick an arbitrary isolate and its root library (eg. We could consider implementing the same behaviour in the new SDK DAPs, although I'm not sure how useful it really is outside of single-file scripts/trivial apps, as I don't think you'd be able to access most of the globals you want. FWIW, if you're using the new debug adapters, Globals will now show up in the Variables pane alongside Locals, which might provide some of the value of global evaluation. Edit: In the short-term, if you want to force yourself back on to the legacy debug adapters you can add this to your VS Code settings - but be aware that these debug adapters won't necessarily be updated with future language features and in some future update they might not be available. "dart.previewSdkDaps": false |
The standalone loop in the An actual widget tree only allows for the inspection of local global variables: Referring to them during any other breakpoint, however, is a futile endeavour: Those hacks - in whatever way they had been implemented - were, are, and will be needed for a long time. That single exposed root isolate kept things flexible enough to allow setups of this kind: Code
final debug = Debugger();
void main() {
final scope = Reactor(
child: const App(),
debugger: debug,
);
runApp(scope);
}
...
class Debugger {
late final WidgetState? state;
void link(WidgetState state) {
this.state = state;
}
call(String i) => state.inspect(i);
} These expose and bring to light any relevant state through a simple Even when a value-holding And this is just one use case I stumbled upon while putting together a few of my own ideas. |
I think there's some confusion between two different issues. Supporting "global evaluation" in the new debug adapters in the same way as the old one will not resolve any issues where you're seeing "" or are paused at a breakpoint. Those evaluation errors are a different issue being tracked in #52430 (which I'm less familiar with as they're from the VM). You can check this using the setting noted above. Setting I'll have a look at handling global evaluation in the same way for now, but to avoid confusion let's keep these two issues separate - this one specifically for where you see "Global evaluation is not supported" errors, and #52430 for failures like "OptimizedOut" when executing is paused and evaluating is failing. |
This provides support for basic global evaluation matching the legacy DAPs. The first available thread is used (because there's currently no way for the user to select a thread) and we look up a library from a file URI provided in the `context` field. In future I hope there's a standard DAP way of getting a file from the client (see microsoft/vscode#134452). See #52574 See Dart-Code/Dart-Code#4636 Change-Id: I7bfa466001142e7e39ebb270ce65f4746a9affcd Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312980 Commit-Queue: Ben Konyi <bkonyi@google.com> Reviewed-by: Ben Konyi <bkonyi@google.com>
I've pushed some changes to the new debug adapters (80a6670) and Dart-Code (Dart-Code/Dart-Code@7389b2c) to add some basic global eval support. It works similar to the legacy DAPs (picking the first available isolate), but it does use your current open file as the target (instead of just the root library as the legacy DAP did). You'll need both the SDK change and the VS Code extension change for this to work. We'll need some VS Code changes (microsoft/vscode#134452) to be implemented to allow you to select which isolate to evaluate in - but I suspect for the majority of cases the one we pick automatically will be sufficient. |
Updating via
flutter upgrade
to the latest version breaks the ability to inspect global variables - in VS Code, at least. Impossible to inspect any global state outside of the immediate local scope even when the execution is paused, i.g. at a breakpoint, either.The minimal example from the thread of 5 years ago when the feature appears to have been first discussed:
Fails with "global evaluation is not supported".
Possibly related to #52430 and #4555.
Downgrading to Flutter 3.7.6 / Dart 2.19.3 solves the issue.
Will experiment with other attempts to upgrade and reproducible examples of my own, when I find the time.
flutter doctor
[√] Flutter (Channel stable, 3.7.6, on Microsoft Windows [Version 10.0.19045.2965], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.21)
[√] Android Studio (version 4.2)
[√] Connected device (3 available)
[√] HTTP Host Availability
• No issues found!
flutter --version
Flutter 3.7.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 12cb4eb7a0 (3 months ago) • 2023-03-01 10:29:26 -0800
Engine • revision ada363ee93
Tools • Dart 2.19.3 • DevTools 2.20.1
The text was updated successfully, but these errors were encountered: