electron: ready-to-show never fires

  • Electron version: 1.3.7
  • Operating system: macOS & Windows

I’m having some trouble creating a minimal repro for this but it seems that the ready-to-show event is not firing for us, since ~1.3.7, despite us having show: false in the window options. Filing this in case others are seeing the same behavior.

We had to switch to using browserWindow.webContents.on('dom-ready', ...).

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 17
  • Comments: 54 (17 by maintainers)

Commits related to this issue

Most upvoted comments

I am not sure if it’s related, but I’ve noticed that if you have fullscreen: true set, then ready-to-show will never fire.

In my case, I removed the fullscreen option from the new BrowserWindow() call, and then after my win.show(); line, I added win.setFullScreen(true); and now the ready-to-show event fires, and I can still go full screen with just a small jitter.

Personally, I consider this a bug, and most likely related to this issue. If you want me to file a new bug report, let me know though.

Still seeing this issue with v6.1.2. Is there any way I can maximize before I hit “did-finish-load?”

@Slapbox in my case,

  • win.loadURL(path.join(__dirname, 'views', 'anchor.html')); : works on windows, but not on macOS.
  • win.loadFile(path.join(__dirname, 'views', 'anchor.html'));: works on Windows and macOS.

ready-to-show not fired if I set webPreferences.preload

let win = new BrowserWindow({show: false})
win.once('ready-to-show', () => {
  win.show()
})

https://github.com/electron/electron/blob/master/docs/api/browser-window.md#showing-window-gracefully

@Slapbox I’m pretty sure loadFile is just a convenience method.

win.loadURL('file://${__dirname}/app/index.html')

vs

win.loadFile('app/index.html')

also the options objects that you can pass to them are different.

Also still seeing this in 6.x - with a preload script, which I strongly suspect is the cause.

@DeerMichel Actually, nevermind that’s documented behavior.

I’m seeing the same behavior as @Zlocoder, ready-to-show doesn’t seem to fire if I use preload, except for my first window.

Version: electron@3.0.0-beta.10 on Windows 7

tl;dr - Removing my electron-reload module include got things working for me when experienceing similar issues.

I too was having similar issues after transitioning from my working Windows 10 desktop to my MacbookPro (10.12.6) and couldn’t get my BrowserWindow to trigger ready-to-show. After a lot of failed digging I finally resorted to copy-pasting the sample code from electronjs.org and it worked! This led me to find that the electron-reload module include I was doing appeared to be the culprit. I haven’t yet dug into why it’s happening but hopefully this helps others.

It stop working in development mode when is fullscreen, only work properly in production

Also to switch to using win.webContents.once('dom-ready', () => {

Also hit this issue.

It turns out that when Electron was maximized, and it’d restart, maximized, the the window would show, but this event would never fire. Despite having my windows set visibility to false, I’m assuming it doesn’t fire because of this: https://github.com/electron/electron/blob/fcc7dc774accfeb526d7ec8b7ff7115c0693f416/atom/browser/native_window.cc#L565 - which may be a mistake, it should probably always fire regardless of the window being visible or not??

If it matters, I’m also using https://github.com/mawie81/electron-window-state which may be triggering something to cause this issue.

As a work around, I think we can also emit ready-to-show on dom-ready event, so it would be guaranteed to emit.

Related: #6898.