NVIDIA (495) on sway tutorial + questions (Arch-based distros)

I’m loving Sway on Nvidia so far! Multiple monitors work great, there’s no screen tearing when scrolling on Firefox, resizing apps is fast, and games run wonderfully.

However, I’m running into major issues with every Electron app I run, and some XWayland ones such as xeyes. There are countless artifacts, including z-fighting, flickering, and weird redrawing issues.
I did notice all Element apps seem to run in XWayland (despite me setting the Ozone flags in ~/.config/electron-flags.conf), but forcing Wayland through directly passing the arguments --enable-features=UseOzonePlatform --ozone-platform=wayland to the program (Element Desktop as an example) does not seem to fix the rendering issues.

Here’s an example of the redrawing issues that occur with xeyes:

Has anyone else encountered these issues? Is there a current workaround? It’s pretty much the only thing keeping me from switching to it fully.

Maybe be helpful, Arch installing of Sway together to Gnome:

I followed the above video but wlroots-eglstream-git didn’t seem to do the job for me (RTX 2080 Super): sway was stalling on startup.
Using wlroots-git i/o wlroots-eglstream-git (which by the way doesn’t seem to be maintained anymore) did the trick. I’ve had flickers in the beginning but they seem to have disappeared after a reboot.
Thanks a lot to all this thread’s participant for putting all this together :)

This is becoming my favourite environment. The only issues that prevent me using this all the time (instead of i3) are:

If anyone got to the bottom of the electron issue please share! Looks like screen sharing is in the works.

Anyone test out the newest drivers to see if there is improvement, maybe there will be more supports with the kernel module being open sourced

What I’ve observed with Sway 1.7 on the 515.43.04 drivers:

  • wlroots-eglstreams has been discontinued after the maintainer’s GPU broke, so GBM is the only way forward now
  • Hardware cursor is still broken
  • Generally, flickering still happens sometimes randomly (the flicker seems worse under XWayland)
  • foot terminal still sees a lot of flickering every time the terminal needs to refresh
  • Lots of flickering in VS Code as well (using Wayland flags, don’t have the same problem with Signal Desktop which also uses Electron)
  • Screensharing is broken as others have discussed above
  • The newest release of wf-recorder (from 2020) is broken but the git release works fine
  • This official Nvidia post has a lot of info as well: Wayland information for r515 beta release

Honestly, not much has changed since 495 and most of the same issues are still there. The open source release is still alpha on GeForce cards and I had trouble booting my system even with the NVreg_OpenRmEnableUnsupportedGpus=1 option with the nvidia-open package. Hopefully it’ll allow contributors to help with development and make Nouveau better as well.

515.43.04 driver released with VK_EXT_external_memory_dma_buf and VK_EXT_image_drm_format_modifier and I can start sway with the Vulkan renderer.
I noticed there is no more flickering but when I open “dmenu”, sway crashes with an out of memory error and OpenGL/Xwayland applications are very slow.

The flickering seems to be gone when using the wlr vulkan renderer. I still get some pretty bad flickering in xwayland if fullscreen though.

Tried wlr vulkan renderer. xeyes and all chromium apps are still borked (flickering and part of frame not updating). Especially annoying in electron apps such VSCode and Discord

I’m assuming it has to do with a compatibility issue with wlroots because wayland on gnome even with the 5.10 drivers works pretty well without flickering on fedora

Most of the issues seem to be linked to explicit sync, at least the xwayland flickers you see on some applications is definitely by that and there are currently fixes on the way - xwayland glamor renders incorrectly on nvidia (#1317) · Issues · xorg / xserver · GitLab
As for the desktop flicker, it seems like sway needs to also adopt explicit sync to it’s compositor(vulkan strictly uses explicit sync hence why you don’t see weird shenanigans), not sure if that’ll happen soon, but I do know kde has explicit sync for it’s compositor refactor to come in 5.26 which has beta in September.
So at the moment it isn’t an nvidia driver issue, it’s just that nvidia driver has support only for the newer explicit sync and doesn’t use implicit sync which causes the entire stack to do flickers, black screens, going forward/backwards. I’d say either file an issue for sway or keep an eye in case it gets explicit sync supported on OpenGL(honestly can’t wait for kde to drop theirs, then only xwayland would be left)

2 Likes

I asked the KDE developer and he told me that there is no explicit sync feature in KDE Plasma 5.26. Even if this feature was added, he did not seem to believe that it could solve the problems on the NVIDIA side. Honestly, whenever I’m hopeful, I’m disappointed.

You spoke to Vlad Zahorodnii ? The main wayland dev at KDE ? Refactor surface state handling in preparation for explicit sync (#91) · Issues · Plasma / KWin · GitLab also this is literally their preparation for explicit sync…

EDIT: With milestone 5.26

I spoke with Xaver Hugl. He mentioned that there was a merge request for explict sync, but he said he didn’t think the NVidia driver had support for explict sync. Even though I remind him of what the NVidia developer said, he seems hopeless. Thinks it won’t help in practice.

For anyone still looking into this, it turns out there is a simple patch to wlroots that completely resolves the flickering. The patched wlroots is available in the AUR as wlroots-nvidia.

@taylor85345, can this patch be used on wlroots-git too? Currently, there is no wlroots-git-nvidia in the AUR.

After comparing the patch with the latest wlroots commit (11192e69308ff48c0f3ec40fb572c4e8e4ad13d8), I have found that all the changes to examples/dmabuf-capture.c where already merged into master. The only change that is not yet the the branch is replacement of glFlush() with glFinish() in render/gles2/renderer.c. Maybe I miss that change, however, using sway-git and wlroots-git on Nvidia Quadro 1000 in Lenovo P15 Gen 1 flickers quite a lot, esp in XWayland apps, but also in Wayland apps.

Apparently, screen sharing can be fixed by hard coding the pixel format in wlroots to one that’s compatible with WebRTC. I will try it when I get some time, but it seems plausible.

I just updated to nvidia 525.60.11 and sway 1.7. Surprisingly enough, it seems external monitor on optimus laptop is now working… I doubt it had something to do with sway as I checked last week and was still not working, so it has to be something pushed to the new 525.60 driver, although I couldn’t find anything mentioned in the release notes.

There’s a lot of screen tearing happening on the external monitor, and I can’t see my mouse pointer either, but nevertheless this is huge step forward.

I documented my entire process as a walk through guide to getting a working Sway instance with NVIDIA hardware. Single RTX 3080 Ti. Not having any major issues at the moment; spent all day trying to get it stable. Only issues I primarily see are with xeyes and chromium being a little buggy still. Haven’t had time to daily-drive it yet.

Please understand I didn’t make this Guide for this Forum, I mainly did it for myself in case I end up messing up the system or in case somebody else falls down the same rabbit hole I did. Just figured maybe y’all would be interested?

https://github.com/tyqualters/sway-nvidia-guide/blob/main/README.md