Repository: electron
Issue: [Bug]: window transparency not respected (black/gray background) on some systems
Labels: bug :beetle:,has-repro-gist,26-x-y,27-x-y

### Preflight Checklist

- [X] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/main/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [X] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a bug report that matches the one I want to file, without success.

### Electron Version

25, 26, 27, 31

### 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
})
```
![image](https://github.com/electron/electron/assets/1406556/d604cc98-e846-4dd1-bd86-85f1c1140076)


### 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.
![image](https://github.com/electron/electron/assets/1406556/983c06a7-647e-4aff-aee8-0d90bf97885d)

It appears the issue is resolved when disabling hardware acceleration. Similar to [this issue](https://github.com/electron/electron/issues/2170#issuecomment-736223269) it seems.

### Testcase Gist URL
https://gist.github.com/Galkon/c5e195442696a324afa03d9c391e8893
[Sample App](https://github.com/Galkon/electron-overlay-test)

### 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](https://github.com/electron/electron/issues/39959) 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](https://github.com/Galkon/electron-overlay-test) 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](https://github.com/electron/electron/issues/27286#issuecomment-823201224))
- `backgroundColor` set to `#00000000` or not set ([related issue here?](https://github.com/electron/electron/issues/39764))
- Delaying window show vs `show: true` on BrowserWindow initialization
- Disabling `thickFrame`
- Setting `backgroundMaterial` to `none`
- Setting `hasShadow` to `false`
- Calling `setBackground('#00000000')` after initialization
- Manually controlling window size via `setBounds` and `setContentSize`
- Manually calling `setAlwaysOnTop` after 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(R) Core(TM) i7-3770 CPU @ 3.40GHz    | NVIDIA GeForce GTX 1060 6GB                           | 1                  | 1280x1024                       |
| 10.0.22621                       | 12th Gen Intel(R) Core(TM) 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(R) Core(TM) i5-10400F CPU @ 2.90GHz  | NVIDIA GeForce GTX 1650                               | 1                  | 1920x1080                       |
| 10.0.19045                       | Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz   | NVIDIA GeForce GTX 1080 Ti, Intel(R) 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(TM) Graphics                               | 3                  | 1920x1080, 2560x1440, 1080x1920 |
| 10.0.22631                       | 12th Gen Intel(R) Core(TM) i5-12400        | Intel(R) UHD Graphics 730                             | 1                  | 1920x1080                       |
| 10.0.22631                       | Intel(R) Core(TM) 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.