~/Simon's Blog ❯

My Wayland experience with Nvidia

I have been experimenting with Sway on Nvidia today, and to say the least, it was quite the experience.

It all started out today when I was sitting at home during a school break, and decided I finally wanted to actually get Sway to properly work under Nvidia's drivers. After all, others have done it before...right? So, I got to work.

Installation

Installation was quite easy over here on Void Linux. it was really just a matter of installing the sway package:

sudo xbps-install -Sy sway

and once I had done that, uninstalling my previous KDE Plasma desktop:

sudo xbps-remove -Ry kde5 kde5-baseapps

After installation, I quickly needed to make sure I had nvidia-drm.modeset=1 set in my GRUB configuration file. So I opened /etc/default/grub, added it to my CMDLINE_DEFAULT and regenerated my configuration using grub-mkconfig --output=/boot/grub/grub.conf

Once I had that, it was onto getting my dotfiles and pushing them to their respective directories (so quite literally just ~/.config/). From there, I installed some extra dependencies that I hadn't installed yet (Waybar, Wofi, Grimshot, just to name a few) and started Sway using the --unsupported-gpu flag. And...it worked!...kinda?

Issues

However, I quickly noticed issues. Whilst everything was very smooth, there was still some theming leftovers from my old KDE Plasma configuration. So after quickly installing gnome-tweaks to change some of those (GTK Theme for instance) that was resolved pretty quickly. As I was doing that, I noticed windows frequently flicker and having artifacts. Of course, I quickly got to investigating. I ran Sway using the --debug flag additionally, and saw nothing out of the usual, so I decided to search it up instead as someone has probably encountered it before and documented it somewhere (despite the fact Sway doesn't support Nvidia). And look at that, I found something even better! Somebody has made an AUR package bundling together a lot of utilities and changes to make Sway work on Nvidia GPUs, which was incredibly timesaving for myself despite the fact I was on Void. I started looking at the environment variables, and adding most of them to my display manager, emptty. I did however skip adding the following, adding them to /etc/environment instead:

GBM_BACKEND=nvidia-drm
__GL_VRR_ALLOWED=0
__GL_GSYNC_ALLOWED=0
__GLX_VENDOR_LIBRARY_NAME=nvidia

So, from there I was already a lot of the way there! Features I did not need were disabled, and I switched to WLR_RENDERER=vulkan to get rid of the flickering as shown in the AUR package.

And that's where more issues arised... I was still missing some packages for the Vulkan renderer to work, notably Vulkan-ValidationLayers, which was needed for sway to not error out with ERROR_LAYER_MISSING (or something along those lines). However, the actual Wayland part of the compositor was now running all fine! Though, there is more than just Wayland application support.

XWayland, Sway, and Nvidia

Now the painful part of setting this up to begin, the part that took me a solid 5 hours to debug without resolution so far, pushing me as far as going to Reddit in search for anyone with more experience. XWayland.

XWayland is something I REALLY wanted to use, though, there is this one cryptic issue that I just cannot explain to myself. XWayland refuses to properly initialize EGL for rendering, making it fall back to Software Rendering with the following error message:

 › Xwayland -verbose 50 :0
(II) Raising the file descriptors limit to 4096
(II) glamor: Using GBM backend
eglInitialize() failed
EGL setup failed, disabling glamor
Failed to initialize glamor, falling back to sw
…
// the rest is just normal XWayland logs with sw rendering

So after a lot of suffering, I have given up on XWayland for now. I have kept it enabled but I do my best to avoid it. This way I can build a list of applications that I need which depend on XWayland due to their lack of native Wayland support. For some of these I was already able to implement workarounds, like running Discord with the Wayland OzonePlatform flags. However, this isn't perfect, as Minecraft for instance only runs under Wayland with lots of effort, and apparently not under Nvidia+Wayland judging from my experience here.

Updates on Xwayland - 2022-10-18:

I have done a lot more debugging on XWayland by now, and have come to the conclusion that XWayland either can't find, or is failing to load the NV_GLX module that the Nvidia drivers provide. Whilst this is quite annoying, I might try another more bleeding-edge distro in the future where there is a bigger community which might be able to give me more support in this. Maybe in a future Nvidia Driver update this will be resolved? Who knows, we'll have to see further developments on that in the future

Overall, it's much better of an experience once everything is setup than a couple of months ago, but that does not mean it's perfect; Far from it! Major features are still not working as intended, causing quite big issues in day-to-day usage. However, I can certainly recommend it to anyone who is up for the challenge and willing to tinker!


Thanks for reading! I wish you a good rest of the day, evening, night, or whatever other time you're reading this!

#linux #nvidia #wayland