Skip to content

macOS: Unable to quit when all windows are closed #172967

Closed

Description

Type: Bug

VS Code has trouble quitting with the cmd+Q shortcut on macOS. When I use cmd+Q quickly after cmd+shift+W, VS Code hangs and remains open. I can tell that VS Code is open by the indicator dot under its icon in the dock.

Steps to reproduce:

  1. Open VS Code on macOS
  2. Use cmd+shift+W to close all windows
  3. Quickly use cmd+Q to quit VS Code
  4. Notice that the "Code" title in the macOS menubar flashes
  5. Notice the dot under VS Code's icon in the dock and that VS Code remains open

I've seen this bug in both VS Code stable and insiders.

Here's a screen recording of this bug:

vscode-no-quit.mp4

Notice how the "Code" title in the menubar flashes as the windows close. It seems like VS Code is receivng the quit event, but it's getting stuck somewhere.

VS Code version: Code 1.74.3 (97dec17, 2023-01-09T17:05:47.808Z)
OS version: Darwin arm64 21.6.0
Modes:
Sandboxed: No

System Info
Item Value
CPUs Apple M1 Max (10 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) 2, 2, 2
Memory (System) 64.00GB (36.59GB free)
Process Argv --crash-reporter-id 3488aeac-bc57-46d3-ac1a-73d78d4582d6
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
vscoreces:30445986
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593cf:30376535
pythonvs932:30410667
cppdebug:30492333
vscaat:30438848
vsclangdf:30486550
c4g48928:30535728
dsvsc012cf:30540253
azure-dev_surveyone:30548225
pyindex848:30577860
nodejswelcome1:30587005
2e4cg342:30602488
pyind779:30647091
89544117:30613380
2i9eh265:30646982

Activity

  1. jungaretti commented on Jan 31, 2023

    @jungaretti
    Author

    #172846 may be related to this bug.

  2. VincentDondain commented on Jan 31, 2023

    @VincentDondain

    Something similar happens to me when I update my VSCode insider, the editor restart after the update and I do not have the close buttons anymore in the UI, nor can I quit the program with cmd + Q, I need to force quit it.

  3. bpasero commented on Feb 1, 2023

    @bpasero
    Contributor

    Can you try to reproduce with our nightly insider builds? You can give our preview releases a try from: https://code.visualstudio.com/insiders/

  4. added
    info-needed
    on Feb 1, 2023
  5. jungaretti commented on Feb 1, 2023

    @jungaretti
    Author

    Here's a repro with insider:

    insiders-quit.mp4

    Version: 1.75.0-insider (Universal)
    Commit: 0615c4f
    Date: 2023-01-31T00:09:14.434Z
    Electron: 19.1.9
    Chromium: 102.0.5005.194
    Node.js: 16.14.2
    V8: 10.2.154.23-electron.0
    OS: Darwin arm64 21.6.0
    Sandboxed: Yes

  6. bpasero commented on Feb 1, 2023

    @bpasero
    Contributor

    Can you try to run code --disable-extensions --user-data-dir <directory> where <directory> is an empty folder? This will ensure Code is starting with a fresh data directory, e.g. no specific settings and without any extensions running.

  7. jungaretti commented on Feb 1, 2023

    @jungaretti
    Author

    I see the same behavior with code-insiders --disable-extensions --user-data-dir <directory>

    insiders-vanilla.mp4
  8. bpasero commented on Feb 1, 2023

    @bpasero
    Contributor

    Please see if you can find any logged output that could help us find the source of the issue:

    • run code --verbose from the command line and attach the output
    • in Code select Help | Toggle Developer Tools and select the Console
    • attach any output you see in the Console you can find

    Thanks!

  9. jungaretti commented on Feb 1, 2023

    @jungaretti
    Author

    Here's the complete output of code-insiders --disable-extensions --user-data-dir /var/folders/2g/cjbxg4p94_925xh94s396hth0000gn/T/tmp.kxnJXdZL --verbose &> quit-failed-log.txt

    quit-failed-log.txt

    I see CommandService#executeCommand workbench.action.closeWindow" on line 472 and CommandService#executeCommand workbench.action.quit" on line 483. It looks like VS Code is hearing both cmd+shift+W and cmd+Q. I think the problem must come from the workbench.action.quit command.

  10. bpasero commented on Feb 1, 2023

    @bpasero
    Contributor

    Yeah so if workbench.action.closeWindow command runs, then you are basically left with a VS Code app that still runs but has no windows opened. But that should not be a command that runs by default, unless you have keyboard shortcuts defined that are any different from the defaults?

  11. jungaretti commented on Feb 1, 2023

    @jungaretti
    Author

    All of my screen recordings show cmd+shift+W followed by cmd+Q. That's my daily flow and I encounter this bug most when following it. Sorry if that wasn't clear.

    cmd+Q alone feels more reliable than cmd+shift+W followed by cmd+Q. Here are the logs from using just cmd+Q where VS Code quits properly:

    quit-success.txt

    These logs look different than the failure logs. I don't see closed application storage in the logs where VS Code didn't quit properly.

  12. jungaretti commented on Feb 1, 2023

    @jungaretti
    Author

    Maybe there's a race condition between workbench.action.closeWindow and workbench.action.quit when closing the folder/workspace? I don't see Request to stop watching or stopping file watcher in the failure logs.

  13. bpasero commented on Feb 1, 2023

    @bpasero
    Contributor

    Oh, what? You press Cmd+Shift+W and then Cmd+Q? Would have really helped to indicate this in the beginning.

    How fast do you press the one after the other?

  14. jungaretti commented on Feb 1, 2023

    @jungaretti
    Author

    Oh, what? You press Cmd+Shift+W and then Cmd+Q? Would have really helped to indicate this in the beginning.

    My steps to reproduce include the cmd+shift+W step, but my description wasn't accurate. I just edited the issue for clarity.

  15. 44 remaining items

  16. jungaretti commented on Feb 21, 2023

    @jungaretti
    Author

    Yes, I can repro with the exploration build you shared. I see the same symptoms as stable and insiders. Disabling telemetry with "telemetry.telemetryLevel": "off" still fixes the problem

    exploration-telemetry.txt
    exploration-no-telemetry.txt

  17. bpasero commented on Feb 22, 2023

    @bpasero
    Contributor

    Vincent Dondain (@VincentDondain) for you any special network settings involved? VPN? Proxy?

  18. bpasero commented on Feb 22, 2023

    @bpasero
    Contributor

    JP Ungaretti (@jungaretti) out of curiosity because we just made some fundamental changes to the shared process, can you:

    • use VS Code insiders
    • make sure telemetry is enabled again as usual to reproduce the issue
    • set window.experimental.sharedProcessUseUtilityProcess in settings to enabled
    • restart
    • try to reproduce the issue
  19. deepak1556 commented on Feb 22, 2023

    @deepak1556
    Collaborator

    how can a possible pending XHR request block app.quit in Electron

    This seems to point an issue with the net module in the main process blocking the event loop on pending requests.

    JP Ungaretti (@jungaretti) Christian Klaussner (@klaussner) can you try the following settings to confirm if the issue persists, thanks!

    "developer.sharedProcess.redirectRequestsToMain": false
    "window.experimental.sharedProcessUseUtilityProcess": false
    "telemetry.telemetryLevel": "all"
    
  20. bpasero commented on Feb 22, 2023

    @bpasero
    Contributor

    👍 worth mentioning though, that in stable we have neither enabled the utility process for shared process nor developer.sharedProcess.redirectRequestsToMain by default, but its worth a try, maybe one of the users changed the settings.

  21. klaussner commented on Feb 22, 2023

    @klaussner
    Contributor

    Do people that see this have any special firewall enabled or network monitor?

    I tested it on two different devices in two locations/networks (without a VPN or firewall) and couldn't see a difference.

    Can you try the following settings to confirm if the issue persists, thanks!

    The issue persists with these settings. 🙁


    I don't know if it helps, but if you monitor the requests sent to the telemetry endpoint with mitmproxy, you can see that the final requests are handled differently, depending on the timing:

    • If the app doesn't quit, requests are sent (and responses are received) after ⌘+Q (first part of the video).
    • If the app quits, the final request is aborted immediately (second part of the video).
    VS.Code.telemetry.requests.mp4
  22. added
    macos
    on Feb 23, 2023
  23. jungaretti commented on Mar 1, 2023

    @jungaretti
    Author

    JP Ungaretti (@jungaretti) Christian Klaussner (@klaussner) can you try the following settings to confirm if the issue persists, thanks!

    Yes, the issue persists with these settings.

  24. deepak1556 commented on May 15, 2023

    @deepak1556
    Collaborator

    JP Ungaretti (@jungaretti) Christian Klaussner (@klaussner) can you start the application with the following arguments --trace --trace-category-filter="browser,io,ipc,net,mojom,renderer_host,shutdown,disabled-by-default-lifecycles,disabled-by-default-network", perform the steps below,

    1. Close all open windows Ctrl + Shift.+ W
    2. Quit the application Cmd + Q
    3. As per the bug, application should still hang around in the dock
    4. Open a new window from this running instance
    5. Open command paletter Cmd + Shift + P and run Developer: Stop Tracing
    6. Attach the generated trace in this issue thread.
  25. jungaretti commented on May 16, 2023

    @jungaretti
    Author

    I'm struggling to repro the bug with code-insiders, and to fix it in code I simply disabled telemetry. I'll share the trace as soon as I can.

  26. klaussner commented on May 17, 2023

    @klaussner
    Contributor

    Same here. I can't reproduce the issue with the latest Insiders build.

  27. locked and limited conversation to collaborators on Jul 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

freeze-slow-crash-leakinfo-neededmacostelemetry

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions