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)
I am not sure if it’s related, but I’ve noticed that if you have
fullscreen: trueset, thenready-to-showwill never fire.In my case, I removed the
fullscreenoption from thenew BrowserWindow()call, and then after mywin.show();line, I addedwin.setFullScreen(true);and now theready-to-showevent 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.
https://www.npmjs.com/package/ready-to-show - fix bug
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
https://github.com/electron/electron/blob/master/docs/api/browser-window.md#showing-window-gracefully
@Slapbox I’m pretty sure
loadFileis 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 apreloadscript, which I strongly suspect is the cause.@DeerMichel Actually, nevermind that’s documented behavior.
I’m seeing the same behavior as @Zlocoder,
ready-to-showdoesn’t seem to fire if I usepreload, except for my first window.Version:
electron@3.0.0-beta.10on Windows 7tl;dr - Removing my
electron-reloadmodule 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
BrowserWindowto triggerready-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 theelectron-reloadmodule 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
developmentmode when isfullscreen, only work properly inproductionAlso 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-showondom-readyevent, so it would be guaranteed to emit.Related: #6898.