Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ready-to-show event doesn't fire when opening a window to "about:blank" and writing a small amount of content to it #24356

Open
3 tasks done
pushkin- opened this issue Jun 29, 2020 · 13 comments
Labels
9-x-y bug 🪲 platform/all status/confirmed A maintainer reproduced the bug or agreed with the feature

Comments

@pushkin-
Copy link

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version: 9.0.4
  • Operating System: Windows 10
  • Last Known Working Electron version: not sure

Expected Behavior

The ready-to-show event should fire when opening a window to "about:blank" and writing a small amount of content to it.

Actual Behavior

ready-to-show doesn't fire until triggering another window.open call.
ready-to-show does fire when writing a larger amount of content however

To Reproduce

main.js:

(async () => {
  const {app, BrowserWindow} = require("electron");

  await app.whenReady()

  const win = new BrowserWindow({webPreferences: { nativeWindowOpen: true }});
  await win.loadURL("https://google.com");
  win.webContents.openDevTools();

  win.webContents.on("new-window", (e, url, frameName, disp, options) => {
    options.show = false;
  });

  app.on("browser-window-created", (e, win) => {
    win.once("ready-to-show", () => {
      win.show();
    });
  });
})();

  1. npm start this app.
  2. in the devtools that appears, execute var w = window.open("about:blank", "a"); w.document.write('<body>a</body>"');
  3. notice the window doesn't appear because the ready-to-show event doesn't fire
  4. if you do another window.open("about:blank", "a") (needs to be for the same window name), then the ready-to-show fires

If you don't make the w.document.write call and just open a window to "about:blank", then the ready-to-show event fires appropriately.

If instead, you write more content (e.g. var w = window.open("about:blank", "a"); w.document.write('<body>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaa</body>"');), then ready-to-show fires correctly.

@codebytere codebytere added 9-x-y bug 🪲 platform/all status/confirmed A maintainer reproduced the bug or agreed with the feature labels Jun 30, 2020
@Hedwig188
Copy link

@codebytere Is there any suggested workaround for this issue? I have a scenario which is waiting on the ready-to-show event to fire. I resolve a promise in the ready-to-show event callback. I am calling browserWindow.print() to print the content from this new opened window. Since the small content won't trigger the ready-to-show event, I added a new promise with setTimeOut. If theready-to-showevent fires after the setTimeout, some of the content would be missing in the print out.
await Promise.race(readyToShowPromise, new Promise(resolve => setTimeout(resolve, 3000))]);
window.webContents.print();

@pushkin-
Copy link
Author

Still a problem in Electron 10.1.2

@pushkin-
Copy link
Author

This issue appears to be fixed in Electron 10.1.3 due to this PR. @zcbenz FYI

@pushkin-
Copy link
Author

This issue seems to have been reintroduced in Electron 10.1.4 and seems to have never worked in Electron 11.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 7, 2022

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Oct 7, 2022
@pushkin-
Copy link
Author

pushkin- commented Oct 7, 2022

repros with Electron 21

@github-actions github-actions bot removed the stale label Oct 8, 2022
@github-actions
Copy link
Contributor

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Jan 10, 2023
@pushkin-
Copy link
Author

pushkin- commented Jan 11, 2023

repros in v22. gist

@github-actions github-actions bot removed the stale label Jan 12, 2023
@github-actions
Copy link
Contributor

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Apr 13, 2023
@pushkin-
Copy link
Author

bump

@github-actions github-actions bot removed the stale label Apr 14, 2023
@github-actions
Copy link
Contributor

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Jul 13, 2023
@Hedwig188
Copy link

Hedwig188 commented Jul 13, 2023 via email

@github-actions github-actions bot removed the stale label Jul 14, 2023
@Hedwig188
Copy link

This is no longer being an issue in Electron v24.6.4 and v25.3.2. Something must fix this in the latest version of Electron.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
9-x-y bug 🪲 platform/all status/confirmed A maintainer reproduced the bug or agreed with the feature
Projects
None yet
Development

No branches or pull requests

3 participants