mozilla-mobile / fenix

⚠️ Fenix (Firefox for Android) moved to a new repository. It is now developed and maintained as part of: https://github.com/mozilla-mobile/firefox-android
https://github.com/mozilla-mobile/firefox-android
Mozilla Public License 2.0
6.47k stars 1.27k forks source link

[Bug]: In private browsing, state for a website should not be cleared if all tabs for that site unload due to memory pressure. #23611

Closed DavidJCobb closed 2 years ago

DavidJCobb commented 2 years ago

Steps to reproduce

Install the Video Background Play Fix add-on.

Go to YouTube and switch to Desktop Mode. Set the site theme to Dark Mode (changing from "device theme"), and then switch back to mobile mode. The mobile site should now display in a dark theme. (You need to explicitly pick the dark theme even if the desktop site is already dark. The desktop site respects your "dark by default" browser settings; the mobile site does not, and is light unless we follow these steps.)

Pick a YouTube video -- ideally a long piece of music. This should do.

What we've done so far is create a private tab that plays long-running media, on a site where we've set some options that are remembered via cookies, all in a private tab. Now, we can proceed and try to repro the bug. Let's call the tab we opened the "test tab."

Leave the private tab open and, in either private mode or normal mode, start opening and closing large numbers of websites other than the website you have open in the test tab. So in this case, we want to avoid YouTube and anything that embeds its videos, but any other sites are fair game: news articles, reddit posts, Imgur albums, the Lua programming language reference documents... Anything. As you do this, never return to the test tab; leave it playing media in the background, and don't close it, but don't touch it either.

Expected behaviour

The private "test tab" should never be unloaded, because it's playing media in the background; Firefox should prefer unloading other tabs.

If the private "test tab" ever is unloaded, all associated data for YouTube should be retained within the private session. If you return to YouTube in private browsing (even just by returning to the test tab), it should continue to use the dark theme on mobile. Firefox should only clear a site's data from the private browsing session if all tabs for that site are actually closed by the user or their add-ons; tabs unloading due to memory management should not cause session data loss.

Actual behaviour

Firefox may unload the private "test tab" even while it's playing media in the background, halting the media immediately.

If Firefox unloads the private "test tab," it will also clear all associated data for YouTube within the private session, since no YouTube tabs remain loaded (as opposed to existent) within the private session. As a result, YouTube will use the light theme on mobile during the same private browsing session. In general, sites affected by this behavior will log the user out and abandon all other cookie-related state even though the user never actually took any action to leave the site.

Device name

No response

Android version

Android 11

Firefox release type

Firefox

Firefox version

96.3.1 (Build #2015860755), 5e0953d24+

Device logs

No response

Additional information

I browse the web with Firefox, and I'd be something of a tab hoarder even if Firefox for Android's tab management weren't aggressively terrible. I must have at least a couple hundred inactive, unloaded tabs accumulated from past browsing. I don't know how well Firefox manages unloaded tabs; it's possible that they'd cause Firefox to unload newer tabs sooner than if no such old tabs existed.

In other words: you may have trouble reproducing this from a "fresh" install or a totally empty browsing session, or at least it may take you a long while.

┆Issue is synchronized with this Jira Task

kbrosnan commented 2 years ago

Might be helped by bz-1753700. Not sure that there is any direct work in this report for the Fenix team.

stale[bot] commented 2 years ago

See: https://github.com/mozilla-mobile/fenix/issues/17373 This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.