[kwin] [Bug 524033] New: Kwin Wayland is too jittery compared to Xorg

thesword <[email protected]>
Newsgroups gmane.comp.kde.devel.bugs
Message-ID <[email protected]/>
https://bugs.kde.org/show_bug.cgi?id=524033

            Bug ID: 524033
           Summary: Kwin Wayland is too jittery compared to Xorg
    Classification: Plasma
           Product: kwin
      Version First 6.7.4
       Reported In:
          Platform: Arch Linux
                OS: Linux
            Status: REPORTED
          Keywords: wayland-only
          Severity: major
          Priority: NOR
         Component: performance
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

DESCRIPTION
KDE desktop is moving to Wayland only and will move away from X11 future
versions, but Kwin as a standalone compositor has a major issue that Xorg
don't: Performance. Despite having higher average FPS in 3D applications/games
with Kwin Wayland, I have high amount of stutter/frame skip, including mouse
cursor, when interacting with Kwin.

I listed below some situations where Kwin struggles:

STEPS TO REPRODUCE
* When using native Wayland applications which uses CPU rendering such as Kate,
Dolphin, Konsole, Kwin is very jittery and the workaround is to launch
application with Xwayland with QT_QPA_PLATFORM=xcb. I previously opened a bug
about this issue (https://bugs.kde.org/show_bug.cgi?id=513295), but it was
closed without being solved and tested.
* Kwin also stutters when cursor shape changes
(https://bugs.kde.org/show_bug.cgi?id=509669).
* Opening display settings and clicking on "Identify screens" freezes Kwin for
~500 ms.
* Opening tab box with ALT+TAB also freezes Kwin for ~500 ms the first time
(https://bugs.kde.org/show_bug.cgi?id=479250).
* Moving a window the edges of a screen freezes Kwin for ~300 ms the first
time.
* Here is an example of user complaining about cursor lags using JetBrains
Toolbox:
https://youtrack.jetbrains.com/projects/JBR/issues/JBR-10036/Wayland-system-cursor-stutter-freezing

I applied to following patch on the top of Kwin to see when it hangs more than
100 ms:

```
--- a/src/backends/drm/drm_gpu.h
+++ b/src/backends/drm/drm_gpu.h
@@ -74,7 +74,7 @@ public:
     /**
      * This should always be longer than any real pageflip can take, even with
PSR and modesets
      */
-    static constexpr std::chrono::milliseconds s_pageflipTimeout =
std::chrono::seconds(1);
+    static constexpr std::chrono::milliseconds s_pageflipTimeout =
std::chrono::milliseconds(100);

     DrmGpu(DrmBackend *backend, int fd, std::unique_ptr<DrmDevice> &&device);
     ~DrmGpu();

```
And after I applied this patch, I saw the message "The main thread was hanging
temporarily!" many times even on normal desktop usage with an AMD Ryzen 7 3700X
CPU and a Nvidia GeForce RTX 2080 SUPER which are high end hardware from 2019.
With Xorg, even on a old laptop from 2009 with an Intel Core 2 Duo and GeForce
9600M GT, the cursor doesn't drop a single frame.

OBSERVED RESULT
Kwin is jittery and freezes.

EXPECTED RESULT
Kwin render smoothly.
The cursor shouldn't drop any frame.

SOFTWARE/OS VERSIONS
KDE Plasma Version: 6.7.4
KDE Frameworks Version: 6.28.0
Qt Version: 6.11.1
Linux 7.1.6-arch1-1

ADDITIONAL INFORMATION
When my Nvidia GPU hangs due to a context switch timeout, I can still move the
cursor but when the cursor shape changes by hovering a link for example, the
cursor doesn't move anymore and the keyboard become unresponsive (Capslock LED
is stuck) and I have "The main thread was hanging temporarily!" and not
"Pageflip timed out! This is a bug in the nvidia_drm kernel driver", which
means this is a Kwin issue and not an issue with the display driver which is
still responding to atomic commits. On Xorg and GNOME Wayland, I can still move
the cursor in the same situation.

-- 
You are receiving this mail because:
You are watching all bug changes.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.