Open Bug 1949248 Opened 6 months ago Updated 12 days ago

Steady memory increase of tabs despite GC and CC, and ghost-windows eating up huge amounts of RAM and CPU with frequent major GCs

Categories

(Core :: JavaScript: GC, defect, P3)

Firefox 137
defect

Tracking

()

UNCONFIRMED

People

(Reporter: daniel.schaaaf, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:135.0) Gecko/20100101 Firefox/135.0

Steps to reproduce:

I describe this bug for Youtube but it affects sites like reddit and probably many other sites as well. Firefox has been using extreme amounts of memory for the past few versions. We talk 30 GB of RAM for mostly inactive tabs!
Here is a profile showing frequent garbage collection and memory increase: https://share.firefox.dev/416CJB3

Install Firefox Nightly (new and unmodified profile) and open one tab with a Youtube video (autoplay switched off).
Switch to an empty tab or about:processes, and leave the Youtube tab untouched (with the video having come to its end and nothing new playing).

Wait ... a few hours ... days ... weeks ...

Interact with the Youtube tab, e.g. by clicking into the search field or expanding the video description.

To make things really bad, have several Youtube tabs open, watch many videos in a row, leave Windows running for days without closing Firefox, write comments on Youtube, use "big sites" like reddit or ebay or AliExpress in parallel, ...

Actual results:

When not interacting with the Youtube tab, RAM usage of that tab will increase slowly but steadily. Firefox will start the garbage collector (GC) and cycle collector (CC) periodically every few seconds. The GC reclaims slightly less RAM than was increased every cycle. Slowly, the memory usage of the tab will increase by 100 MB after an hour, and potentially a GB after some days.

Interacting with the Youtube tab will increase the number of minor GCs significantly. Major GCs will be frequent as well, using a lot of CPU power.

Using Firefox intensely for days, webServiceWorkers (?) will eventually have one or more ghost windows. When ghost windows are present, memory usage will increase fast, and closing an involved tab will not help (I guess a webServiceWorker runs several tabs?).
Tabs run by a webServiceWorker with a ghost window will be slowed down to being unusable because of frequent major GCs that last for several seconds and cause 100 % CPU utilisation. GCs run every time I interact with such a tab (mouse clicks or text input). I assume Firefox desperately wants to reclaim memory from the webServiceWorker, but fails because the ghost window is blocking/inaccessible.

I do not know how to replicate getting ghost windows. But they do show up eventually, every time I use my working installation of Firefox (135).

Expected results:

  • Garbage collection, especially major GC, should never run every few seconds.
  • Ghost windows should be killed (or garbage collection should be disabled for them?).

If GC cannot prevent memory usage from increasing, especially for inactive tabs and ghost windows, the reason for the steadily increasing RAM usage must be identified and eliminated.

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

Component: Untriaged → JavaScript: GC
Product: Firefox → Core
Severity: -- → S3
Priority: -- → P3

I tried to replicate the ghost windows, but I couldn't. The main reason is that they take a while to show up in my every day Firefox profile, and I don't want to use a fresh profile without ad blocker and userscripts for a day or longer.
With the latest version 136.0.1, I see ghost windows within one day of browsing Youtube, reddit, Aliexpress, and Finn.
The bigger problem is that having approximately 20 tabs open, Firefox occupies 15 GB of memory. Even if getting rid of ghost windows would release some of that, I'd still be stuck with >> 10 GB for a few open tabs. This is just ridiculously awful :-(

Don't know if it matters, but v136.0.1 seems to be really bad, at least on YouTube. I get the GC/CC acting up very quickly. And I noticed that it is not only triggered by clicking on page elements, but by moving the mouse cursor into the tab onto an apparently inactive part of the page (background) while no video is playing. Here is the profile: https://share.firefox.dev/3FyWzxQ
This particular tab was run by a worker (or whatever they are called) that had a ghost window too. Other YouTube tabs run by that worker were affected in the same way. I don't think ghost windows/tabs are the cause of the GC/CC problem. But when a ghost window/tab is involved, the worker can't be closed by closing all of it's tabs?

Something is seriously wrong with memory usage in Firefox, and constant garbage/cycle collection makes things worse by increasing CPU usage too.

v139.0.1 is really bad too. I see way more GC/CC deadlocks than in the previous few versions, and they show up quickly with Youtube and reddit.
(Not complaining, just reporting builds that seem significantly worse than others, so that someone maybe sees a correlation between certain code changes and GC/CC deadlocks.)

Is no one working on Firefox experiencing this bug? In v139.0.4, the GC/CC problem is causing CPU spikes that make browsing YouTube a pain. Worse, I have seen my mouse cursor not being rendered (!) over Firefox, and fullscreen videos playing in their original size for some seconds before there was enough CPU available to get them to play in fullscreen.

This could be related to Bug 1939295 or Bug 1936182. But both were closed as fixed in v134/135?
There is a long reddit thread from 5 months ago that seems to talk about the current issue: https://www.reddit.com/r/firefox/comments/1hvu7vq/youtube_is_shitty_as_hell_on_firefox/

If the GC/CC problem continues to persist at this intensity for the next few weeks/months, I might be able to test a fresh Firefox installation and/or see if uBlock Origin has an impact. Unfortunately, my health doesn't permit doing extensive tests or working faster. After a few minutes of mental work, I get fatigue and brain fog. Almost as if my brain is getting blocked by GC/CC too 😁

From memory, v140.0.2 was not unusually bad, and is v140.0.4 is much worse (on YouTube and reddit). Disabling userscripts and ublock origin didn't seem to help with v140.0.4. (Just a quick comment, in case anyone wants to look into the differences between v140.0.2 and v140.0.4)

v141.0 is still a huge memory hog, but it doesn't have slow-downs on reddit and youtube like v140.0.4.

Damn, I was too quick to judge v141.0. It is an improvement over v140.0.4, but after some browsing, reddit started to act up, memory usage is insane, and closing tabs doesn't decrease memory usage. Especially reddit posts with many comments start to hog the CPU a lot and make the webpage (Firefox) unresponsive every few seconds.

I see a lot of ghost processes too. An example is one single webIsolated reddit.com userContext of 2 GB! Half of that, 1 GB, is a ghost.

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

Attachment

General

Creator:
Created:
Updated:
Size: