electron: [Bug]: Paint events do not fire when window is initially hidden on Windows or Linux

Preflight Checklist

Electron Version

16.0.0

What operating system are you using?

Other (specify below)

Operating System Version

Windows 11, macOS 12, Fedora 35

What arch are you using?

Other (specify below)

Last Known Working Electron version

11.5.0

Expected Behavior

A hidden window with this configuration should still paint:

  const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    show: false,
    paintWhenInitiallyHidden: true,
  })

The page should fire paint events that can be picked up by PerformanceObserver.

const observer = new PerformanceObserver((performance) => {
  console.log("Paint event:", performance.getEntries(), new Date().toString());
});
observer.observe({ entryTypes: ["paint"] });

Actual Behavior

On Windows and Linux, paint events do not fire while the window is hidden. It is unclear whether any painting is happening while the window is hidden.

On macOS, it works as expected.

Windows console output in renderer:

Contentful element added to DOM: <h1>​Paint me!!​</h1>​
Showing window after timeout: Thu Nov 25 2021 13:26:28 GMT-0500 (Eastern Standard Time)
Paint event: Array(2) Thu Nov 25 2021 13:26:28 GMT-0500 (Eastern Standard Time)

Mac console output in renderer:

Contentful element added to DOM: <h1>​Paint me!!​</h1>​
Paint event: Array(2) Thu Nov 25 2021 13:25:10 GMT-0500 (Eastern Standard Time)
Showing window after timeout: Thu Nov 25 2021 13:25:13 GMT-0500 (Eastern Standard Time)

Testcase Gist URL

https://gist.github.com/062c602a24a5f72a1f00d05285fdac68

Additional Information

This behaviour seemed to regress gradually over the course of several Electron versions. In 11.x, the paint events reliably fire when the window is hidden. Around 13-14, they sometimes do, and sometimes do not. As of 16.0, they never fire on Windows or Linux, but continue to fire on macOS.

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 1
  • Comments: 22 (5 by maintainers)

Most upvoted comments

bump