electron: [Bug]: window transparency not respected (black/gray background) on some systems
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
25, 26, 27, 31, 33, 34
What operating system are you using?
Windows
Operating System Version
Windows 10, Windows 11
What arch are you using?
x64
Last Known Working Electron version
No response
Expected Behavior
When setting these options on a new BrowserWindow, the window should always be transparent regardless of whether or not hardware acceleration is enabled:
new BrowserWindow({
frame: false,
transparent: true,
alwaysOnTop: true
})
Actual Behavior
For some reason, for some people, electron does not respect the transparency or a transparent background color (such as #00000000) and it has a black background when hardware acceleration is enabled.
For some users, disabling hardware acceleration fixes it. Similar to this issue it seems.
Testcase Gist URL
https://gist.github.com/Galkon/c5e195442696a324afa03d9c391e8893 Sample App
Additional Information
Context
Context: We are using electron for a screen overlay at Medal.tv. For everyone on our team, there are no issues with transparency. However, there are some users using our production app which have this issue.
In our app we are still using electron 22 for win 7/8/8.1 compatibility, but I have verified this problem still exists in 25, 26, and 27 (side note, 27 is plagued by this bug too).
Disabling hardware acceleration is a less-than-ideal solution because our app is video-based and you cannot disable it per-window, only for the entire app.
Debugging
I’ve created a sample app which currently can run 15 different test scenarios, all of which still produce a black window for affected users when it should be transparent.
The tests it runs include 15 variations of the following:
- Setting the window size to be smaller than display width / height (mentioned in this issue)
backgroundColorset to#00000000or not set (related issue here?)- Delaying window show vs
show: trueon BrowserWindow initialization - Disabling
thickFrame - Setting
backgroundMaterialtonone - Setting
hasShadowtofalse - Calling
setBackground('#00000000')after initialization - Manually controlling window size via
setBoundsandsetContentSize - Manually calling
setAlwaysOnTopafter initialization
System Specs
I’ve been able to grab some specs of users systems, but I cannot find any correlating factors. It has happened to users on Windows 10, Windows 11, users with a single monitor, users with multiple monitors.
Windows Version (os.release()) |
CPU | GPU(s) | Number of displays | Display resolution(s) |
|---|---|---|---|---|
| 10.0.19045 | Intel® Core™ i7-3770 CPU @ 3.40GHz | NVIDIA GeForce GTX 1060 6GB | 1 | 1280x1024 |
| 10.0.22621 | 12th Gen Intel® Core™ i5-12600KF | NVIDIA GeForce RTX 3080 | 2 | 2560x1080, 1920x1080 |
| 10.0.19045 | AMD Ryzen 5 5600X 6-Core Processor | NVIDIA GeForce RTX 3070 | 1 | 1920x1080 |
| 10.0.22621 | Intel® Core™ i5-10400F CPU @ 2.90GHz | NVIDIA GeForce GTX 1650 | 1 | 1920x1080 |
| 10.0.19045 | Intel® Core™ i5-10400 CPU @ 2.90GHz | NVIDIA GeForce GTX 1080 Ti, Intel® UHD Graphics 630 | 1 | 1920x1080 |
| 10.0.22621 | AMD Ryzen 5 5600G with Radeon Graphics | NVIDIA GeForce RTX 3060 | 1 | 1920x1080 |
| 10.0.22621 | AMD Ryzen 7 7700X 8-Core Processor | AMD Radeon™ Graphics | 3 | 1920x1080, 2560x1440, 1080x1920 |
| 10.0.22631 | 12th Gen Intel® Core™ i5-12400 | Intel® UHD Graphics 730 | 1 | 1920x1080 |
| 10.0.22631 | Intel® Core™ i7-10700KF CPU @ 3.80GHz | NVIDIA GeForce RTX 3070 | 1 | 1920x1080 |
Other Info
- It appears to happen regardless of windows display scaling setting (happens at 100%)
- It appears to happen regardless of whether has an integrated GPU or not
- One user did reinstall Windows 10 after they ran into this on Windows 11, and it was fixed for them. So it seems to me that it is a software issue under certain circumstances that I haven’t pinpointed yet.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 4
- Comments: 32 (4 by maintainers)
bump
reproduced on another user’s computer
associated issue: https://github.com/std-microblock/breeze-shell/issues/1
I reproduced this issue with bare GLFW and OpenGL, the code is here: https://gist.github.com/std-microblock/2d7cb4ed154ed8969d0ca5ec755fa799 This might be the most simple reproducer
Not sure, I don’t know how to test a transparent frameless window with Chrome alone 😅
We have had tens of thousands of users at Medal.tv run into this issue, which is for windows only. Some users have it fixed by tweaking nvidia settings and others have no such luck or don’t have an nvidia gpu.
It’s unlikely a solely Chromium or nVidia issue. I happen to run into exactly same problem on bare-bone WinAPI app written in Rust under 500 LOC with simple layered window (in fact, the search for the solution happen to drive me here from Google). No chromium involved. And I know of report in the wild from AMD GPUs.
Hello, I just happen to run into very same problem with different WinAPI application (my own actually, Rust based with OpenGL renderer). It happen on my PC, and after googling a lot I found this page, so I wish to to share some of my insights:
stays opaque even if losing focus again(correction: losing focus again retriggers correct transparency)RedrawWindow(NULL, ...)(this should redraw entire desktop) has utter no effect.UpdateLayeredWindow()per frame (also with non-NULL args containing unchanged position or size) has utter no effectSetLayeredWindowAttributesper frame has also no effectPlatform: nVidia GeForce / Win 11 <- both up to date