daa84 / neovim-gtk

gtk ui for neovim
GNU General Public License v3.0
718 stars 56 forks source link

Neovim-gtk flickers a lot #57

Closed glacambre closed 6 years ago

glacambre commented 6 years ago

Hi, I'm trying to run neovim-gtk on my computer (Linux 4.14, Debian, X11, integrated GPU) and it flickers a lot. I tried running neovim-gtk with an empty init.vim and also making the window smaller, nothing changed. The only way to make the flickering stop on my computer is to focus another window.

I don't really know how to troubleshoot this issue, if you need more information, feel free to ask.

Pretty cool project by the way ! :)

daa84 commented 6 years ago

From description looks like cursor repaint produce flicker, as when window not in focus - cursor stops. Flickering can happens when double buffer is disabled, but by default it must be enabled.

unclechu commented 6 years ago

I have the same issue when I open vim-ctrlspace window, since I started to use neovim-gtk, I've never reported it because I haven't found a way to simply reproduce it. I tried to make clean init.vim with only vim-ctrlspace but in this case this flickering isn't happening, so I think it's not related to just vim-ctrlspace. Here is my config: https://github.com/unclechu/neovimrc

unclechu commented 6 years ago

I just recorded a screencast that demonstrates flickering when I open vim-ctrlspace window: https://www.youtube.com/watch?v=uqoUnieAdg8

unclechu commented 6 years ago

Sometimes it's getting worse, on this video it's quite better than usual. Sometimes this happens even without opening vim-ctrlspace window, and even if I restart neovim-gtk it still happens. When this happens I just open TUI and go back to neovim-gtk after some time and this at least again happens only with vim-ctrlspace window (looks like some black magic).

unclechu commented 6 years ago

@daa84 I just realized it happens during cursor blinking animation. I just met a moment when this blinking was at its worst rate and I see that in pauses of cursor blinking animation whole screen isn't blinking.

unclechu commented 6 years ago

@daa84 look at my dirty hotfix to test it with cursor without blinking: https://github.com/daa84/neovim-gtk/compare/master...unclechu:dirty-fix/cursor-without-animation?expand=1 It just gets it better, not heals it completely, I still got flickering when I move selection in list of buffers in vim-ctrlspace but when I'm not touching anything it stills without flickering. See screencast: https://youtu.be/dgXCopYP7N0

P.S. Maybe it would be a good idea to add an command-line option to disable cursor animation, not just in sense of this issue but as an option for a user.

daa84 commented 6 years ago

The big question is why so strange thing happens? Gtk by default have double buffering enabled. So it can be just some nvim blinking. Can you run RUST_LOG=nvim_gtk::shell cargo run to check logs, maybe some resize events come when flickering happens? Another way i can try is to do double buffering by hand with cairo surface. Maybe in some environments double buffer is disabled by default

daa84 commented 6 years ago

Created test branch with double buffering through second cairo surface. https://github.com/daa84/neovim-gtk/tree/double_buffer @unclechu can you test this branch? Solution is a bit dirty, but i want to find problem source.

unclechu commented 6 years ago

@daa84 I'll try this branch soon.

unclechu commented 6 years ago

@daa84 Wow, now everything is fine, I see no flickering at all, it works. Thanks, I'll use this branch for now!

unclechu commented 6 years ago

I could record a screencast if you need it that proves that it works.

daa84 commented 6 years ago

strange, i always think that gtk do double buffering for cairo automatically. But looks like in some cases it does not. Can you write your configuration? wayland/xorg, video driver?

Current double buffer solution think bad for performance. Later i adapt this changes better way.

glacambre commented 6 years ago

@daa84 The double_buffer branch fixes the flickering on my end too! Running RUST_LOG=nvim_gtk::shell cargo run on the master branch doesn't produce any output.

Here are bits of information about my configuration I found in my X11 log in case you need it.

Matched modesetting as autoconfigured driver 0
Matched fbdev as autoconfigured driver 1
Matched vesa as autoconfigured driver 2
Assigned the driver to the xf86ConfigLayout
Loading /usr/lib/xorg/modules/drivers/modesetting_drv.so
Loading /usr/lib/xorg/modules/drivers/fbdev_drv.so
Loading /usr/lib/xorg/modules/drivers/vesa_drv.so
FBDEV: driver for framebuffer: fbdev
VESA: driver for VESA chipsets: vesa
glamor: OpenGL accelerated X.org driver based.
modeset(0): [DRI2]   DRI driver: i965
modeset(0): [DRI2]   VDPAU driver: i965

I run the i3 window manager without a compositor if that makes a difference.

Thank you for fixing this bug!

unclechu commented 6 years ago

@daa84 xorg.conf.txt

Compton (composite manager) running command:

compton --dbus --backend glx \
    --blur-background --blur-background-fixed --blur-kern 7x7box \
    -c -z  -r 10  -o 0.3  -t -10  \
    --xinerama-shadow-crop \
    -m 0.9
λ lspci | grep -i vga
00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller (rev 06)
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Tobago PRO [Radeon R7 360 / R9 360 OEM] (rev 81)
λ glxinfo | grep -i opengl
OpenGL vendor string: X.Org
OpenGL renderer string: Gallium 0.4 on AMD BONAIRE (DRM 2.50.0 / 4.13.16-100.fc25.x86_64, LLVM 3.9.1)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 17.0.5
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 17.0.5
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.1 Mesa 17.0.5
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10
OpenGL ES profile extensions:
unclechu commented 6 years ago

@daa84 You could add an command-line option to disable double-buffering for users who could have performance issues.

unclechu commented 6 years ago

Anyway, I think some usually unnoticeable performance issues (I personally haven't noticed any lags) is better than issues with my eyes. Maybe it would be good idea to ask about that in issues of package that provides it? I think it's here: https://github.com/gtk-rs/cairo/issues

akatrevorjay commented 6 years ago

I noticed this too. Glad there's a fix here now. New laptop with 120hz display; nvidia proprietary driver.

@glacambre Is your display by chance > 60hz?

akatrevorjay commented 6 years ago

So, the branch at least for me only removes ~90% of the flickering, but it still happens every few seconds, especially during redraw upon move.

akatrevorjay commented 6 years ago

Actually now it stopped flickering at all; strange.

If it happens again I'll report back, otherwise I'll assume I may have ran it before compilation and installation was complete.

Kudos +42

unclechu commented 6 years ago

@akatrevorjay That it is still flickering a bit could be some tearing caused by your proprietary video driver. Which DE do you use? You could try some composite manager with vsync feature as attempt to fix it (such as compton).

glacambre commented 6 years ago

@akatrevorjay No, my display is 60Hz.

akatrevorjay commented 6 years ago

@unclechu I use compton already (with vsync) :)

unclechu commented 6 years ago

@daa84 Isn't that fix for double-buffering already in master branch (I'm just asking if I still urged to use separated branch or could try fresh master)?

daa84 commented 6 years ago

no, it still not merged. As this fix slowdown rendering i plan to introduce env variable that will switch double buffering behavior (by default it will be disabled). As not all user have such problems with flickering.

daa84 commented 6 years ago

merged fix to master, by default disabled, environment variable NVIM_GTK_DOUBLE_BUFFER=1 can be used to enable it

maybe later i remove it, if this buffer will be used for some other functionality.

unclechu commented 6 years ago

Thanks!

unclechu commented 6 years ago

Maybe this would help someone, my nvim file in ~/.local/bin:

#!/usr/bin/env bash
env NVIM_GTK_DOUBLE_BUFFER=1 \
    "$HOME/neovim-gtk-2018-04-08-74d7417/bin/nvim-gtk" "$@" || exit $?

To auto-enable NVIM_GTK_DOUBLE_BUFFER flag where $HOME/neovim-gtk-2018-04-08-74d7417 is a path in where you installed neovim-gtk.

unclechu commented 6 years ago

I'm just leaving here a link to an issue of another editor: https://github.com/equalsraf/neovim-qt/issues/166#issuecomment-375065567 Where another user mentioned he was having this issue too.

unclechu commented 6 years ago

@daa84 Now by using 0524e97b8ab1fc2207abb3e827fa7c5cff9207b3 I see this is fixed, I'm using neovim-gtk without this environment variable hack and don't see any flickering. Thanks a lot!