electron: Transparency does not work on Linux (black background instead)

  • Output of node_modules/.bin/electron --version: in first bad version : 1.5.0 in latest beta : v4.0.0-beta.8 in lastest nightly : v4.0.0-nightly.20181010

  • Operating System (Platform and Version): Linux Debian Jessie : Linux version 3.16.0-7-amd64 (debian-kernel@lists.debian.org) (gcc version 4.9.2 (Debian 4.9.2-10+deb8u1) ) #1 SMP Debian 3.16.59-1 (2018-10-03) and also in Linux Debian Buster : Linux version 4.18.0-2-amd64 (debian-kernel@lists.debian.org) (gcc version 7.3.0 (Debian 7.3.0-29)) #1 SMP Debian 4.18.10-2 (2018-10-07)

  • Output of node_modules/.bin/electron --version on last known working Electron version (if applicable): v1.4.16

Expected Behavior having a transparent background for the window

Actual behavior having a black background for the window

To Reproduce see https://gitlab.com/doom-fr/electron-transparency-bug.git

Screenshots

1.4.16 image

1.5.0 image

4.0.0.beta.8 image

Additional Information

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 25 (2 by maintainers)

Most upvoted comments

Easy to wait more than two years without doing anything and tell that the version is not supported any more …

In the last month users seems to encounter the problem. @shubham-root & @Pevernow, can you confirm this is still an issue in the last release ?

Thanks.

我在另一个问题中看到如下的解决方案,亲测可用:

app.on('ready', () => setTimeout(your window create function, 400));
function createWindow () {
  // Create the browser window.
  mainWindow = new BrowserWindow({
    width: 500,
    height: 500,
    frame: false,
    transparent: true,
    alwaysOnTop: true,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js')
    }
  })

 // 设置延迟
app.on('ready', () => setTimeout(createWindow, 400));
if(process.platform === "linux") {
  app.commandLine.appendSwitch('enable-transparent-visuals');
  app.disableHardwareAcceleration();
}

before your

app.on('ready', () => {..}) seems to do the trick for me on Ubuntu 18.04/Electron 11.2.3

“–disable-gpu” and latency do make it work.

But I need to use webgl, which is not a good solution.

Is there any way to make transparency and webgl work on Linux at the same time?

After some other tests, it seems that it works in electron 4.0.1, but we have to wait for at least 300ms before opening a window !!! @codebytere why should we need this ? Couldn’t it be integrated into the ready event or another one, to wait just what is needed ?