slowlydev/f1-dash

Memory leaking on Firefox

voidlynx opened this issue · 12 comments

Heya, big fan of F1-Dash. Unfortunately, it absolutely destroys my system's memory on Firefox.
Experienced this on both my main desktop and laptop under latest version of Firefox for a few race weekends now.
Right now opened the dashboard in Yandex Browser (chromium-based) during Monaco FP1 and my memory is doing absolutely fine.
So I'm absolutely sure it's a Firefox bug that should be easily reproducable. Oh, also, the more my memory fills up, the higher the CPU usage is and the dashboard just freezes.

Running on Yandex Browser (Chromium-based)

Running on Firefox

Thanks for the issue, okay I will investigate this Firefox when I have time.
If u want to you could run this in the browser console of the f1-dash tab and reload the page. And send me some screenshots when the lagging and so happens. localStorage.setItem("dev", "true")
It enables a small UI which shows the buffers, because the buffers should be the biggest thing that consume memmory, but they should be capped at 1000 entries.

Yeah the total sum seems to be going over a thousand, but it starts lagging hard even before it gets near that number.
EDIT: okay the sum also goes over a thousand on chromium but i simply lack the resources and time to see if i can get the State Engine Buffer (which does cap at a thousand in a normal environment) to that limit. it lags so hard not even a minute into firefox running.

image

Oh wow yeah, each buffer has a 1000 limit so we would be no where near the limits.
Has this issue always been there or was it introduced lately?

I'm not sure since how long ago, but it did occur when watching the Imola GP. Probably a few weeks before that too. Likely way before that, can't say for sure.

Hm I did not seem to get the excessive leak you did. But I was also using firefox nightly and I am on arm macOS. I will test on a windows machine next.

image

Maybe this pr #119 could be part of the solution?

I was able to reproduce this during Austria GP qualifying. It seemed to be proportional to the delay, if I had 0 delay there was no memory build up, I then set an ~45 second delay and the mem usage started to skyrocket, maxing out at around 16GB mem usage. I tried to capture a memory snapshot to try debug further but it was struggling to do once it had already exhausted all the resources.

Screenshot_29
Screenshot_30
Screenshot_31

Thanks for the testing. Looks like the buffer changes did not fix the memory leaks.

It seemed to be proportional to the delay, if I had 0 delay there was no memory build up, I then set an ~45 second delay and the mem usage started to skyrocket, maxing out at around 16GB mem usage.

Thats very weird, because the only difference between 0 and >0 delay is that the buffer will be searched and with 0 we just take latest. Also that it increases proportionally is weird as well.

I tried to capture a memory snapshot to try debug further but it was struggling to do once it had already exhausted all the resources.

okay, I will try to get a snapshot on my windows machine

Thats very weird, because the only difference between 0 and >0 delay is that the buffer will be searched and with 0 we just take latest. Also that it increases proportionally is weird as well.

It is entirely possible it was coincidental, but there were times where the behaviour was seemingly normal and then something caused it to suddenly climb until resources were exhausted 🤔

Same here on Firefox 130.0 on Linux. Long delays trigger memory leaks on my system.

Today I followed Singapore's FP2 session on Brave (on linux) with a delay of 73secs and everything was stable.
@slowlydev Any troubleshooting info we can provide to help solve the memory issue in firefox?

The Firefox memory issues have been on https://dev.f1-dash.com and the fix will arrive in prod soon.