morethanwords / tweb

Telegram Web K, GPL v3
https://web.telegram.org/k/
GNU General Public License v3.0
1.86k stars 595 forks source link

[BUG] The lack of keeping a static function reference in Event Listeners #339

Open randmaru opened 3 months ago

randmaru commented 3 months ago

Describe the bug Due to the use of anonymous functions in event listeners, there is an endless filling of the heap, which can indirectly affect the performance described in this Issue.

  1. Go to this channel
  2. Open the Chrome DevTools
  3. In the DevTools, open the Performance monitor tab
  4. Start scrolling using the PageDown/PageUp key
  5. You will see an endless increase in the heap size and the number of event listeners. As well as the periodic triggering of an exception in IntersectionObserver

Expected behavior You need to use named(static) functions to fix this problem. And find out more about its solution in MDN

Screenshots Check JS heap size & quantity Event Listeners

Desktop and Smartphone:

Additional context I conducted this research as part of a competition, but I can't say for sure if my hypothesis is correct. It takes a lot of time to check it, and I don't have it. As you understand, it is necessary to perform a large amount of work and conduct a thorough check.