Blurry text when using Sway or fractional scaling on Wayland

IntelliJ IDEs - like other Java applications - use X11 to talk to the Xorg server and render on Linux. When running on a desktop with Wayland (like Ubuntu 21.04), Java actually continues to work through X11, but this time the Xorg server is implemented by XWayland, providing a migration path for the applications that don't (yet) use Wayland directly. 

Without fractional scaling enabled, XWayland simply lets X applications render the same way as under "pure" Xorg suggesting the desired DPI through the Xft.dpi X resource value. In this configuration, text is rendered as sharp as under “pure” Xorg.

When using Sway or with the fractional scaling enabled, any scale above 100% - fractional or not - reduces the screen size available to X applications proportionally. For example, this is what an X application sees with "fractional" scaling of 200%:

$ xrandr --current
Screen 0: minimum 16 x 16, current 1280 x 800, ...

and this is with the same scaling of 200%, but fractional scaling disabled:

$ xrandr --current
Screen 0: minimum 16 x 16, current 2590 x 1664, …

As you can see, the screen size with fractional scaling is roughly twice as small. So in this mode Wayland provides a smaller screen to X windows that are then pixel-stretched according to the system's scaling factor. This makes the window's contents look somewhat blurry, which is most noticeable with text. The effect can be seen with any "pure" X application like XTerm, for instance. 

Many applications have already been ported to use Wayland, either directly or through a toolkit like Gnome. Java is on its way to be ported. The Wayland rendering pipeline project has just started (see  the announcement) and JetBrains has joined this initiative. 

Until Java has learned to use Wayland natively or until the fractional scaling feature of Wayland is reworked to avoid pixel-stretching X windows, workarounds for blurry text would be to

  • when using Sway, switch off scaling completely
  • switch off fractional scaling ([link1] [link2]) or
  • go back to using "pure" X session without Wayland ([link]). 

References

22 out of 32 found this helpful
6 comments

Summary: If you have a 4K screen that is usable at 200%, do not enable fractional scaling. Use the 200% option without fractional scaling. When gnome's experimental fractional scaling is disabled, a 200% scale is handled as 2x (that is, integer scaling) and xwayland windows see the true resolution. Then a DPI capable xwayland app such as jetbrains will natively support hidpi, at this point you have the same situation as you would with an x session. With experimental fractional scaling turned on, gnome does not treat 200% as integer factor 2 scaling. It will still tell xwayland apps the 100% resolution, and the scale them up (which is where blur comes from).

Since I originally posted, another option is KDE Plasma 5.27, where the wayland session can be told to present the true canvas resolution to Xwayland apps even when using fractional scaling. Gnome only does this under the settings I described above.

If you have multiple monitors and only one of them is hidpi, the JetBrains IDE must be launched on that monitor. This is the trickiest part. xrandr will help (yes, it still has a use, it will set the primary xwayland monitor).,

Edited by Tim Richardson
0

The actual summary is that you can't use JetBrains IDE's with fractional scaling enabled. There is no 200% option that isn't fractional scaling. This is the one thing preventing me from moving to Wayland, because other applications (browsers) do not scale well with the "200% option", only the views change- none of the toolbars or menus change, including tab size.

1

GNOME is the most popular desktop environment on linux. Ubuntu, Fedora and Arch all default to Wayland when using GNOME. Fedora and probably more also default to Wayland with KDE. High DPI monitors are very common these days, making fractional scaling a necessity.

From this it seems to follow that a large majority of linux users would be affected by this. I think JetBrains should fix this ASAP.

Personally, I have two 27 inch 4k monitors. Both 100% and 200% scaling are unusable. The blurriness is very pronounced, resulting in a terrible experience.

3

I can hardly believe that the developers of Java only "just started" porting Java to Wayland in 2022. This should have started a long time before that. I mean, I am not a Linux geek or anything, but even I started using Wayland back in 2020 or 2019. Why didn't the developers know that Wayland would replace X11 soon? They just did not care about Linux desktop?

 

Edited by homer simpson
3

X seems to be the only option. wayland really hurts my eyes. I was looking forward to Wayland for almost a decade. seems to me Java's priorities lay elsewhere.

0

I switched to KDE/Plasma to be able to use Wayland & HiDPI monitors. As a former i3 user I tried Sway first, but I could not get it to work as expected. KDE/Plasma worked out of the box.

0

Please sign in to leave a comment.

Have more questions?

Submit a request