MicrosoftEdge / MicrosoftEdge/WebView2Feedback
[Problem/Bug]: visibilitychange doesn't fire when parent window is minimized or covered
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
What happened?
Reopening this issue: https://github.com/MicrosoftEdge/WebView2Feedback/issues/2681
The visibilitychange event doesn't fire when the window hosting a webview2 control is minimized or covered by another window. This works correctly in Electron, because they handle it themselves
The closed issue said "currently, it's by design" and proposed a workaround (for just the minimize issue, not the other one).
I think it would be nice if they baked this workaround into WebView2, so the browser events fire as expected, by checking the hosting window.
Importance
Moderate. My app's user experience is affected, but still usable.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
129.0.2792.89
SDK Version
1.0.2535.41
Framework
Winforms
Operating System
Windows 11
OS Version
22631.4317
Repro steps
- launch minimal app
- open devtools and execute
document.addEventListener("visibilitychange", () => console.log(document.visibilityState), true) - minimize the window or cover it fully by another window and notice that you don't get any logs
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
No, this never worked
Last working version (if regression)
No response
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal WinForms reproduction and the document.visibilityState listener described in the issue. Read the linked Electron browser-window.ts workaround and the Control.Parent hosting-window API; done means visibilitychange reports the expected state when the host window is minimized or fully covered.
Written by the indexing model from the issue text.
Assessment
- Domain
- desktop, web-dev
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100