Window's ready-to-show event not firing

I’m having a strange problem with the newer version of electron.

I’m using the ready-to-show event to hide when it’s painting so it looks nicer, as mentioned here:

If I use the “npm start” command, the “ready-to-show” event will sometimes not fire.
Sometimes it will fire, but it’s random.

If I use the “electron .” command, then it works exactly as expected (the event fires properly).
I have electron 8.2.5 installed locally.

Does anyone know what’s going on?
Would it help to downgrade to 8.2.5?
I’m using Electron Forge and I tried changing the electron version in package.json, but I don’t think that did anything.
image

Here’s the pertinent part of my main process:

const createWindow = (WindowName,properties) => {
    properties = properties || {}
    
    properties.show = properties.show || false
    
    if (!properties.show)
        properties.show = false
    
    if (!properties.webPreferences)
        properties.webPreferences= {
            nodeIntegration: true
        }
    
    // Create the browser window.
    var Window = new BrowserWindow(properties);
    /*
    const Window = new BrowserWindow({
        width: properties.width || 800,
        height: properties.height || 600,
        show: properties.show || false,
        frame: properties.frame || false,
        parent: properties.parent,
        webPreferences: {
            nodeIntegration: true
        }
    });
    */
    
    //console.log(Window.once)
    Window.loadFile(path.join(__dirname, '/window.html'));
    
    // and load the index.html of the app.
    Window.once('ready-to-show',()=>{
        //console.log('sending window to load')
        Window.show();
        Window.webContents.send('loadWindow', WindowName)
    });
    // Open the DevTools.
    //Window.webContents.openDevTools();
    
    return Window
};

const createMainWindow = () => {
    
    mainWindow = createWindow('Main');
    
    toolbarWindow = createWindow('Tools',{parent:mainWindow,width: 200,height: 400});
};

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createMainWindow);
1 Like

hi,
it would be great if you provide a repo so i can check with you.
BTW, i think the passed option properties.show in your logic could be causing a problem!!
the docs example shows clearly that you initialize the new browserWindow with show set to false so that it only shows on event ready-to-show like in win.show()