Open Bug 1779557 Opened 2 years ago Updated 3 months ago

document.hidden/document.visibilityState is false/visible even for windows occluded by other windows (either same-process or other applications)

Categories

(Core :: Widget: Cocoa, defect, P3)

defect

Tracking

()

People

(Reporter: Gijs, Unassigned)

References

(Blocks 1 open bug)

Details

Testing on beta:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:103.0) Gecko/20100101 Firefox/103.0

on macOS big sur (11.6)

If I run e.g. setTimeout(() => console.log(document.hidden), 10000) in the browser console (so document is a toplevel/browser.xhtml window), switch applications (all my apps have windows maximized), then wait, it logs false.

The same thing appears to be true for the document inside the selected tab when the parent window is occluded.

If I switch tabs and log the same thing in a background tab, it correctly switches to true.

See Also: → 1236512, 1688997

It appears that safari also doesn't do this on my machine, so now Emilio and I are wondering if it's just my machine / version of macOS / whatever...

It works on my macOS machine fwiw. document.visibilityState in chrome docs doesn't change, but window.isFullyOccluded is true and document.visibilityState changes properly as well in content. So it seems something in Gijs' machine might be borked.

See Also: → 1779559
Severity: -- → S3
Priority: -- → P3

I can reproduce this on Linux, is it worth filing a bug or is window occlusion not supported on Linux?

Window occlusion is not implemented on Linux afaict.

(In reply to :Gijs (he/him) from comment #0)

If I run e.g. setTimeout(() => console.log(document.hidden), 10000) in the browser console (so document is a toplevel/browser.xhtml window), switch applications (all my apps have windows maximized), then wait, it logs false.

The same thing appears to be true for the document inside the selected tab when the parent window is occluded.

If I switch tabs and log the same thing in a background tab, it correctly switches to true.

This reminds me a conversation I had with Markus a few weeks ago, I just found it in the Element archives:

florian
I'm testing window.isFullyOccluded in the Browser Toolbox on my Macbook, and it doesn't seem to give me reliable results. Are there known issues, or is it worth trying to find steps to reproduce?
Seems to return false when the window touches either the left or right side of the screen, even if I have a window taking the entire screen above it. That's unfortuate because it means a maximized window is never reported as fully occluded.
The windowDidChangeOcclusionState notification apparently comes directly from the OS, so it might be difficult to do anything about it

mstange
yeah exactly!
I've never investigated the cases where it works and where it doesn't
we could add our own heuristics on top of the OS notification, if we have some scenarios where it really makes a difference but any problems with the OS notification would also affect Safari

florian
maximized windows when we have another maximized window on top of it would probably make a difference; if the other maximized window is not ours it's probably harder... and multi-screen situations are also harder, of course.

mstange
true

You need to log in before you can comment on or make changes to this bug.