Bug 397850 - kwin_x11 - triple buffer detection of compositing apparently broken with every driver; causing stuttering, lag or tearing
Summary: kwin_x11 - triple buffer detection of compositing apparently broken with ever...
Status: RESOLVED DUPLICATE of bug 344433
Alias: None
Product: kwin
Classification: Plasma
Component: compositing (show other bugs)
Version: 5.13.4
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-24 20:29 UTC by tempel.julian
Modified: 2019-12-01 19:30 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tempel.julian 2018-08-24 20:29:47 UTC
The problem in a nutshell:
free drivers (both AMD and Intel): stutter when moving windows and in applications
Proprietary Nvidia driver: tearing

-> So the situation with any graphics driver is quite ugly.
I tested this with several GPUs, distributions and driver versions: The described problem is shared among all of them, and exists probably since the beginning of KWin 5.

I'm having a strong suspicion that the source of this evil lays in KWin's triple buffer detection.
What makes me think so? I tried several situations with the KWIN_TRIPLE_BUFFER environment variable and the results are very interesting.

First observation:
When KWIN_TRIPLE_BUFFER is set (both 1 and 0), the nasty initial "calibration stuttering" when compositing turns on disappears.
This easily noticeable when moving windows right after enabling compositing. KWin is the only compositor I know which shows such a weird behavior. It's especially nasty when you turned compositing off for a fullscreen application like a game, and when closing it and returning to desktop, everything is stuttery for some time.

Observation regarding Nvidia driver:
By default, there is tearing after the initial "calibration stuttering".
However, with workarounds, perfect KWin compositing is possible with Nvidia. To do so, set both
KWIN_TRIPLE_BUFFER=0
and in Nvidia xorg config, also
Option "TripleBuffer" "0"
The latter option makes triple buffering unavailable for any application and for some reason, it's required to make KWin compositing on Nvidia work correctly. It's completely free of stutter and shows low input latency at the same time.

Observation regarding free drivers (applies to both Intel and AMD to the same extent):
KWIN_TRIPLE_BUFFER=0 reduces stutter, but doesn't fully eliminate it in applications like Firefox. Weirdly, it also shows a much higher input latency than TB autodetect (environment variable unset) or than setting KWIN_TRIPLE_BUFFER=1.
However, KWIN_TRIPLE_BUFFER=1 shows stuttering when moving any window, e.g. Dolphin, and strong stuttering when e.g. scrolling in Firefox.
Unfortunately, there is no such an option in Mesa like Option "TripleBuffer", which is available in the Nvidia driver.
Instead, there is vblank_mode=x. But no value of it helps to reduce the stuttering or input latency of KWin. It's always stuttery and laggy.

I think it's very unsatisfying that kwin_x11 compositing does only work correctly on Nvidia with some workarounds and with free drivers not at all.
Shouldn't it be possible to bisect the issue due to the open nature of Mesa? It's quite the irony that, unlike any other compositor, KWin actually seems to hate free drivers more than the closed one of Nvidia.

The GUI options offered by KWin KCM in Plasma system settings don't have an effect on any of the points I described above.

It's still the same bug as 383023, but that original bugreport was too focused on Intel graphics. So I'm going to close it and I'm hoping for some response here.

I'm aware that kwin_x11 is left in "maintenance bugfix only" state, but the described problems can obviously considered as bugs and it would be a shame if kwin_x11 was left in that state.
Comment 1 tempel.julian 2018-09-06 11:55:12 UTC
Well, if no one wants to fix it, perhaps set at least KWIN_TRIPLE_BUFFER=0 by default?
This makes things only better, not worse, with both Mesa and Nvidia.
Comment 2 Steffen Coenen 2019-01-06 20:38:29 UTC
This is probably a duplicate of https://bugs.kde.org/show_bug.cgi?id=344433
Comment 3 tempel.julian 2019-04-02 14:36:48 UTC
Closing as unmaintained, as apparently no one seems to care (which is shockingly ignorant. btw.).
Luckily, Compton is maintained again these days and I recommend everybody to use it instead of KWin.
Comment 4 Vlad Zahorodnii 2019-04-21 21:14:47 UTC
(In reply to tempel.julian from comment #0)
> First observation:
> When KWIN_TRIPLE_BUFFER is set (both 1 and 0), the nasty initial
> "calibration stuttering" when compositing turns on disappears.
That stuttering occurs because KWin detects whether triple buffering is supported.

> This easily noticeable when moving windows right after enabling compositing.
> KWin is the only compositor I know which shows such a weird behavior.
If you are aware of better way to detect triple buffering, please submit a new patch. :-)

(In reply to tempel.julian from comment #1)
> Well, if no one wants to fix it, perhaps set at least KWIN_TRIPLE_BUFFER=0
> by default?
No, this is a terrible idea.

(In reply to Steffen Coenen from comment #2)
> This is probably a duplicate of https://bugs.kde.org/show_bug.cgi?id=344433

Yep, probably.
Comment 5 Nate Graham 2019-12-01 19:30:33 UTC

*** This bug has been marked as a duplicate of bug 344433 ***