Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dark mode doesn't switch on and off when the OS automatically switches #158314

Closed
capnajax opened this issue Aug 16, 2022 · 24 comments · Fixed by #210923
Closed

Dark mode doesn't switch on and off when the OS automatically switches #158314

capnajax opened this issue Aug 16, 2022 · 24 comments · Fixed by #210923
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug on-testplan plan-item VS Code - planned item for upcoming themes Color theme issues
Milestone

Comments

@capnajax
Copy link

Type: Bug

  1. Set macOS to automatically switch between light mode and dark mode.
  2. Set VS Code to use different themes for light and dark mode.
  3. Before sunset, ensure you are in light mode. Lock your screen and leave your computer.
  4. Have a nice dinner, go for a bike ride, reconnect with friends and family, enjoy a beautiful sunset, and walk your dog.
  5. Later that night, return to your computer. Note the computer has automatically set dark mode, but VS Code is still on light mode.

You'll have to manually switch macOS back to light mode and back again to dark mode for Code to pick up teh dark mode.

VS Code version: Code 1.70.1 (Universal) (6d9b74a, 2022-08-10T06:09:06.916Z)
OS version: Darwin arm64 21.6.0
Modes:

System Info
Item Value
CPUs Apple M1 Ultra (20 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
webgl: enabled
webgl2: enabled
Load (avg) 6, 6, 5
Memory (System) 128.00GB (2.24GB free)
Process Argv --crash-reporter-id 04103f14-c8dc-42a8-b7b2-1ffef3657f3f
Screen Reader no
VM 0%
Extensions (30)
Extension Author (truncated) Version
vscode-zonefile Com 0.0.4
systemd-unit-file coo 1.0.6
doxdocgen csc 1.4.0
copilot Git 1.40.6471
vscode-pull-request-github Git 0.48.1
vscode-graphql Gra 0.7.3
vscode-graphql-syntax Gra 1.0.4
better-cpp-syntax jef 1.15.19
cmake-language-support-vscode jos 0.0.4
ldif jta 0.2.0
bash-ide-vscode mad 1.14.0
vscode-docker ms- 1.22.1
vscode-dotnet-runtime ms- 1.5.0
python ms- 2022.12.0
vscode-pylance ms- 2022.8.20
jupyter ms- 2022.7.1102252217
remote-containers ms- 0.245.0
remote-ssh ms- 0.84.0
remote-ssh-edit ms- 0.80.0
remote-wsl ms- 0.66.3
cmake-tools ms- 1.11.26
cpptools ms- 1.12.1
cpptools-extension-pack ms- 1.2.0
vsliveshare ms- 1.0.5683
vsliveshare-audio ms- 0.1.91
sqltools mtx 0.23.0
sqltools-driver-pg mtx 0.2.0
vetur oct 0.36.0
cmake twx 0.0.17
vscode-arduino vsc 0.4.12

(3 theme extensions excluded)

A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vsdfh931:30280409
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411cf:30542925
vsaa593cf:30376535
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30449410
vscscmwlcmt:30465135
cppdebug:30492333
pylanb8912cf:30529770
vsclangdf:30486550
c4g48928:30535728
hb751961:30541207
dsvsc012cf:30540253

@aeschli
Copy link
Contributor

aeschli commented Aug 26, 2022

Did you set "window.autoDetectColorScheme": true ?

@aeschli aeschli added the info-needed Issue requires more information from poster label Aug 26, 2022
@capnajax
Copy link
Author

capnajax commented Aug 26, 2022

Yes I did. The colour changes as it should if I change the OS colour scheme manually, but if the colour scheme automatically changes while the screen is locked, e.g I leave for dinner when it's in light mode, but when I unlock my screen that night OS has switched to dark mode, VSCode does not change its colour scheme. The workaround is I change the OS scheme to light and back to dark; then VSCode picks it up.

@darknoon
Copy link

Having the same issue, will try the OS theme workaround!

@aeschli aeschli added themes Color theme issues and removed info-needed Issue requires more information from poster labels Dec 15, 2022
@aeschli
Copy link
Contributor

aeschli commented Dec 16, 2022

This is vey likely an Electron issue. VS Code listens to the OS color theme changes that come from Electron, and I suspect one is missing while the screen is locked.

I you have a chance (and have node and git installed on your machine), can you validate my theory by running this:

  • git clone https://github.com/aeschli/electron-theme-test.git
  • cd electron-theme-test, npm i && npm start
  • a simple electron window opens
  • enjoy your evening
  • when you come back, check the output of the command and paste it here
    There should be some messages showing that the event has been sent

@jamieorc
Copy link

jamieorc commented May 1, 2023

Having same problem

@philoserf
Copy link

shouldUseDarkColors: false, shouldUseHighContrastColors: false, shouldUseInvertedColorScheme: false
shouldUseDarkColors: true, shouldUseHighContrastColors: false, shouldUseInvertedColorScheme: false

I see vscode did also adjust. Still, some behavior has changed. If vscode wasn't listening to the change, it remains in the last active theme even after shutdown and restart.

@jamieorc
Copy link

jamieorc commented May 5, 2023

The latest release 1.78 seems to have fixed this

@philoserf
Copy link

see also: #124572 #120420 #91231

@tylerlaprade
Copy link

@jamieorc, I'm on 1.79.2 and still experiencing this issue

@ananthu-kurup
Copy link

I am facing the same issue and I am on the latest version as of this post:

Version: 1.84.0 Commit: d037ac076cee195194f93ce6fe2bdfe2969cc82d Date: 2023-11-01T11:29:51.160Z Electron: 25.9.2 ElectronBuildId: 24603566 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Darwin arm64 23.1.0

@joaomoreno joaomoreno added the bug Issue identified by VS Code Team member as probable bug label Nov 6, 2023
@joaomoreno
Copy link
Member

This just happened to me as well @aeschli. Unsure what caused it. Restarting VS Code didn't help. To fix it, I unset autoDetectColorScheme and reset it again autoDetectColorScheme and then it started to work.

@htoooth
Copy link

htoooth commented Nov 17, 2023

‌‌Yes, the autoDetectColorScheme needs to be reset.

@solrevdev
Copy link

This is the same for me too. I tend to see the opposite in that I turn my mac on in the morning and while OS and all other apps have gone back into light mode to match the OS, VSCode and VSCode Insiders stay in dark mode.

My workaround is to go into the macOS System Settings. Appearance and toggle from Auto to Dark then Light which forces the change then back to Auto

Screenshot 2023-11-27 at 09 51 20

VSCode:

Version: 1.84.2 (Universal)
Commit: 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e
Date: 2023-11-09T10:52:33.687Z
Electron: 25.9.2
ElectronBuildId: 24603566
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Darwin arm64 23.1.0

VSCode Insiders:

Version: 1.85.0-insider (Universal)
Commit: 055458feab40fc308fc6d70b185068138c8cf8eb
Date: 2023-11-27T05:36:15.984Z
Electron: 25.9.4
ElectronBuildId: 25127168
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Darwin arm64 23.1.0

I think I have the correct settings in VSCode:

Screenshot 2023-11-27 at 09 52 21

@skythomp16
Copy link

This is happening to me everyday and I always have to go and uncheck and recheck the auto detect color scheme box for it to switch. Vs code version info below:

Version: 1.85.1 (Universal)
Commit: 0ee08df
Date: 2023-12-13T09:48:06.308Z (2 wks ago)
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

@giuliospinozzi
Copy link

giuliospinozzi commented Jan 21, 2024

Same for me. macOS Sonoma (latest updates) and VSCode:
Version: 1.85.2
Commit: 8b37750
Date: 2024-01-18T06:40:11.430Z
Electron: 25.9.7
ElectronBuildId: 26354273
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Darwin arm64 23.2.0

@gsimons-nzme
Copy link

gsimons-nzme commented Feb 4, 2024

What helped for me was to open up the settings.json manually and changing some lines. It was like this:

{
    "window.systemColorTheme": "auto",
    "window.autoDetectColorScheme": true,
}

I removed the systemColorTheme line, saved the file (Cmd+S) and then it did immediataly change colors correctly. It also changed the settings.json to this, though obviously that could also be Dark something if you run it in the evening.

{
    "window.autoDetectColorScheme": true,
    "workbench.colorTheme": "Default Light Modern",
}

@giuliospinozzi
Copy link

@gsimons-nzme you are right. Now the problem seems fixed! I think that should be included in the app, to solve definitely this issue on Mac.

@danawoodman
Copy link

Seems like VSCode should remove the window.systemColorTheme setting when auto detect is turned on or at least warn a user about it. As it stands now if you set a color scheme and try to use auto, nothing will work unless you figure this bit out.

@247arjun
Copy link
Member

Did you set "window.autoDetectColorScheme": true ?

Is there a reason that window.autoDetectColorScheme is not set to true out-of-the-box? Pretty much every other application on my Mac has this default, and toggles based on system preference (including Teams, Outlook and other MSFT apps).

@squarewave24
Copy link

"window.systemColorTheme": "auto",

+1

for me just removing this line was the fix:

"window.systemColorTheme": "auto",

@aeschli
Copy link
Contributor

aeschli commented Apr 22, 2024

I created #210902 for the issue with "window.systemColorTheme": "auto

@aeschli aeschli added the plan-item VS Code - planned item for upcoming label Apr 22, 2024
@aeschli aeschli added this to the April 2024 milestone Apr 22, 2024
@aeschli
Copy link
Contributor

aeschli commented Apr 22, 2024

Marking as fixed. I made the following changes:

  • When window.autoDetectColorScheme is not enabled, we use workbench.colorTheme (as before)
  • When window.autoDetectColorScheme is enabled, we use workbench.preferredDarkColorTheme and workbench.preferredLightColorTheme. workbench.colorTheme is ignored, and also not changed
  • Caveat: window.autoDetectColorScheme is ignored it the system color is hardcoded by window.systemColorTheme

@danawoodman
Copy link

Nice work @aeschli 👏

@aeschli
Copy link
Contributor

aeschli commented Apr 23, 2024

Marking as fixed.

@aeschli aeschli closed this as completed Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug on-testplan plan-item VS Code - planned item for upcoming themes Color theme issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.