zed icon indicating copy to clipboard operation
zed copied to clipboard

Text rendering is broken/blurry on linux when using fractional scaling.

Open tropicaaal opened this issue 9 months ago • 3 comments

Summary

This is a little strange. Below are two screenshots of the same text run when the window is resized to different heights:

Image

Image

The top one is noticably blurrier, while the bottom is sharper. This appears to only happen when using fractional scaling (I am running 125% scaling on GNOME, Fedora 41). My best guess as to what could be causing this would be that resizing the window relayouts the text to be on a subpixel, resulting in some subpar antialiasing results.

You can also observe the text slightly shifting when rendered to subpixel boundaries every few pixels of window height when I resize:

https://github.com/user-attachments/assets/0c649507-2f0d-415b-ba35-f29626bd1dd7

This does not occur on 100% scaling (video below)

https://github.com/user-attachments/assets/2563a154-0975-44a9-9770-e5ac26b9465d

This behavior also appears to be mostly GPUI-specific. I don't observe this behavior on electron apps (VSCode) for example.

Steps to trigger the problem:

  1. Apply a fractional scaling factor (e.g. 125%)
  2. Scale the window's height by slight amounts.
  3. Observe slight shifts in text rendering as the height changes.

Actual Behavior:

Text clarity changes every few pixels of height, shifting between sharp and blurry rendering.

Expected Behavior:

Text should remain sharp at all window heights and scale factors.

Zed Version and System Specs

Zed: v0.173.11 (Zed) OS: Linux Wayland fedora 41 Memory: 15 GiB Architecture: x86_64 GPU: AMD Radeon Graphics (RADV RENOIR) || radv || Mesa 24.3.4

tropicaaal avatar Feb 19 '25 21:02 tropicaaal

Thank you for reporting this. I'm using KDE Wayland and can consistently reproduce the issue at fractional scales like 125% and 175%. The blur and jittering (~1px) are subtle but clearly noticeable.

smitbarmase avatar Feb 20 '25 07:02 smitbarmase

Duplicate of #18113, but this does illustrate the issue better.

jansol avatar Feb 20 '25 15:02 jansol

has anyone found a workaround?

suhaylmv avatar Mar 21 '25 19:03 suhaylmv

@as-cii and I took a look at this. We're fairly convinced that the issue has to do with a 1px mismatch in the size of the buffer with the wl_surface or the gpu bounds. Here's some notes from our investigation in case someone else tries to dig into this:

  • The blurriness applies to everything rendered in the window, not just text.
    • I initially assumed this was a font hinting problem, but the fact that arbitrary paths (we used a horizontal line in the UI to verify this) are made blurry at the same time as text disproves that theory.
  • Unintuitively the blurriness occurs whenever the height of the window multiplied by the scale factor is a whole number.
  • This means that if you have your scale set to 1.2 for example, you'll get blurry rendering when the height is a multiple of 5
    • This can be tested with a tiling window manager that lets you script window resizing. I was using sway and tiled the zed window over a terminal where I ran watch -n1 swaymsg resize shrink height 1px to change the size by 1px per second so we could clearly see when you hit the blurry state.
    • To log the size on each resize you can add a dbg!(size) here
  • There's a note in the fractional scale wayland protocol docs that says "For toplevel surfaces, the size is rounded halfway away from zero". We're a bit worried that we're using floor but changing this to round or ceil seemed to give us the same results.
  • Sub-pixel rendering makes it slightly harder to see the blurriness, you can disable it by setting these lines to zero.
  • Using WAYLAND_DEBUG=1 you can verify that the set_destination and set_geometry wayland requests and zed window size all match. When the window is floating there seems to be a 10px offset and the window is 20px smaller in wayland than in zed, but given that the blurriness occurs both when floating and when tiled we assume that isn't relevant.
  • Resizing the window horizontally seems to have no effect. It's unclear why only changes in the height cause the blurriness.

P1n3appl3 avatar Jun 12 '25 17:06 P1n3appl3

We found a rounding problem with the layout engine some time ago, could it possibly be related?

https://github.com/zed-industries/zed/pull/31836

GoldsteinE avatar Jun 12 '25 17:06 GoldsteinE

Hmm, I just checked out that PR and can still replicate the problem so it doesn't seem so unfortunately.

Also @as-cii linked me to this sway PR which seems related. Smit mentioned above that he could replicate this issue on KDE though so I think there's still a problem on Zed's end either way.

P1n3appl3 avatar Jun 12 '25 18:06 P1n3appl3

I have also been suffering from similar issues for a long time. Is there any PR that's being worked on to fix this that I should be aware of?

In case you need my setup info:

  • OS: Fedora 42 (KDE edition)
  • KDE Plasma version: 6.3
  • Zed version: Zed 0.190.6 9a2dcbbe244407fed51d61f38e4a4a59ec1cccc6
  • Fractional scaling: 150%

AMythicDev avatar Jun 18 '25 10:06 AMythicDev

https://github.com/zed-industries/zed/pull/33087 fixes this for Gnome and KDE. But, for weird reason not for Sway (or maybe other wlroots based compositors). I'm keeping this issue open until that is also resolved.

smitbarmase avatar Jun 20 '25 15:06 smitbarmase

Image still blurry on gnome, 150% fractional scaling, but slight

f2w00 avatar Jul 03 '25 14:07 f2w00

still blurry on gnome, 150% fractional scaling, but slight

But is it equally blurry with 100% scaling? That falls under #7992

jansol avatar Jul 03 '25 14:07 jansol

I can confirm that after updating to v0.193.X that this seems to be fixed on my system.

tropicaaal avatar Jul 03 '25 23:07 tropicaaal

Shouldn't this still be open as per https://github.com/zed-industries/zed/issues/25195#issuecomment-2992129530?

WaffleLapkin avatar Jul 07 '25 17:07 WaffleLapkin

still blurry on gnome, 150% fractional scaling, but slight

But is it equally blurry with 100% scaling? That falls under #7992

sorry for missing message, as additional information, machine info as following,

OS: Manjaro Linux x86_64 Host: Code01 Ver2.0 (1) Kernel: Linux 6.15.3-1-MANJARO Uptime: 11 hours, 21 mins Packages: 1501 (pacman)[stable] Shell: zsh 5.9 Display (CSO160A): 2560x1600 @ 120 Hz (as 1704x1065) in 16" [Built-in] DE: GNOME 48.2 WM: Mutter (Wayland) WM Theme: Breeze Theme: Breeze [GTK2/3/4] Icons: Tela-dark [GTK2/3/4] Font: JetBrainsMono Nerd Font Mono Medium (10pt) [GTK2/3/4] Cursor: oreo_white (24px) Terminal: GNOME Console 48.0.1 Terminal Font: JetBrains Mono Medium (10pt) CPU: AMD Ryzen 7 6800H (16) @ 4.79 GHz GPU: AMD Radeon 680M [Integrated] Memory: 11.65 GiB / 22.20 GiB (52%) Swap: Disabled Disk (/): 57.45 GiB / 92.95 GiB (62%) - ext4 Local IP (wlo1): 192.168.50.221/24 Battery (SSBS81): 100% [AC Connected] Locale: en_US.UTF-8

and zed stable 0.194.3, not equally blurry with 100%scaling, it is as sharp as vscode, and the blurring phenomenon is less pronounced when the scaling ratio is reduced. 100%scaling compare with vscode side by side

Image 150% compare Image

f2w00 avatar Jul 12 '25 14:07 f2w00

and zed stable 0.194.3, not equally blurry with 100%scaling, it is as sharp as vscode, and the blurring phenomenon is less pronounced when the scaling ratio is reduced. 100%scaling compare with vscode side by side

I think that this is at minimum a separate issue and may fall under #7992. This issue concerns the quality of text blurring/sharpening as the window size changes rather than the general rendering quality of the text at all times. Compared to VSCode, zed certainly has some work to be done in regards to font sharpness and rendering quality, but they are up against chromium's entire rendering stack here.

tropicaaal avatar Jul 13 '25 02:07 tropicaaal

and zed stable 0.194.3, not equally blurry with 100%scaling, it is as sharp as vscode, and the blurring phenomenon is less pronounced when the scaling ratio is reduced. 100%scaling compare with vscode side by side

I think that this is at minimum a separate issue and may fall under #7992. This issue concerns the quality of text blurring/sharpening as the window size changes rather than the general rendering quality of the text at all times. Compared to VSCode, zed certainly has some work to be done in regards to font sharpness and rendering quality, but they are up against chromium's entire rendering stack here.

make sense, i'm not familiar with gui developing, the most confusing part is that zed looks sharper in 1080p with 100% scaling , and vscode is way sharper in 2560*1600 with 150% scaling, while almost same sharp with 2560p 100%scaling, so i thought it was because the scaling, but your zed looks fine, maybe should I follow #7992

f2w00 avatar Jul 13 '25 03:07 f2w00

I finally got on Sway to test it myself, and it looks like https://github.com/zed-industries/zed/pull/33087 indeed fixed it. I'm closing this as resolved. Note that this issue is for when resizing causes blurry text, not for rendering issues in general, for which you can follow https://github.com/zed-industries/zed/issues/7992.

smitbarmase avatar Aug 05 '25 13:08 smitbarmase