microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.41k stars 29.33k forks source link

`code` CLI still opens duplicate VSCode instance in the macOS dock #139634

Open lgarron opened 2 years ago

lgarron commented 2 years ago

Issue Type: Bug This is a re-file of https://github.com/microsoft/vscode/issues/60579, which does not appear to be fixed for me in the November VSCode release.

VSCode is still opening processes with duplicate dock icons (and therefore slowing down the use of code to open files). Judging from the issue and the accompanying PR, it looks like I'm not the only one who is still experiencing this issue. Unfortunately, the other issues and PRs are closed and locked, so I'm filing this new one.

Simple repro: code new-file.txt

One workaround from the other issue was to use open -b com.microsoft.VSCode. However, this has some challenges:

A proper fix would be really appreciated.

VS Code version: Code 1.63.2 (899d46d82c4c95423fb7e10e68eba52050e30ba3, 2021-12-15T09:37:28.172Z) OS version: Darwin x64 21.2.0 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz (12 x 2900)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled| |Load (avg)|4, 3, 3| |Memory (System)|32.00GB (0.14GB free)| |Process Argv|--crash-reporter-id 98789cd9-b9d1-4ac0-b09a-99c0a9d11695| |Screen Reader|no| |VM|0%|
Extensions (12) Extension|Author (truncated)|Version ---|---|--- custom-window-zoom|cra|1.1.4 vscode-eslint|dba|2.2.2 prettier-vscode|esb|9.0.0 codespaces|Git|1.4.2 vscode-pull-request-github|Git|0.34.2 go|gol|0.30.0 jupyter-keymap|ms-|1.0.0 vsliveshare|ms-|1.0.5200 vs-code-prettier-eslint|rve|3.0.4 fish-vscode|sky|0.2.1 shellcheck|tim|0.18.3 vscode-status-bar-format-toggle|tom|3.0.0
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492cf:30256860 pythontb:30283811 pythonvspyt551:30345470 pythonptprofiler:30281270 vshan820:30294714 vstes263cf:30335440 vscoreces:30384385 pythondataviewer:30285071 vscod805:30301674 pythonvspyt200:30340761 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593:30376534 pythonvs932:30410667 vscop804:30404766 vscop341:30404997 vsrem710cf:30416617 vscexrecpromp3t2:30407763 ```
IllusionMH commented 2 years ago

Do you see same issue if you disable all extensions? May be duplicate of #138712

lgarron commented 2 years ago

Do you see same issue if you disable all extensions? May be duplicate of #138712

Yes, unfortunately code --disable-extensions successfully disables extensions but does not address this issue. 😢

lgarron commented 2 years ago

I also just realized that opening the editor for things like git commit was still super slow. I just added set EDITOR "open -b com.microsoft.VSCode" and that's a lot faster, but I'm worried it will break in other situations.

lgarron commented 2 years ago

I just added set EDITOR "open -b com.microsoft.VSCode" and that's a lot faster, but I'm worried it will break in other situations.

... aaaaand:

Screen Shot 2022-01-23 at 20 58 52

😔

setanarut commented 2 years ago

All extensions are disabled and the new icon is still bouncing when a file is opened with the terminal in the same workspace. disappears in a few seconds

Drarig29 commented 2 years ago

I had the same problem and I used the "Extension Bisect" feature to find the culprit.

In my case it was the extension "Spell Right". I'm posting an issue on their repo: https://github.com/bartosz-antosik/vscode-spellright/issues/497

TylerADavis commented 2 years ago

What would be the best way to troubleshoot this? I just started seeing this behavior (double dock icons) the last few weeks, perhaps after an update to an extension or vs code itself. I tried code --disable-extensions . as in https://github.com/microsoft/vscode/issues/139634#issuecomment-999541635, but the issue persists.

image

Drarig29 commented 2 years ago

What would be the best way to troubleshoot this? I just started seeing this behavior (double dock icons) the last few weeks, perhaps after an update to an extension or vs code itself. I tried code --disable-extensions . as in https://github.com/microsoft/vscode/issues/139634#issuecomment-999541635, but the issue persists.

image

As I said just before, try using the "Extension Bisect" feature. You can start it in the Extensions panel, with the "..." menu.

More information: https://code.visualstudio.com/blogs/2021/02/16/extension-bisect

TylerADavis commented 2 years ago

Thanks @Drarig29 ! I had expected --disable-extensions to stop all extensions from running and rule out the possibility of being extension related, but that seems to not be the case. I ended up having the same extension as the culprit.

lgarron commented 2 years ago
  • In addition to setting an alias/function for code in your shell, you will need to set up $EDITOR separately (at least in some shells).

I've tried to debug this a bunch of times, and concluded that it's impractical (or maybe even impossible) to maintain enough workarounds for this. I use fish, and all the combinations of abbreviations / $EDITOR / $VISUAL just don't seem to work for the "edit commandline with external editor" functionality.

If I want to use the workaround for the slow duplicate VSCode instance, I inevitably have to leave other things broken right now. 😕

Given that code --disable-extensions . and extension bisect both show that this happens for vanilla VSCode, are there any useful steps I can take to help pinpoint the issue?

lgarron commented 2 years ago

VSCode has been frustratingly slow to load[^1] for me, and I've been having issues pinning it down, since it occurs even for code --disable-extensions. I now believe the root cause is related to this issue. :-/

[^1]: Slow to load, slow to create files, slow to open files. Once a file is open, things are fast, though.

pcutillas commented 1 year ago

This isn't a direct solution to this, but if you don't use the recent apps section of the dock, you can disable it: https://www.howtogeek.com/714379/how-to-hide-recent-apps-from-the-mac-dock/#:~:text=In%20System%20Preferences%2C%20select%20%E2%80%9CDock,will%20disappear%20from%20your%20Dock.

lgarron commented 1 year ago

This isn't a direct solution to this, but if you don't use the recent apps section of the dock, you can disable it: https://www.howtogeek.com/714379/how-to-hide-recent-apps-from-the-mac-dock/#:~:text=In%20System%20Preferences%2C%20select%20%E2%80%9CDock,will%20disappear%20from%20your%20Dock.

For what it's worth, I've personally had the recent apps section disabled for a long time, and it seems to be unrelated to this issue (which is still happening, and I've just learned to grit my teeth and live with the slight slowdown and extra visual distraction of using the original code binary as my editor so that I don't have to deal with the bugs and security issues of the workaround alternatives).

plttn commented 1 year ago

I can replicate this with zero extensions enabled, as long as Code is running.

In other words:

  1. run code . from Terminal
  2. Only pinned Dock icon bounces.
  3. work on that window for a bit, then realize "oh I need to work on another project"
  4. use the Terminal to navigate to the new project
  5. run code .
  6. duplicate icon appears
conradwt commented 1 year ago

@plttn I'm starting to see a similar issue. Furthermore, the more times I execute code-insiders . the more VSCode icons I'll see in the Dock. This issue always starts with the editor window not resizing to the full size of the monitor.

Screenshot 2023-08-30 at 9 31 53 PM

cameronelliott commented 1 year ago

Also seeing this issue.

image
thadbloom commented 1 year ago

I solved it on my machine with this:

alias code="open -b com.microsoft.VSCode"

Not really an actual solution. But this was annoying to me.

conradwt commented 1 year ago

Here's a recent error report and a picture of what I'm seeing on the screen when I attempt to make VSCode - Insiders full-screen.

error report:

https://gist.github.com/conradwt/4fcdc1f3447ea3306923cdccf7e98191

Screenshot 2023-09-25 at 7 58 12 PM

davilima6 commented 10 months ago

I confirm the issue persists using latest. Besides, the open workaround fails to jump to a specific line as --args is ignored:

open -b com.microsoft.VSCode --args --goto myFile.ext:10

Which I need for Run Command on iTerm's Semantic History:

/usr/bin/open -b com.microsoft.VSCode --args --goto \1:\2

I'm using regular VS Code in Mac Sonoma 14.2.1:

Version: 1.85.1 (Universal)
Commit: 0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2
Date: 2023-12-13T09:48:06.308Z
Electron: 25.9.7
ElectronBuildId: 25551756
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Darwin arm64 23.2.0
cameronelliott commented 10 months ago

Yeah,the work around is lame, it broke my arguments from working also. It would be nice to not need the work around so the regular flags worked.

conradwt commented 10 months ago

After upgrading to macOS Sonoma, all the VSCode - Insider issues that I reported went away for me.

davilima6 commented 10 months ago

I'm using macOS Sonoma 14.2.1 and I confirm the issue persists using the latest regular (non-Insider) VS Code.

Besides, the open workaround fails to jump to a specific line as --args is ignored:

open -b com.microsoft.VSCode --args --goto myFile.ext:10

Which I need for Run Command on iTerm's Semantic History:

/usr/bin/open -b com.microsoft.VSCode --args --goto \1:\2

Using:

Version: 1.85.1 (Universal)
Commit: 0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2
Date: 2023-12-13T09:48:06.308Z
Electron: 25.9.7
ElectronBuildId: 25551756
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Darwin arm64 23.2.0
fserb commented 9 months ago

On MacOS Sonoma 14.2.1, seeing multiple instances of VSCode when using the code cli.

The open workaround fails to parse arguments properly (you can check by trying: open -b com.microsoft.VSCode --args --new-window doesn't work at all.

AntonellaMorittu commented 8 months ago

In your Mac Dock Settings, disable the recent apps in the dock and it will work just fine 👍

Screenshot 2024-03-15 at 11 41 24
lgarron commented 8 months ago

In your Mac Dock Settings, disable the recent apps in the dock and it will work just fine 👍

Screenshot 2024-03-15 at 11 41 24

I've had recent apps disabled in the dock for a long time. It didn't help for me a year ago and still doesn't help now, unfortunately. The bug still persists.