Wayland: massive flickering on xwayland / Java

Hello,
I’m experiencing massive flickering on xwayland while running Java applications, like Mediathekview or Hibiscus (I don’t use other java programs). There isn’t any problem running those programs natively in pure Xorg without any wayland involved.

Kernel: .5.15.32
nvidia: nvidiaG06-515.43.04
KDE: Plasma 5.24.5 / kwin5-5.24.5
Java: different versions, like Java 17 or 1.8 (both openjdk).
Xwayland: 22.1.1

0a:00.0 VGA compatible controller: NVIDIA Corporation GP108 [GeForce GT 1030] (rev a1) (prog-if 00 [VGA controller])

0a:00.0 0300: 10de:1d01 (rev a1) (prog-if 00 [VGA controller])
        Subsystem: 1043:85f4
        Flags: bus master, fast devsel, latency 0, IRQ 69
        Memory at f6000000 (32-bit, non-prefetchable) [size=16M]
        Memory at e0000000 (64-bit, prefetchable) [size=256M]
        Memory at f0000000 (64-bit, prefetchable) [size=32M]
        I/O ports at d000 [size=128]
        [virtual] Expansion ROM at 000c0000 [disabled] [size=128K]
        Capabilities: [60] Power Management version 3
        Capabilities: [68] MSI: Enable+ Count=1/1 Maskable- 64bit+
        Capabilities: [78] Express Legacy Endpoint, MSI 00
        Capabilities: [100] Virtual Channel
        Capabilities: [128] Power Budgeting <?>
        Capabilities: [420] Advanced Error Reporting
        Capabilities: [600] Vendor Specific Information: ID=0001 Rev=1 Len=024 <?>
        Capabilities: [900] #19
        Kernel driver in use: nvidia
        Kernel modules: nvidia_drm, nvidia

nvidia-drm.modeset=1 is set.

This problem can be seen with previous versions, too. I’ve never seen it without massive flickering.

Is this a known problem? How can it be solved? Do you need any more information? Please feel free to ask!

Thanks!

Is this issue exclusive to Java + xwayland for you or does it also happen with other non-Java applications running through xwayland? I’ve seen “juddering” in Discord running through xwayland as if the frames are being displayed out of order, and this issue is most likely the culprit.

NVIDIA says “Xwayland does not provide a suitable mechanism for our driver to synchronize application rendering with presentation, which can cause visual corruption in some circumstances” on this topic they posted about NVIDIA + Wayland.

No, until now, I couldn’t see this massive flickering (it’s like a very fast blinking of parts of the (or even complete) window of the app) with other X-programs through Xwayland.

The only not Java X-program I used with Xwayland so far was smplayer / mpv. I could see effects there and I think those could be the effects you described above.

But those two effects I’m seeing here seem to be completely different to me.

Here you can see an example of the flickering in Java apps (please play it until end because there are different errors). You have to download it (“Herunterladen”) to play it!
At t this example, it looks like the problem seems to happen only if there are mouse movements - but that’s not true - the flickering may bee seen even without mouse movements - but that’s relatively seldom.

I am noticing the same problem using JabRef, both with openjdk and jdk. The black flickering is so extreme that it covers almost the entire window at a high frequency, making the software completely unusable. Only Java programs running through XWayland are affected, running the same software through X11 works fine.

Running the same software using another GPU vendor works without issues. Not sure if this is an Nvidia or KDE bug, relevant issue on the KDE bugtracker: 454354 – nvidia: Java programs running in Plasma Wayland / Xwayland show massive flickering

Name Version
OS Arch Linux x86_64
Kernel 5.18.9-zen1-1-zen
DE Plasma 5.25.2 (kwin)
GPU NVIDIA GeForce RTX 2060 Rev. A
$ lspci -vks 01:00.0
01:00.0 VGA compatible controller: NVIDIA Corporation TU106 [GeForce RTX 2060 Rev. A] (rev a1) (prog-if 00 [VGA controller])
        Subsystem: Gigabyte Technology Co., Ltd Device 37d9
        Flags: bus master, fast devsel, latency 0, IRQ 130, IOMMU group 1
        Memory at f6000000 (32-bit, non-prefetchable) [size=16M]
        Memory at e0000000 (64-bit, prefetchable) [size=256M]
        Memory at f0000000 (64-bit, prefetchable) [size=32M]
        I/O ports at e000 [size=128]
        Expansion ROM at 000c0000 [virtual] [disabled] [size=128K]
        Capabilities: [60] Power Management version 3
        Capabilities: [68] MSI: Enable+ Count=1/1 Maskable- 64bit+
        Capabilities: [78] Express Legacy Endpoint, MSI 00
        Capabilities: [100] Virtual Channel
        Capabilities: [250] Latency Tolerance Reporting
        Capabilities: [258] L1 PM Substates
        Capabilities: [128] Power Budgeting <?>
        Capabilities: [420] Advanced Error Reporting
        Capabilities: [600] Vendor Specific Information: ID=0001 Rev=1 Len=024 <?>
        Capabilities: [900] Secondary PCI Express
        Capabilities: [bb0] Physical Resizable BAR
        Kernel driver in use: nvidia
        Kernel modules: nouveau, nvidia_drm, nvidia
$ cat /proc/cmdline
initrd=\intel-ucode.img initrd=\initramfs-linux-zen.img [...] intel_iommu=on iommu=pt nvidia-drm.modeset=1 rw nowatchdog

+1

I had the same problem mostly with impact on intelliJ, for moments its usable but from time to time the flickering goes crazy i had to change size or minimize and maximize to as a temporarily workaround … but i think i’m gonna go back to X11 if this cant be solved or if there is not a doable workaround for this .
Note: on xeyes its easy to watch this flickering and even some kind of buffer corruption ( ie. xeyes takes the background of intelliJ, and does not clear mouse pointer and flickers a lot.)