element-hq / element-web

A glossy Matrix collaboration client for the web.
https://element.io
GNU Affero General Public License v3.0
11.17k stars 1.99k forks source link

Element leaks every now and then #28307

Open smaug---- opened 3 days ago

smaug---- commented 3 days ago

Steps to reproduce

  1. Where are you starting? What can you see? We at Mozilla have seen some slow cycle collection times every now and then when using Element.
  2. What do you click? N/A
  3. More steps… This happens randomly and takes often some time to reproduce

Outcome

What did you expect? No leak

What happened instead? memory usage goes up and GC/CC times too

Copy-pasting my comment from elsewhere: I may have gotten some useful information about the Element leak. Happened to see that locally. At least in this case lots of the memory stays around because there is some function n which through enclosing_environment and other stuff keeps openEvent alive, and that is a pointer to a FocusEvent. (openEvent is still marked). Now, FocusEvent isn't skippable, and its mRelatedTarget and mOriginalRelatedTarget point to an orphan html:li element. CC doesn't know about that FocusEvent, and thus html:li have two unknown refs. html:li does have a preserved wrapper and of course that then keeps lots of stuff around (because of react stuff). So, a leak on the site. We should be able to decrease CC time quite a bit, but the leak is still there.

So seems like there is this "openEvent" somewhere through which lots of memory stays around. Or something is keeping openEvent around. The path is 'function n->Call->LexicalEnvironment->a->current->openEvent->FocusEvent'

My guess something somewhere is forgetting to clear openEvent, or that current.

Operating system

No response

Browser information

No response

URL for webapp

No response

Application version

No response

Homeserver

No response

Will you send logs?

No

t3chguy commented 3 days ago

openEvent looks like a thing in floating-ui.react rather than Element so it might be worth reporting it upstream