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

[debugger] handle paused state when there are 0 frames #2687

Open kenzieschmoll opened 3 years ago

kenzieschmoll commented 3 years ago

Discussion started here: https://github.com/flutter/devtools/pull/2683#discussion_r572410011

We can get into a state where the app is paused but there are not frames. The original discussion started as a question of whether or not we should support stepping in this case. This question still stands, but sparks a larger question of how we can make this case actionable for our users? If there are neither scripts nor frames to show, what will the user experience be like as the user steps / resumes? If they did not manually pause the app, how will the user understand why the app is paused?

In the web case, the app can be paused in some JS or SDK code for which we don't have any frames (do we have scripts at this point @grouma?). Perhaps we could add some fake frame JS that at least communicates to the user that their app is paused in JS code, and then point them to Chrome DevTools for a better JS debugging experience.

@grouma @bkonyi for input on what the debugging workflow should look like in this case for both web and mobile connections.

jacob314 commented 3 years ago

The VM Service protocol already has an affordance to expose JS frames as the VM has a similar challenge with native frames. I would suggest we treat JS frames as native. https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md#codekind

That will make it clearer what is going on if you pause in JS. We don't need to provide debugging support for JS frames just as we don't provide any debugging support for native frames on VM apps. The fact that you can end up paused in SDK js functions worries me a bit as well. Do you have examples of how that can be triggered? On the VM side you never end up paused in native code in the dart sdk so it would be nice to avoid that case on the web as well perhaps with more blackboxing or automated stepping?

bkonyi commented 3 years ago

I'm surprised that we're pausing in non-Dart code in the first place. I'd expect for native/JS frames to show up in traces, but there's really no reason to pause in those frames and I'd say that's a bug.

grouma commented 3 years ago

In the web case, the app can be paused in some JS or SDK code for which we don't have any frames (do we have scripts at this point @grouma?). Perhaps we could add some fake frame JS that at least communicates to the user that their app is paused in JS code, and then point them to Chrome DevTools for a better JS debugging experience.

We may not have a corresponding Dart script for the paused location. For these situations, I believe we used to make a synthetic frame that would read <internal>. I also believe the Dart VM can get into a similar situation. We should be able to easily update the logic here to adjust the frames to our liking.