nicolargo / glances

Glances an Eye on your system. A top/htop alternative for GNU/Linux, BSD, Mac OS and Windows operating systems.
http://nicolargo.github.io/glances/
Other
26.64k stars 1.53k forks source link

Screen frequently flickers when outputting to local display #2490

Closed ATLief closed 4 months ago

ATLief commented 1 year ago

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

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!

nicolargo commented 1 year ago

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) ?

ATLief commented 1 year ago

@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.

nicolargo commented 1 year ago

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).

ATLief commented 1 year ago

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.

nicolargo commented 1 year ago

@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().

FichteFoll commented 1 year ago

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?

rubin110 commented 10 months ago

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.

johananl commented 8 months ago

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).

x61s commented 5 months ago

The same. Blinking every second.

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

nicolargo commented 5 months ago

Should be solved in Glances 4.0.0.

FichteFoll commented 4 months ago

Can confirm, thanks for the fix!

ATLief commented 4 months ago

@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?

nicolargo commented 4 months ago

Is it reintroduce in version 4.0.7 ?

Can you also try with another terminal ?