Open Bug 1893813 Opened 2 years ago Updated 1 year ago

Make documents always appear to be visible and in the foreground

Categories

(Core :: DOM: UI Events & Focus Handling, task, P5)

task

Tracking

()

REOPENED

People

(Reporter: manday, Unassigned)

Details

I've noticed that marketing websites (e.g. https://profitsfly.com/shorteners/) reliably run down presence timers which pause if the tab is not focused. In my opinion, a website should not be able to introspect whether the tab within which it is displayed has focus or not, it's a privacy (and usability) issue; a website has no business inspecting the state of the browser beyond its container.

If we don't pause or restrict timers in tabs then animations in non-displayed tabs would pointlessly overwhelm the browser's CPU/GPU.

I should add that this particular timer holds even if the tab is visible but unfocused (as the firefox window is unfocused).

Re freezing (?, entirely?) websites in background to save ressources, I wonder how feasible this is as a general measure. Websites may (reasonably) expect to continue doing <whatever> (calculations, evolution) while the user does not focus them.

The Bugbug bot thinks this bug should belong to the 'Firefox::Tabbed Browser' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Tabbed Browser

This might make more sense in Core :: DOM: UI Events and Focus Handling, though Core :: DOM: Core & HTML might also be a good fit. At any rate, Firefox :: Tabbed Browser is not the right component.

Component: Tabbed Browser → DOM: UI Events & Focus Handling
Product: Firefox → Core

farre: Could you set the severity field or close this bug if you think it's not reasonable.

Flags: needinfo?(afarre)

I'd guess that websites that want to detect if a document is hidden or not use the Page Visibility API, which is a Web API implemented by all major browsers. If you wish to drive a change of the spec I suggest you file an issue on GitHub.

Status: UNCONFIRMED → RESOLVED
Closed: 1 year ago
Flags: needinfo?(afarre)
Resolution: --- → WONTFIX

What you say is true, but how is this relevant for this issue? No one claimed that it were a bug in Firefox, but it is a privacy issue. Would Mozilla not like to address this? The W3C specs cookies, webstorage, canvas elements, etc., yet Firefox provides features to mitigate the privacy problems that these specs cause. Shouldn't that extend to this problem, too?

A simple "always return false for Document.hidden" setting would probably be enough while leaving the spec intact. I do not understand why you propose that be changed (or how would that be changed) in the spec.

Flags: needinfo?(afarre)

This was filed as a defect, I'll reopen and set it to task.

Status: RESOLVED → REOPENED
Type: defect → task
Ever confirmed: true
Flags: needinfo?(afarre)
Priority: -- → P5
Resolution: WONTFIX → ---

To implement this feature we'd need to do:

Disable Page Visibility API
Turn off background throttling of setTimeout/setInterval/requestIdleCallback (including budget throttling)
Disable all possibilities of suspending windows.

... and probably a lot more features that I've forgotten. I have no idea how this would impact Mobile. It would require a great deal of re-architecturing, especially around the suspend logic.

Summary: Tab focus leaked to website → Make documents always appear to be visible and in the foreground

Thank you and apologies for misclassifying the issue initially!

I think it's important to note that the changes you mention can be grouped into two categories:

One, there is Firefox which explicitly and unambigiously exposes the private information through the API. It would already be a significant step forward if this (i.e. the Page Visiblity API -- albeit not disabled, but just return a fixed value) could be changed.

Two, there is perhaps a plethora of side-channels from which a website may or may not infer the current visibility. None of which, however, give the website absolute certainty. In fact, there may be so many of them that I think addressing them (if really necessary) could be a constant WIP.

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