glances icon indicating copy to clipboard operation
glances copied to clipboard

Screen frequently flickers when outputting to local display

Open ATLief opened this issue 2 years ago • 7 comments

Describe the bug When outputting to a local display, sections of the screen frequently flicker as the information updates. Reverting commit ed4cc5e fixes this particular issue, but re-introduces the bug in #2211. Increasing the delay between updates increases the delay between flickers. This issue doesn't happen when displaying the console on another computer over SSH.

To Reproduce

  1. Plug a display (HDMI and VGA tested) directly into the computer
  2. Start a console session on that display (native Linux fbcon and kmscon tested)
  3. Start a glances session in that console session (standalone and client mode tested)
  4. See error

Expected behavior The text on the screen changes without large portions of the text briefly disappearing.

Screenshots

https://github.com/nicolargo/glances/assets/3957073/24f66b83-af80-4c07-9272-198e3faaf903

Environement

  • Operating System: Debian GNU/Linux 12 (bookworm)
  • Glances & psutil versions: Glances v3.3.1.1 with PsUtil v5.9.4
  • How do you install Glances: Package manager (Apt)
  • Glances test:
===============================================================================
Glances 3.3.1.1 (/usr/lib/python3/dist-packages/glances/__init__.py)
Python 3.11.2 (/usr/bin/python3)
PsUtil 5.9.4 (/usr/lib/python3/dist-packages/psutil/__init__.py)
===============================================================================
alert         [OK]    0.00001s []
amps          [OK]    0.00126s key=name [{'key': 'name', 'name': 'Dro
cloud         [OK]    0.00001s {}
connections   [NA]
core          [OK]    0.00058s {'phys': 6, 'log': 12}
cpu           [NA]
diskio        [OK]    0.00105s key=disk_name [{'time_since_update': 2
docker        [OK]    0.00002s []
folders       [OK]    0.00001s []
fs            [OK]    0.00042s key=mnt_point [{'device_name': '/dev/m
gpu           [OK]    0.00001s []
help          [OK]    0.00000s None
ip            [OK]    0.00056s {'gateway': '192.168.6.1', 'address': 
irq           [NA]
load          [NA]
mem           [OK]    0.00008s {'total': 16684060672, 'available': 11
memswap       [OK]    0.00009s {'total': 8589930496, 'used': 66322432
network       [OK]    0.00046s key=interface_name [{'interface_name':
now           [OK]    0.00001s 2023-07-06 18:46:13 EDT
percpu        [OK]    0.00004s key=cpu_number [{'key': 'cpu_number', 
ports         [OK]    0.00000s [{'host': '192.168.6.1', 'port': 0, 'd
processcount  [OK]    0.17216s {'total': 1581, 'running': 1, 'sleepin
processlist   [OK]    0.00056s key=pid [{'memory_info': pmem(rss=5190
psutilversion [OK]    0.00001s (5, 9, 4)
quicklook     [OK]    0.00018s {'cpu': 7.5, 'percpu': [{'key': 'cpu_n
raid          [NA]
sensors       [OK]    0.00000s key=label [{'label': 'Composite', 'uni
smart         [NA]
system        [OK]    0.00000s {'os_name': 'Linux', 'hostname': 'post
uptime        [OK]    0.00006s {'seconds': 11296}
wifi          [NA]
===============================================================================
Total time to update all stats: 0.18445s
===============================================================================

Additional context Please ignore the empty space on the right side of the display; I limit the number of TTY columns to hide the VIRT and RES columns in Glances, but the problem persists even without that limitation.

If this issue can't be fixed, maybe you could add an option to use the new or old clearing behaviour, or an option to clear the screen at a slower interval (maybe every 30 update intervals, or every minute).

Thank you for fixing the other bug, and everything else you do for this awesome project!

ATLief avatar Jul 07 '23 00:07 ATLief

Thanks for the issue report (and the video).

I did not reproduce on my side. Can you please try with the latest Glances version (3.4.0.2) ?

nicolargo avatar Jul 08 '23 13:07 nicolargo

@nicolargo I installed 3.4.0.2 via PyPi/pipx (Glances v3.4.0.2 with PsUtil v5.9.5) and was able to reproduce the issue. There was also a version 3.4.0.3 on PyPi (Glances v3.4.0.3 with PsUtil v5.9.5) that I tried and it had the same issue.

But I found something else: I could reproduce the issue on another computer (running the same version of Debian), but not within an X session (even when maximizing the window). So maybe it has something to do with window management / the terminal emulator.

ATLief avatar Jul 09 '23 04:07 ATLief

Issue should be solved in the development branch. I switch back to self.term_window.erase() and add a new hot key (Ctrl-R) to force a self.term_window.clear() (related to https://github.com/nicolargo/glances/issues/2211).

nicolargo avatar Jul 15 '23 07:07 nicolargo

Thanks! Would you be willing to accept a PR in a few weeks that periodically calls self.term_window.clear()? Maybe as a hard-coded proportion of the updates? I'm thinking every 150 updates, which would be every 5 minutes at 2 seconds between updates. I can also try to add a config option and cli argument to change that multiple.

For anyone else experiencing #2211 again, a hacky workaround is to periodically echo control-r into the stdin of glances. For example while sleep 300; do echo -n $'\cr'; done | glances, although this prevents other interactive input. There's probably a better workaround when run directly on a TTY.

ATLief avatar Jul 22 '23 11:07 ATLief

@ATLief yes a PR with a configurable self.term_window.clear() call every n seconds can make sense (by default n should be unset or set to 0 to avoid call to self.term_window.clear().

nicolargo avatar Jul 24 '23 16:07 nicolargo

For the record, I also experience this on Arch with alacritty. On every refresh, the entire terminal window very briefly flickers, most likely by being empty for a fraction of a second/one frame. When the window is very small, it becomes less noticable or not at all, presumably because refilling the few characters of the window happens fast enough that a display refresh doesn't happen between clearing the window and refilling it.

Other tools like htop do not have this issue and I also haven't seen #2580 with them, but I also very rarely have other processes running in the background of the same shell I later run a TUI in, if ever, so the potential for this happening is much reduced. Would using the "alternate screen" feature of terminal emulators be an option?

FichteFoll avatar Oct 12 '23 17:10 FichteFoll

I'm seeing this issue with Windows Terminal 1.18.3181.0 under Debian Bookworm via WSL, Glances 3.3.1.1 deb from the Debian repos, when connecting to a different machine on my network. SSHing into that machine and running glances -c there I don't have the flicker issue, nor do I when running glances locally within WSL or running the server locally and connecting locally.

rubin110 avatar Dec 21 '23 16:12 rubin110

For the record, I also experience this on Arch with alacritty.

I confirm this is happening for me, too, with alacritty 0.14.0-dev (cb3a79db).

johananl avatar Feb 22 '24 16:02 johananl

The same. Blinking every second.

Glances v3.3.1.1 with PsUtil v5.9.4 alacritty 0.11.0 Debian 12.5

x61s avatar May 22 '24 10:05 x61s

Should be solved in Glances 4.0.0.

nicolargo avatar May 22 '24 10:05 nicolargo

Can confirm, thanks for the fix!

FichteFoll avatar May 25 '24 09:05 FichteFoll

@nicolargo Thanks again for fixing this! Since it unfortunately re-introduces #2211, would you mind re-opening that issue to help with future search-ability?

ATLief avatar May 29 '24 01:05 ATLief

Is it reintroduce in version 4.0.7 ?

Can you also try with another terminal ?

nicolargo avatar May 29 '24 06:05 nicolargo