-
Notifications
You must be signed in to change notification settings - Fork 15.5k
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
Transparent window has white background window #2170
Comments
This is usually related to hardware, can you open the |
Graphics Feature Status - exactly the same in mac, windows virtualized (via parallels) and windows pc. If you want I can provide you more accurate screenshots. |
I think it is a bug of Chrome's rendering code, and it should be GPU/hardware related. I'm afraid we can not fix it on Electron's side. |
Ok, so your advice is to wait for the next versions of Chrome? |
I have an update, that's strange. On the virtualized Windows, as you know is all ok, but on the pc if the window is at least 160x80 pixels, the transparent option works. In my specific case, 100x50px is the standard size of my window, I increase the dimensions by 12x5px every time I click on my own button by using win.setSize(x, y); Recap: |
I can confirm this on my windows 7(x64) machine as well. When the transparent flag is set to true. Update: |
I came across this recently as well, and I've fiddled with the height and width to try see what happens. Turns out that if both width and height values are smaller than 160, you will see the white screen, ie 159 x 159 = white screen However if at least one value is >= 160 than it will be transparent, so 160 x 1 = transparent I tried to see if re-sizing the browser window programmatically might help, but it doesn't, although I did see that it adds the white background behind the window. If you are using a background of say rgba(0,0,0,0.2) you will see it will be discoloured because of the white window behind it |
This is most likely related to this issue: #861 |
I'm on the latest Electron (v0.33.6) and on Yosemite. It works fully for me... I instantiate the window like so: const window = new BrowserWindow({
width,
height,
'node-integration': true,
frame: false,
transparent: true
});
window.loadUrl(`http://localhost:8002${uri}`);
window.openDevTools(); The only flaw I see is when I open Dev Tools, the background is white until I close it, then it becomes transparent. |
Just realized this seems to be an issue with Microsoft Windows |
@kevinmartin yes, it is! |
EDIT: Sweet! adding Also having this problem on Linux. I'm just trying to do a "Hello world" with transparent bg to see if it works, but I'm getting a white background. Here's what I have. I'm on elementary OS Freya 64-bit. It's an Ubuntu 14.04 based distro running GTK3. Tried chrome://gpu and it detected some problems. |
i have the same problem on ubuntu linux |
This issue is deeply related to the hardware and drivers, we are not able to solve this on Electron's side, so I'm closing this as won't fix. For people troubled with this issue, the only suggestion I can give is to wait for upgrades of Chrome and see if it can fix this. |
Hi, I have the same problem, there is white background.
I tried almost everything |
Have you try to downgrade electron, for example to version 4.* ? |
@doom-fr Yeah ,i did. the vertion of |
@vifird Try to set wait to 3000 ms. Remember to test |
This issue should not be closed, please reopen it again, thanks! |
If waiting 3000ms before creating the window fixes your problem
Then this issue is the good for you : |
The opposite happened to me, windows 7 pro, the app window is transparent when started. |
No amount of waiting fixes the problem for me. Using latest version of Electron on Windows 10. |
I played around with a lot of these options on Windows 10, Electron v8 and found that transparency worked when I launched the application without dev tools or launched with dev tools undocked |
Same issue on linux. Transparency not working and it's not related to window size. |
Its been 5 years but still it couldn't be fixed. 😿 |
If somebody with the same issue, the only way I found to solve, is disabling hardware acceleration. app.disableHardwareAcceleration();
app.on('ready', () => {
setTimeout(() => {
createWindow();
autoUpdater.checkForUpdatesAndNotify();
createMenu();
}, 50);
}); I hope helped somebody... |
@andredezzy you're my hero, give this guy a beer! 🍺 Tested and working on Linux Mint 20 with XFCE and |
Be careful, the wait delay seems to depend of the platform. |
My take is that with HW accel stopped, the delay is not needed. |
Nah, seems it is still needed. |
Yeah if you try on a variety of desktop environments / platforms / distros you'll notice it's still needed and it needs to be several seconds to work consistently. Same as back in 2015 :/ |
I found a different solution for me, I had to disable : |
@angjelonuho yes as a general note when dev tools is open translucency automatically turns off because the window mode changes |
I was having a black screen while trying to enable the transparent property on my Arch Linux Manjaro. Adding the flag |
I resolve this problem if you want to make a transparent window, remember to invoke the window.setBackgroundColor after win.loadUrl or win.loadFile method
|
Here's my solution for this. In my experience, any set of options that changes the position of the window can trigger the issue unless I set it after the window is shown at least once. Also import { app, BrowserWindow, screen } from "electron";
app.on('ready', () => {
const { workAreaSize } = screen.getPrimaryDisplay();
const window = new BrowserWindow({
show: false,
frame: false,
transparent: true,
// This is important, set your window's width and height - 1
width: workAreaSize.width - 1,
height: workAreaSize.height - 1,
// Any option you want down there
maximizable: true,
resizable: true,
});
window.loadURL(THE_URL_TO_YOUR_COOL_WEBSITE);
window.webContents.openDevTools({ mode: 'detach' });
window.on('show', () => {
window.setSize(workAreaSize.width, workAreaSize.height);
window.center();
});
window.on('hide', () => {
window.setSize(workAreaSize.width - 1, workAreaSize.height - 1);
});
window.once('ready-to-show', () => {
window.show();
});
}); Edit: After more testing I found out that hiding the transparent window and showing it will make it lose its transparency but changing its size on show will make the transparency work again so I updated my answer to reflect on this. |
Hi, I've some issue with the transparent window, my code is:
On Mac I have not any kind of problem, on my Windows 7 Parallels virtual machine again no problem, but on another pc (not virtualized) with Windows 7 transparent windows doesn't work (I have a white background).
I haven't error logs from console.
In both Windows 7 machines I have DWM enabled and running (in fact, both are using aero).
The text was updated successfully, but these errors were encountered: