Open Bug 1553260 Opened 5 years ago Updated 5 months ago

Automatically unload (discard/hibernate) longly unused tabs to free RAM (when running out of RAM)

Categories

(Firefox :: Tabbed Browser, enhancement, P3)

Desktop
All
enhancement

Tracking

()

People

(Reporter: robert_abc3, Unassigned)

References

(Blocks 3 open bugs)

Details

It should be possible to set Firefox to trigger tab discarding when only free physical memory is running low. User should have a choice to choose between 3 options for browser.tabs.unloadOnLowMemory:
(1) no tab discarding,
(2) tab discarding when the total amount of both free physical memory and swap space is running low (provided in Bug 675539),
(3) tab discarding when free physical memory is running low (default setting) (Bug 1553260).
Tab discarding when free physical memory is running low should be set as default.

Alternatively, values (2) or (3) should be chosen automatically by Firefox based on total RAM present in PC/device: (2) if less than 8 GB is available in PC, and (3) if 8 GB or more is available. This value could be slightly different for different operating systems; user could have option to change this value too.

Discussion:
https://www.reddit.com/r/firefox/comments/brafza/latest_firefox_release_is_faster_than_ever_the/eoc44sk
https://www.reddit.com/r/firefox/comments/bncank/firefox_beta_keeps_reloading_tabs_on_a_pc_with_16/enis26r/?context=5

Not sure about 8GB limit (maybe 4 or 6 should be Ok?) but I agree that (3) should be default at least for 1-3 GB RAM devices. My opinion is based on Firefox for Linux (bug 1532955) usage experience of HP Stream 7 Tablet (1 GB RAM), Lenovo Miix2 8 (2 GB RAM), DEXP Ursus 10XW (2 GB RAM), Dell Venue 8 Pro 5855 (2 GB RAM) and other similar tablets.

Option 3 could be hard to implement because of the page cache. A lot of physical memory is usually consumed by the page cache and we don't want to unload tabs if physical memory is low because of that, the OS will reclaim it so we don't need to do anything.

This is not a problem on Linux where /proc/meminfo offers MemAvailable field which is just that (free memory + memory used by the page cache) but I'm not sure on Windows or Mac. I should investigate those two platforms to ascertain if it's feasible.

That being said if it is the changes should be minimal as the available memory tracker already has provisions to respond to low-physical memory scenarios.

Type: defect → enhancement
Priority: -- → P3
Version: 67 Branch → Trunk

(In reply to Gabriele Svelto [:gsvelto] from comment #2)

Option 3 could be hard to implement because of the page cache. A lot of physical memory is usually consumed by the page cache and we don't want to unload tabs if physical memory is low because of that, the OS will reclaim it so we don't need to do anything.

This is not a problem on Linux where /proc/meminfo offers MemAvailable field which is just that (free memory + memory used by the page cache) but I'm not sure on Windows or Mac. I should investigate those two platforms to ascertain if it's feasible.

That being said if it is the changes should be minimal as the available memory tracker already has provisions to respond to low-physical memory scenarios.

The main idea here is to prevent Firefox from using swap file (especially if it is on HDD). I stated "free RAM", but I mean any RAM available for Firefox including free and RAM memory which can be easily made available for the browser, without the need to go to swap file.

(In reply to Robert Ab from comment #3)

The main idea here is to prevent Firefox from using swap file (especially if it is HDD). I stated "free RAM", but I mean any RAM available for Firefox including free and RAM memory which can be easily made available for the browser, without the need to go to swap file.

Indeed; heavy swapping rarely provides a good user experience so we want to avoid that.

Also swapping to eMMC shorten device lifespin as it usually soldered on the board (like on devices I mentioned above).

(In reply to russianneuromancer from comment #5)

Also swapping to eMMC shorten device lifespin as it usually soldered on the board (like on devices I mentioned above).

Good point.

I'd suggest to widen a bit the use case: for example, I am more interested in unloading tabs to stop them from using CPU than because of memory usage.

Do you know when this future will be implemented in Firefox?

Flags: needinfo?(gsvelto)

We don't have a plan yet but it will be discussed this week.

Flags: needinfo?(gsvelto)

(In reply to Gabriele Svelto [:gsvelto] from comment #9)

We don't have a plan yet but it will be discussed this week.

Any news?

Flags: needinfo?(gsvelto)

Automatic tab unloading has been disabled due to a bug in the low-memory detection logic, see bug 1558930 for more details. Until that's fixed we won't be able to turn it back on. Regarding unloading long inactive tabs we discussed implementing the Page Lifecycle API, possibly feeding back changes into the draft spec. Idle tab unloading will probably happen within that context.

Flags: needinfo?(gsvelto)
See Also: → sleeping-tabs

(In reply to Gabriele Svelto [:gsvelto] from comment #11)

Automatic tab unloading has been disabled due to a bug in the low-memory detection logic, see bug 1558930 for more details. Until that's fixed we won't be able to turn it back on. Regarding unloading long inactive tabs we discussed implementing the Page Lifecycle API, possibly feeding back changes into the draft spec. Idle tab unloading will probably happen within that context.

There are 2 similar bugs: Bug 675539 (with Bug 1558554 as follow-up), and Bug 1553260? Are you talking about Bug 1553260?

Flags: needinfo?(gsvelto)

I was talking about bug 675539, bug 1553260 was not implemented yet.

Flags: needinfo?(gsvelto)

(In reply to Gabriele Svelto [:gsvelto] from comment #11)

(...) Regarding unloading long inactive tabs we discussed implementing the Page Lifecycle API, possibly feeding back changes into the draft spec. Idle tab unloading will probably happen within that context.

It will be useful also for this API to give options to add-ons to be able to discard tabs after given time. Chrome extensions, like The Great Suspender, can perform these actions already. (See also The Great Discarder).

Add-ons can already do that, there's a few available on Firefox too.

Depends on: 1579198
See Also: → 675539
No longer depends on: 1475889
No longer depends on: 1579198

Do you have plans to implement this bug?

Flags: needinfo?(gsvelto)
See Also: → 1587762

Yes, it's something we have discussed internally. We need more data and we need basic tab-unloading-on-low-memory to be working first. In the meantime interested users can experiment with the Reduce RAM Usage add-on which is a simple time-based tab unloader.

Flags: needinfo?(gsvelto)

Should block bug 565512

Blocks: cuts-control
Blocks: cuts-addons

(In reply to Gabriele Svelto [:gsvelto] from comment #18)
In the meantime interested users can experiment with the Reduce RAM Usage add-on which is a simple time-based tab unloader.

that addon is not available anymore.

(In reply to Tortino from comment #20)

that addon is not available anymore.

There is also Auto Tab Discard (Github), which does the same thing.

Severity: normal → S3
Duplicate of this bug: 1650230
You need to log in before you can comment on or make changes to this bug.