Description
In the Dart extension we have a "New Project" command that asks the user for some input (such as a directory and a project name) and creates a new project for them. A while back, I noticed that between prompting for a folder (using showOpenDialog) and the project name (using an input box) there was sometimes a long delay of ~10 seconds. It doesn't happen all the time, and seems to reproduce most often if I have left VS Code open for > 10 minutes and then tried to execute the command (this might just be coincidence though, it's quite intermittent).
I reviewed the code, and there was basically nothing between those two calls that could take any time. We do some fs.exist()
calls to compute a project name, however I added some console-log timing and found the delay actually occurs while at one of the await
s (such as getting the response from showOpenDialog
). I assumed there was some other extension code being triggered that was blocking the extension host preventing that code from continuing for a while.
However, I was able to capture some extension host profiles while reproducing the issue, and they don't contain any code:
slow_flutter_new_project.cpuprofile.txt
So my feeling is that this delay might be occurring outside of the extension host inside one of the other processes. I was able to reproduce it while profiling from the built-in Chrome dev tools, however that also doesn't seem to show anything:
vs_code_devtools_profile-20250619T165606.json
I noticed when trying to use --prof-startup
that there is mention of a "renderer" process, but I don't know if that's the same one I profiled above (--prof-startup
is unfortunately broken - see #251014 - and it's not clear to me if that would keep profiling enough for me to reproduce anyway).
So, that leaves me stuck - I'm seeing a long delay, but neither of the profiles seem to provide any clue what it is. I'm hoping someone can provide some suggestions about what else I can profile to try and track down what is occurring during this delay.
I can provide steps to reproduce, but since it's quite intermittent, I'm not sure if that will help:
- Install the Dart + Flutter extensions
- Set up a Flutter SDK
- Run the Flutter: New Project command
- Choose a folder to create the project in
- (you may see a long delay of > 10s here)
- You'll now be prompted for a name for the project
Most of the time it is instant, but now and then it takes a long time.