neovide / neovide

No Nonsense Neovim Client in Rust
https://neovide.dev
MIT License
13.07k stars 532 forks source link

Wierd Artifacting and broken fonts after scrolling #755

Closed smit2909 closed 3 years ago

smit2909 commented 3 years ago

Describe the bug

To Reproduce Steps to reproduce the behavior:

  1. Go to Terimal, open any file in neovide
  2. Scroll down using j or shift + ] or any other key
  3. See error

Expected behavior Fonts and lines should not be cut off after scrolling

Screenshots If applicable, add screenshots to help explain your problem. Screenshot from 2021-06-26 01-08-56 Screenshot from 2021-06-26 01-09-11

Look at line 210 in below screenshot Screenshot from 2021-06-26 01-07-33

Desktop (please complete the following information):

Kethku commented 3 years ago

What font are you using

smit2909 commented 3 years ago

Here a bunch that very consistently show such behaviour

This behaviour occurs regardless of the multigrid flag

doums commented 3 years ago

Hi, I observe the same bug here. I use JetbrainsMono.

Kethku commented 3 years ago

i can repro something like this on windows now. The trick was dpi scaling had to be enabled, so it looks like this has to do with the renderer's interaction with scaling.

last-partizan commented 3 years ago

Yes, it seems related to scaling. I tried to reproduce bug with scaling set to 1, and was not able to. At 1 it works fine.

When using wayland it renders at 1 regardless of system-wide scaling.

I'll try to dig this issue.

doums commented 3 years ago

What scaling setting are you talking about ? Because I far as I know the only scaling setting I set myself are some env variables for GTK and QT

QT_AUTO_SCREEN_SCALE_FACTOR 1
GDK_SCALE 2
GDK_DPI_SCALE 0.5

and dpi for X11

Xft.dpi: 120
last-partizan commented 3 years ago

I'm talking about this scaling: https://docs.rs/winit/0.22.2/winit/window/struct.Window.html#method.scale_factor

If you're using x11, it's calculated from DPI.

last-partizan commented 3 years ago

As workaround you can set WINIT_X11_SCALE_FACTOR=1 and just set bigger font size.

last-partizan commented 3 years ago

@doums try running latest version with neovide --log, and then show me grep scale neovide_rCURRENT.log. And what exact font and font size are you using?

Issue is affecting some font sizes more than others, and i want to find some good combinations to reproduce it.

last-partizan commented 3 years ago

@Kethku I'm pretty sure it's some sort of rounding issue. window.scale_factor() sometimes passed as f64 and sometimes as f32. And multiplied by font size in some parts. And with scaling like 1 or 2 it works perfectly fine.

Maybe you have some ideas/hints?

last-partizan commented 3 years ago

@Kethku i'm worried abount those lines:

image

In src/renderer/mod.rs:draw_frame there is root_canvas.scale((scaling, scaling)); And in src/renderer/rendered_window.rs:handle_window_draw_command there is canvas.scale((scaling, scaling));

If i comment out one of them, it scales in half, if i comment both - it scales in half more. Is it supposed to work this way?

last-partizan commented 3 years ago

When i get these artifacts, cursor is rendered at slightly different (and i think, correct?) position.

image

And when i change mode to visual and make a selection, line gets rerendered at same position as cursor, without artifacts.

Kethku commented 3 years ago

I introduced a fix for this here: https://github.com/Kethku/neovide/pull/791 which removes the scroll performance optimization which seems to cause the issue. Could you try it and or review the change? I know you've been looking into this @last-partizan

last-partizan commented 3 years ago

https://github.com/Kethku/neovide/pull/793

Here is another fix. @doums @smit2909 please, try it.

doums commented 3 years ago

bug seems to be fixed in #793 good job !

But I can't build main, it's failing with

error: checksum for `skia-safe v0.40.2` changed between lock files
last-partizan commented 3 years ago

@doums Merged fix

doums commented 3 years ago

main is still broken

smit2909 commented 3 years ago

793

Here is another fix. @doums @smit2909 please, try it.

Awsome! Working like a charm @last-partizan . No more broken fonts. I am on 755-scale-factor branch though. I didnt build after the merge into main.

last-partizan commented 3 years ago

@doums are you sure?

https://github.com/Kethku/neovide/commit/5c5cf9088da9ce205f2225ca969fcf2f251e4c12

Does git log includes this commit?

last-partizan commented 3 years ago

Just to be clear, #793 is not merged yet.

I just merged fixes for broken main branch.

doums commented 3 years ago

@doums are you sure?

5c5cf90

Does git log includes this commit?

I was talking about artifact bug on main branch. Yes the build is fixed of main branch and yes it includes the commit.

last-partizan commented 3 years ago

This should be fixed now on main.