elvetemedve / gnome-shell-extension-system-monitor

Gnome Shell extension for displaying resource usage
GNU General Public License v3.0
87 stars 15 forks source link

Extension causes stutter lag in video players. #3

Closed Silvery-Corgan closed 8 years ago

Silvery-Corgan commented 8 years ago

Hi. The extension causes stutter lag in video players such as VLC or SMPlayer. I have Fedora 23 x64. SMPlayer is using the MPV back-end while VLC has it's own back-end. The issue is more visible if you set the refresh interval to 1s in the extension's options and play an 1080p MKV video. After disabling the extension the stutters have stopped entirely. I have no idea where to look for logs but otherwise happy to provide more info if directed.

elvetemedve commented 8 years ago

Hi @Silvery-Corgan,

Which gnome session do you run? Is it Xorg or Wayland?

Silvery-Corgan commented 8 years ago

@elvetemedve I am using Xorg with proprietary NVidia drivers installed via RPMFusion with akmod package.

elvetemedve commented 8 years ago

@Silvery-Corgan I see lags on Arch Linux as well, using the open source Nouveau driver. So it's not video driver related or specific to an OS. Nice catch, by the way.

I have no idea what is the source of this behaviour. The extension basically just reads files from /proc and /sys directories and utilises the Gnome St library to display the information. It does not touch the graphics directly.

I'll try to narrow down the problem to a specific GUI operation. Once that is done, maybe Gnome developers can give some help.

Silvery-Corgan commented 8 years ago

@elvetemedve I have upgraded to Fedora 24. I am still using Xorg and the proprietary drivers. So nothing changed except the base (F23 => F24). I am still having this issue. This might be related to GNOME.

elvetemedve commented 8 years ago

I've done investigation and it looks like Gnome is not the source of the problem, but the too many file reads causes those spikes when a video plays.

First this line has to be refactored and implemented in a more efficient way: https://github.com/elvetemedve/gnome-shell-extension-system-monitor/blob/master/System_Monitor%40bghome.gmail.com/meter.js#L384 Secondly the list of process IDs are loaded multiple times per update interval, but should be loaded only once per iteration: https://github.com/elvetemedve/gnome-shell-extension-system-monitor/blob/master/System_Monitor%40bghome.gmail.com/meter.js#L379

I'll try to come up with a solution.

elvetemedve commented 8 years ago

@Silvery-Corgan I have managed to improve the performance of the extension by loading statistics asynchronously. I attached the modified version below. Can you test it please by extracting the content into the ~/.local/share/gnome-shell/extensions directory and restart Gnome session? (I used this animation to measure the lag.)

System_Monitor@bghome.gmail.com-0.1.0.zip

Silvery-Corgan commented 8 years ago

@elvetemedve Sorry for the late reply. I have tested this for the past week. The issue is no longer present with a few exceptions. So the stuttering will appear sometimes but it's not going to be like it was before and it certainly fades away after about 10-20 seconds. The stuttering appears roughly after 1, 1 & a half hour of watching something but like I said it's really negligible. You did an awesome job with that. :+1: Is there something that can be done to have this fixed permanently? (Otherwise I'll just have to live with it) :)

By the way, this should be pushed to production. I had no crash in the past week.

elvetemedve commented 8 years ago

@Silvery-Corgan Thanks for the feedback. That's good. Actually further improvements can be done, but I have no much free time nowadays.

The extension loads system statistics by reading a lot of files from the kernel filesystem (/proc or /sys). It turned out that even if it reads asynchronously, Gnome Shell somehow blocks the rendering until all operation is complete. As one of the Gnome developer suggested, I moved some of the most used read operations into an "idle callback function" which resulted in a smoother rendering. However not all file reads are done this way, so it can be further improved.

I have no idea why do you see that happening after 1 hour or so. The extension does not accumulate tasks over time, except if there is a bug somewhere.

I'll publish the modified version soon.

elvetemedve commented 8 years ago

New version has been published.

pts-sergiomartins commented 5 years ago

This problem affects me on Ubuntu 18.04. Is it possible we have a regression?

Package: gnome-shell-extension-system-monitor
Version: 35-1ubuntu0.18.04.1
elvetemedve commented 5 years ago

@pts-sergiomartins The last related change is made in Version 9. Later releases did not touch that.

ghost commented 5 years ago

@elvetemedve I was running into the same problem also on ubuntu 18.04.1 with gnome-shell-extension-system-monitor/bionic-updates,bionic-updates,now 35-1ubuntu0.18.04.1 all

disabling all menu entries (e.g. cpu, temp,..) makes stuttering disappear, but as soon as one entry is activated(+ session logout/login) the effect is back and visible not just while video playback but also scrolling in firefox...

Any ideas?

elvetemedve commented 5 years ago

@frnkd Sorry, I'm not a GNOME expert, so don't really know what can be done. Also I don't have free time to dig deeper into the internals of the GNOME desktop components. Probably GNOME 4.0 will solve this kind of visual bug, but there is no planned release date yet. Also the extension might need complete rewrite.

I'm currently using Arch Linux and haven't experienced this bug since the improvement changes.

ghost commented 5 years ago

Thx for taking the time. I just like the exension and cannot use it anymore because of the described problem. Will gladly provide debug info if you plan to work further on this issue in future.

kyrsjo commented 2 years ago

The stuttering bug is definitively back for me. Fedora 35, on a big but old machine. When enabled, the whole desktop freezes for a fraction of a second every time the applet updates.

However: If I disable the swap activity monitoring, the problem goes away, and I can have the applet enabled without stuttering.