[Bug] Incorrect values of document.hidden/document.visibilityState when page is loaded in background tab
Categories
(Firefox for Android :: Tabs, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox122 | --- | affected |
People
(Reporter: ekager, Unassigned, NeedInfo)
References
Details
(Whiteboard: [geckoview:m86] [geckoview:2022h2?])
Attachments
(1 file, 1 obsolete file)
|
490 bytes,
text/html
|
Details |
From github: https://github.com/mozilla-mobile/fenix/issues/16637.
Steps to reproduce
- Open https://jg-testpage.netlify.app/document.hidden/landing/
- Long press the link on the page and open the link in the new tab.
- Wait a few seconds. Switch to the newly opened tab
Expected behavior
The logs until the time when the tab became active should be saying
document.hidden = true; document.visibilityState = hidden;Actual behavior
The logs are saying
document.hidden = false; document.visibilityState = visible;In other words, initial values for visibility APIs are wrong when page is loaded as background tab.
Fix
- The browser should detect that the page is initially invisible
- and raise
visibilitychangeonce it becomes visible.(The visibility APIs seem to work correctly when visible page gets changes to invisible (by switching tab) or by minimizing the browser.)
Device information
- Android device: Huawei P20 lite, Android 9
- Fenix version: 82.1.3
Change performed by the Move to Bugzilla add-on.
Just a note, the feature works correctly on desktop (tested on Windows); also it works correctly on Android in all Chromium-based browsers I tested.
Scope of the bug is only Firefox Android.
Updated•5 years ago
|
Updated•5 years ago
|
Comment 2•3 years ago
|
||
I just checked and I can still reproduce this in the latest Fenix nightly.
Updated•3 years ago
|
Comment 3•3 years ago
•
|
||
Visibility API is broken in GeckoView. The bug has a minimal test case that can reproduce the bug.
Comment 4•1 year ago
|
||
Does this happen still? I think Geckoview/Fenix was fixed (I just can't find now the right bug).
Comment 5•1 year ago
|
||
It is still a problem, yes
Comment 6•1 year ago
|
||
Actually, Testing this in GVE - does not reproduce. Haven't tested on Fenix yet, but I would imagine this should work
Comment 7•1 year ago
|
||
In Fenix this is still a problem
Updated•1 year ago
|
Comment 8•1 year ago
•
|
||
A bit more information:
When we tried reproducing it in GVE and Fenix using dev tools (meaning, to navigate by inspecting a background tab) - it doesn't reproduce in Fenix either. So, speculating here, it might have to do with the way a new tab is opened in the background.
I moved this to the Fenix component, but I think to really check which layer this bug is in, might be useful to try to reproduce in another GV powered browser that has ability to pen tabs in background - maybe the Reference Browser. If the state of the tab is not handled correctly by the app - and we don't communicate to Gecko correctly re: the backgroundness of the tab, that might mess up the web APIs
Comment 9•1 year ago
|
||
I can still reproduce this bug in Fenix (122) but not in Chrome 121.
Comment 10•1 year ago
|
||
Over on bug 1877469 comment 8 I mentioned the same problem for the TestRunner application, which is basically used for all the wpt tests. That one is failing as well, whereby tests have shown that both Fenix and GeckoView example are working fine. At the moment it's blocking me to land a patch this reduces races when switching tabs. Owlish maybe you could have a look? Thanks.
Comment 11•1 year ago
•
|
||
I remembered an odd bug I reported in bug 1847566.
Not sure if it is related in any way, but it has a parallel feel to this one, and calls around setFocused and setActive might be a place to investigate. That bug had differing behavior in GVE and Fenix. Additionally, the bug reproduced by switching tabs and touching content a certain way. For example, touching content v. not touching the content when switching tabs caused different behavior with primary = true and primary = false on the browser.
Comment 12•1 year ago
•
|
||
Edit: I have reproduced in Fenix Nightly 123.0a1 and Reference Browser having the wrong initial state of document.hidden = false; document.visibilityState = visible; when opening the tab in the background through a deep click. Didn't try inspecting GVE.
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Description
•