Repository navigation
Closed as not planned
Closed as not planned
Copy link
Labels
17-x-y18-x-y19-x-ybug 🪲component/native-themehas-repro-repoIssue can be reproduced by cloning a git repoplatform/linux
Description
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
17.1.2
What operating system are you using?
Other Linux
Operating System Version
Fedora Linux 36 (Workstation Edition Prerelease)
What arch are you using?
x64
Last Known Working Electron version
No response
Expected Behavior
nativeTheme should reflect the light/dark scheme configured in the OS
Actual Behavior
nativeTheme.shouldUseDarkColors is always false.
Testcase Gist URL
No response
Additional Information
git clone https://github.com/aeschli/electron-theme-test.gitcd electron-theme-test,npm i && npm start- a simple electron window opens
- switch between light and dark in the OS
- the window should change the menu bar colors and the terminal should print
shouldUseDarkColorsmatching the OS scheme.
Terminal output
> [email protected] start
> electron-forge start
✔ Checking your system
✔ Locating Application
✔ Preparing native dependencies
✔ Launching Application
shouldUseDarkColors: false, shouldUseHighContrastColors: false, shouldUseInvertedColorScheme: false
shouldUseDarkColors: false, shouldUseHighContrastColors: false, shouldUseInvertedColorScheme: false
libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[4553:0406/110408.146875:ERROR:sandbox_linux.cc(377)] InitializeSandbox() called with multiple threads in process gpu-process.
[4553:0406/110412.166946:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 1 times!
[4553:0406/110449.772046:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 2 times!
[4553:0406/110449.783890:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 3 times!
Reacted by jannuary, Joel Jose, Daniel, Siggsy, Óscar Fernández Díaz, Patryk Kościk, Taylor, ozboss, Mauricio Robayo, Bart Louwers and 26 more
Metadata
Metadata
Assignees
Labels
17-x-y18-x-y19-x-ybug 🪲component/native-themehas-repro-repoIssue can be reproduced by cloning a git repoplatform/linux
Type
Projects
- StatusShow more project fieldsDoesn't Block Stable

Activity
[-]nativeTheme API not working on Fedora Workstation [/-][+]nativeTheme API not working on Fedora Workstation 36 / Gnome 42[/+]ckerr commentedon Apr 26, 2022
I'm not able to reproduce this when running the test repo (Electron 17.1.2) on Ubuntu 22.04, which like Fedora 36 is also running GNOME 42. Wayland graphics. When I load System settings, go to Appearance, and click "Light" or "Dark", Electron's theme updates correctly along with the rest of the desktop.
I'll try installing Fedora 36 to see if that changes things.
As an aside, I do see that the console log is triggered twice each time I toggle between light and dark:
I'm mentioning it here since It's possible that this is relevant to the bug and that second event is needed to make Electron's theme change. It's also possible that, this is a red herring, that the testcase registered for the event twice, or that Electron is generating unnecessary duplicate events 👀 :
I'll try installing Fedora 36 to see if that helps in reproducing this issue.
Jeter-work commentedon Jun 3, 2022
New install of Fedora 36 and I see this issue as well. Specifically with VS Code 1.67.2. Came here from: microsoft/vscode#146804
senekor commentedon Jun 5, 2022
The work around posted here worked for me:
Gnome Tweaks -> Appearance -> Themes, Legacy Application -> Select Dark theme (Adwaita-dark)
I have also figured out for myself a way to script this:
The first line is how Fedora 36 seems to "generally" handle dark mode, while the second covers those edge cases like vscode / electron.
proninyaroslav commentedon Jun 5, 2022
@remlse
But this will not follow the system theme change. Although it's possible to write a script that would listen to the DBus theme change event and change it globally.
proninyaroslav commentedon Jun 5, 2022
I also use a ready-made extension for GNOME 42 which allows to force a theme switch for legacy applications (this is disabled by default in the extension settings) https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension
I definitely recommend it to those who want to have real theme switching in GNOME 42 like in macOS.
12 remaining items
escape0707 commentedon Apr 4, 2023
Problem solved in Chinese Communist Party ways.Ige-fi commentedon Apr 10, 2023
The upstream issue in Chromium has been fixed today, at long last. They have implemented a new
DarkModeManagerLinuxview that monitors the FreeDesktop settings portal, and falls back to GTK/QT theme monitoring for systems where the portal is not supported. As far as I can see, this means that the current workaround for GTK themes in the nativeTheme API of Electron is no longer needed.q234rty commentedon Jun 29, 2023
I believe this was not fixed by just updating chromium to 114, the workaround mentioned above probably needs to be removed.
Ige-fi commentedon Jul 7, 2023
@q234rty is correct. Chromium 114 did fix the prefers-color-scheme query for newer distros that implement the XDG Settings portal. You can test it yourself by using a suitable desktop environment (e.g. Fedora 38 / GNOME 44), downloading the latest Chrome/Chromium, opening this site, and toggling the dark mode setting in the desktop environment’s settings. The style of the page should change immediately.
However, since Electron 25 still uses the aforementioned workaround, which is designed for older Linux distributions and older Chromium, the
nativeThemeAPI cannot possibly work as expected for newer systems that rely solely on the Settings portal, since Electron overrides Chromium’s (now correct) current behaviour.Reproduction steps
I have updated the reproduction repository example by @aeschli.
Prerequisities: use Fedora 38 / GNOME 44
git clone https://github.com/Igetin/electron-25-prefers-color-scheme-test cd electron-25-prefers-color-scheme-test npm install npm startWhat should happen
shouldUseDarkColors: falsewill be printed in the terminalshouldUseDarkColors: truewill be printed in the terminalWhat actually happens
The window has black text on a white background at all times, and does not respond to the system’s preference. Only
shouldUseDarkColors: falseis printed to the terminal.Here’s also an example screenshot of the erroneous behaviour. As can be seen, the dark preference is enabled in the Fedora 38 system, but the Electron window does not reflect this.
Fix
To fix this, Electron must remove the previously mentioned workaround. Chromium now handles the
prefers-color-schememedia query in a backwards-compatible manner, which means that it should work for both older distros/apps (that rely on the selected GTK/Qt theme) and newer distros/apps (that rely on the XDG Settings portal preference). Electron no longer needs to provide special handling for Linux distros in thenativeThemeAPI.In this context, “old distros” are basically any distros that still rely on GTK themes for light/dark preference. This includes GNOME 41 or older (example: Ubuntu 18.04) and all currently supported Plasma releases (example: Kubuntu 22.04).
GNOME implemented the XDG Settings portal in GNOME 42 . Distros that have 42 or a newer version are “new distros” in this context (examples: Fedora 36+, Ubuntu 22.04).
(Note: KDE technically implemented the XDG Settings portal in Plasma 5.24. However, if you toggle between light and dark appearance in the system settings, it currently still changes the GTK theme under the hood.)
@codebytere Can you please reopen the issue, as this is still unresolved and reproducible on the latest Electron? This was inadvertently closed as a duplicate a few months ago. You marked 36040 as a duplicate of this issue (33635), so this issue should have stayed open as it is the earliest report of the problem.
Danik1601 commentedon Jul 30, 2023
@codebytere I believe you closed this issue by accident. Please reopen it
aeschli commentedon Aug 24, 2023
@codebytere Can this issue be reopened?
I tested on Fedora Linux 38 (Workstation Edition), Gnome 44.3, Wayland
Electron 26.1.0, Node.js 18.16.1, Chromium 116.0.5845.97
git clone https://github.com/aeschli/electron-theme-test.gitcd electron-theme-test, npm i && npm startExpected:
shouldUseDarkColors: falsewhen the OS uses a light color scheme, orshouldUseDarkColors: trueif the OS color scheme is darkActual:
Always
shouldUseDarkColors: false,is printed, even when the OS color scheme is dark.In the OS settings, switch between light and dark while the window is still open
Expected:
Actual:
Test running under Wayland:
cd electron-theme-test, npm i && npm start-waylandSame problem.
itsyigid commentedon Nov 6, 2023
Tested just like @aeschli has done on Arch Linux, Hyprland (Wayland) without no success.
I attached a video demonstrating the issue; you can clearly see Chromium switching themes as the GTK theme and colour scheme change, and also the logged CLI messages noticing the change; however, the Electron app doesn't react in any way.
test.mp4
real-or-random commentedon Nov 6, 2023
Note: the video doesn't work (here in my Firefox). "Video can't be played because the file is corrupt."
itsyigid commentedon Nov 6, 2023
I triple checked the attachment, and it seems to work on Chromium. I'll record again with a different codec once I've the time.
strophy commentedon Nov 7, 2023
Plays for me by downloading it and using VLC
johnny-brav0 commentedon Jan 5, 2024
This issue is still there on Fedora 39 (Workstation Edition) running GNOME 45.2
Terminal output:
shouldUseDarkColorsseems to change but only the title bar changes to dark/light.EDIT:
The Open and Save As dialog boxes are white, other ones which appear like "Are you sure you want to ... something" go dark when using "custom" dialog style.
itsyigid commentedon Jan 6, 2024
It's apparent that we won't be getting a real fix...
real-or-random commentedon Jan 7, 2024
@codebytere Giving this another try. Can you please re-open this issue? It was closed by accident.
spease commentedon Nov 13, 2024
This still seems to be indirectly causing an issue with Signal, are there any plans to get this fixed?
real-or-random commentedon Nov 13, 2024
AFAIU the discussion and in particular @Igetin's very detailed analysis (#33635 (comment)), the solution should be simply reverting fdf40ce. Perhaps this should be submitted as a PR? This would at least raise renewed attention to the issue.
(I don't have the time right now, so for the moment, I just hope that someone else can step up here.)