Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop spamming deprecation messages #37289

Closed

Conversation

JonathanTreffler
Copy link

@JonathanTreffler JonathanTreffler commented Mar 17, 2023

Stops flooding the browser dev tools console every time a deprecated global function is called, by only logging a specific deprecation notice once.

Issue

Nextcloud logs every time a deprecated global function in the frontend is called. If a Browser Dev Tool is attached to the browser tab it will save all these logs to the RAM to show them in the "Console" tab.

For my instance this results in about 1000 deprecation notices PER SECOND, no that is not a typo, that is 3 zeros.

To demonstrate I attached a Dev Tools debugger to a Dev Tools debugger debugging Nextcloud files. Yes the Chrome Dev Tools are implemented in html and js, so they can be debugged with another instance of themself :)

Screenshot 1, after about the 1 Minute it took me to set up the debugger debugger and screenshot:
1

Screenshot 2, exactly 65 seconds later:

2
(different deprecation logs disrupted the log messages collapse, because of that the collapse number in the last line is smaller)

As you can see the dev tools memory usage grew by about at least 0,4 GB in 65 SECONDS of having the debugger open.

But it is actually worse, because the debugger ist not just using a lot of RAM, it is basically completely unusable, because it uses a lot of CPU. For example executing a js command in that console, that is busy with showing the deprecation warnings has a latency of 20 seconds or so. This also applies to the communication between the two debuggers, so the actual RAM usage is actually higher, because the RAM usage shown in the debugger debugger is delayed quite a bit. From looking at the process table in the system monitor it actually looks like that browser process of the debugger is using 1,9 GB at the time of screenshot 2.

I would like to show you a longer duration, but shortly after screenshot 2 the debugger OOMed.

  • Is it embarrassing, that the Chrome Dev Tools Debugger is not capable of discarding old logs, in order to keep itself from OOMing ?

    Yes, but can we please still stop spamming it with 1000 log messages per seconds, ok thx

  • Does this happen when not debugging the debugger ?

    Yes

  • Is it really the logs ?

    Yes, see here with these deprecation logs disabled (using window.TESTING = true) after 3 minutes:
    3

  • Does this issue occur without any apps installed ?

    I don't think the core itself throws (enough) deprecation warnings to cause the RAM usage issue. I am not sure which app exactly (I have a lot of them) uses this deprectaed stuff so often.

    It is likely, that this issue does not occur this extreme on most instances, since it depends on the installed apps and something is clearly wrong with one app, if it calls jquery 1000 times a second, but without causing a log every time, it is not actually a performance issue.

    On most instances this PR is just going to solve the annoyance of constant error messages in the Console, as described in the linked issue [Bug]: Spam of jQuery deprecation warnings in developers console #31763.

  • On which Browsers does this happen ?

    The screenshots are from Brave Browser on Fedora. I have also tested it with Chrome on Windows.

  • What Hardware was this was tested on ?

    CPU: AMD Ryzen 5 3600 (12 Threads)
    RAM: 16 GB

  • How often did this issue cause your system to lock up completely ?

    5 times, or about 5 times too often for my sanity 😐 (OOM on Fedora is weird)

The Fix:

Only thowing a specific deprecation warning once, so it can still throw multiple issues, if multiple different deprecated globals are being used, but each one only once.
This can be achieved, by using the lazy getter pattern described by MDN here.

TODO

  • Easy fix (only logging a specific deprecation notice once)

Checklist

Stops flooding the browser dev tools console every time a deprecated global function is called, by only logging a specific deprecation notice once.

Signed-off-by: Jonathan Treffler <mail@jonathan-treffler.de>
@JonathanTreffler JonathanTreffler marked this pull request as draft March 17, 2023 20:35
@JonathanTreffler JonathanTreffler changed the title WIP: Stop spamming deprecation messages Stop spamming deprecation messages Mar 17, 2023
@JonathanTreffler
Copy link
Author

(This is a draft, because I have not had time to test the patch yet, but it should work)

@szaimen szaimen added the 2. developing Work in progress label Mar 17, 2023
@szaimen szaimen added this to the Nextcloud 27 milestone Mar 17, 2023
This was referenced May 3, 2023
@skjnldsv skjnldsv modified the milestones: Nextcloud 27, Nextcloud 28 May 9, 2023
@skjnldsv skjnldsv mentioned this pull request Nov 1, 2023
This was referenced Nov 6, 2023
This was referenced Nov 14, 2023
@blizzz blizzz modified the milestones: Nextcloud 28, Nextcloud 29 Nov 23, 2023
This was referenced Mar 12, 2024
@Altahrim Altahrim mentioned this pull request Mar 20, 2024
@skjnldsv skjnldsv modified the milestones: Nextcloud 29, Nextcloud 30 Mar 28, 2024
@joshtrichards joshtrichards removed this from the Nextcloud 30 milestone May 12, 2024
@joshtrichards
Copy link
Member

Superseded by #38852 / #38980. Removing Milestone and closing.

@skjnldsv skjnldsv deleted the JonathanTreffler-stop-spamming-deprecations branch August 30, 2024 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Spam of jQuery deprecation warnings in developers console
5 participants