electron / electron

:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS
https://electronjs.org
MIT License
113.67k stars 15.3k forks source link

[Bug]: Empty `WebContentsView` can never appear on top non-empty `WebContentsView` on `BaseWindow` #43293

Open kevinlinv opened 1 month ago

kevinlinv commented 1 month ago

Preflight Checklist

Electron Version

31.1.0

What operating system(s) are you using?

Windows, macOS

Operating System Version

Sonoma 14.6, Windows 11 Home

What arch are you using?

arm64 (including Apple Silicon)

Last Known Working Electron version

N / A

Expected Behavior

The WebContentsView appears on top of another WebContentsView that has a page loaded, regardless of its page loading state.

Actual Behavior

The WebContentsView does not appear on top of another WebContentsView that has a page loaded, when it does not have any page loaded or is currently loading one.

Testcase Gist URL

https://gist.github.com/kevinlinv/ceb6702dbc353a9f41a0dce60a7d588c

Additional Information

I have attached a testing recording on macOS and Windows.

https://github.com/user-attachments/assets/19f12755-66bb-4378-81d1-41302e7279cb

https://github.com/user-attachments/assets/4cf86180-cdb8-4cb4-a2b4-55860e7fc880

kevinlinv commented 1 month ago

Note: I purposely did not load any page to make the bug more obvious. The problem is more about the view not appearing while the content is loading. Which would look more like the following:

https://github.com/user-attachments/assets/b7b2f0b9-ce8b-4b6b-a194-9c56b7e2eae7

The desired behavior would be something like the following:

https://github.com/user-attachments/assets/1ecdc635-f4f9-4f3a-9cf7-9be54439df26

I also found that setting the visible of the rest of the other view via view1.setVisible(false) prior to loading view2 does let the view appear. Perhaps this is a z-indexing issue? 🤔

It isn't practical to set all other views hidden to resolve the issue, though.

codebytere commented 4 weeks ago

@kevinlinv this Fiddle doen't work in 29 - has this ever worked as expected? I agree it's worth trying to address, but it'd help knowing that.

kevinlinv commented 4 weeks ago

Hey, thanks for following up, I filled in v29 because I assumed WebContentsView wasn't supported then 🙏

I think this was never working before 👍