Make it easier to find/run Flutter apps in profile mode #765
There's not a great way to do this right now (at least as I'd like), though perhaps we could do something more basic.
What I'd like to do:
Doing that requires that we can identify the selected launch config (microsoft/vscode#47122).
Without that, what we could do:
This makes things a little different to when you hit
We could also add an additional "Profile" CodeLens link (next to Run/Debug on the main method) that would do the same, although for Flutter apps it's probably not that common for users to launch from there (it's probably not that often you're inside your
For the specific user I mentioned above, he did have some environmental variables in his launch config, so supporting your first option is needed.
However, I agree with you that most Flutter projects probably don't have an existing launch.config. Having the IDE create a default launch.config for building the app in profile mode would be convenient. Maybe the following logic would be reasonable when the user issues the command "Flutter: Run in Profile Mode":
What do you think?
I think creating the launch.json is a little awkward - depending on the type of workspace open it could go into different places (for example in a multi-root workspace, the configs may go into the workspace file, or any of the individual folders). VS Code already has some UI to help create them that I think may be better to guide people towards:
Clicking the "Create a launch.json file" link creates the file (and in a multi-root workspace lets the user choose which folder or whether to add to workspace config). Clicking "Show all automatic debug configurations" lets you pick a debug config and run it without the file (and we get to choose which ones go there).
So two things that I think would help (though I'm not sure they go far enough) would be:
Note: Clicking the cog icon on the right would instead copy that config into launch.json for you to customise.
Perhaps we could still add a command, but simplify it slightly to not try to create the file:
In the interest of improved visibility (even if it's a less common way to run your Flutter app), I also added a CodeLens link for the main method of Flutter projects. Like Run/Debug this will always run a default empty config (the same as the Run config, but with `"flutterMode": "profile"), but also open the DevTools Performance page once the VM Service is available.
This sounds reasonable. I do believe increasing the visibility of profile mode is very important. Both providing a command in the palette and a CodeLens link will be helpful. When Dart Code runs a profile build with the default configuration, would it make sense to show a message such as "Running the app in profile mode with a default configuration. To customize it, create or edit
I like this idea. The caveat is that this could be the first time someone heard of "profile mode". Maybe we can add an inline comment to explain it briefly and link to documentation, if that's possible in
sgtm - I'd already added the CodeLens, and now I've added a Debug: Profile Flutter app command (I put it in Debug to match all the others for launching and attaching - "Debug" here means VS code's "launch the app" functionality rather than specifically debug mode).
I'd added a one-time prompt to this effect when launching from the command palette. I didn't add it to the CodeLens as the existing Run/Debug links also use default configs (unless overwritten by launch.json) so that seems expected.
To behave more like the CodeLens, I also named it "Profile Flutter app" rathe than "Start in Profile Mode" and made it also open the DevTools Performance view.
My only niggle with this command is that if you do customise it in launch.config then you run this command again, it will continue to run the default config and not your new launch config. To use your launch config, you'd need to select it on the Debug side bar and start from there (or press
Unfortunately we're unable to add comments here - we only supply the launch config to VS Code and it generates the file from that. It's not great, but if you search for "flutter profile mode" the top few search results on Google at least do a pretty good job of explaining what it is.
There's a beta version with the changes in here if you'd like to test it out before release:
If anything doesn't work as expected, please let me know!