meslzy / electron-as-wallpaper

set your electron window as wallpaper behind desktop icons
MIT License
68 stars 10 forks source link

transparent window immediately closes #11

Closed Double-Lv closed 9 months ago

Double-Lv commented 9 months ago

Hello,

When I specify transparent: true, the browserWindow opens briefly and then immediately closes. And when I set transparent: false, the window didn't closes. It seems there might be an issue with the support for the transparent property. My environment details are as follows:

Operating System: Windows 10 Electron Version: 25.9.8

My code:

const widgetWindow = new WidgetBrowserWindow({
    width: 600,
    height: 300,
    x: 100,
    y: 100,
    hasShadow: false,
    frame: false,
    transparent: true,
    backgroundColor: 'rgba(0, 0, 0, 0.5)',
    enableLargerThanScreen: true,
    resizable: false,
    webPreferences: {
        webSecurity: false,
        contextIsolation: false,
        nodeIntegration: true,
        enableRemoteModule: true,
        allowRunningInsecureContent: true,
    }
  });
const winURL = process.env.NODE_ENV === 'development'
    ? 'http://localhost:6879/widget.html'
    : `file://${__dirname}/widget.html`;

require('@electron/remote/main').enable(widgetWindow.webContents);

widgetWindow.once('ready-to-show', () => {
    if (__DEBUG__ && !config.showDevTools) {
      widgetWindow.webContents.closeDevTools();
    }

  attach(widgetWindow, {
    forwardKeyboardInput: true,
    forwardMouseInput: true,
    transparent: true
  });

  widgetWindow.show();
});

widgetWindow.loadURL(winURL);

By the way, I use electron-as-wallpaper with the commit: 86e3f94b8f16b7edae101e40402bb97c867f3edd (before your Refactor), because my Application can only run with node16

Thank you.

meslzy commented 9 months ago

Hey, Thanks for reporting the issue, But.

image

I can't solve issue unless i see errors or bugs.

Double-Lv commented 9 months ago

Hey, Thanks for reporting the issue, But.

  • First, There's no issue of using any node version as far as my knowledge goes.
  • I can't really go back to prev commit and test the code, so i test using the latest commit and it works well as showing below.

image

  • Can you try using the latest version ?
  • Can you please create a repo for it and send it over with more details of what's goin on, try to use logs, etc.

I can't solve issue unless i see errors or bugs.

Hello,I'm unable to obtain logs because the window immediately crashes,and devTools didn't show any error. I've updated electron-as-wallpaper to the latest code, but the issue persists. Could you please try running nodejs16 locally to see if it works for you?

meslzy commented 9 months ago

Yes, i used node 16 on windows 10.

Double-Lv commented 9 months ago

Thank you very much for the response. I've finally identified the root cause of my problem. It turns out that in my code: app.disableHardwareAcceleration(); This line is causing the crash. I added this line because GPU rendering was slowing down my app (although I'm not sure why).

meslzy commented 9 months ago

I see, thanks for reporting this, I'll try to add note abt it, also I'll try to figure out the issue.

I'll close this issue unless you have something to add.