Bug 343184

Summary: KWin misdetects trimple-buffering (at least on login)
Product: [Plasma] kwin Reporter: Alexander <vo.zaeb>
Component: scene-openglAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED WORKSFORME    
Severity: normal CC: jan, kde.org, sayginb, sgbarber, ua_bugz_kde, vo.zaeb, witheld
Priority: NOR Flags: thomas.luebking: NVIDIA+
Version: 5.1.2   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=345657
https://bugs.kde.org/show_bug.cgi?id=322060
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Xorg log
KWin supportInformation

Description Alexander 2015-01-23 08:56:25 UTC
After every boot of my PC and log in to KDE I observe a very slow performance of Kwin. This is noticeable especially when moving windows over the screen.

The bug disappears after re-enabling Kwin effect (with Alt+Shift+F12).

Reproducible: Always

Steps to Reproduce:
1. Boot the PC.
2. Log in to KDE.
3. Open a few windows (some could be in the full screen mode and some not).
4. Try to drag windows and observe they are almost 1/3 screen behind the mouse cursor.
5. Press Alt+Shift+F12 to disable Kwin effects
6. Press Alt+Shift+F12 again to enable Kwin effects
7. Observe the lag has gone



I am using nvidia blob.

In KDE's settings I have OpenGL 3.1 (reproducible with other OpenGL versions as well) and raster graphic system.

Please let me know if I can be of more help.
Comment 1 Martin Flöser 2015-01-23 10:37:41 UTC
please specify which version you are using. You selected a 5.x version but raster graphics system option does not exist in 5.x any more.

Best provide the output of:
qdbus org.kde.KWin /KWin supportInformation

when the problem is present.
Comment 2 Thomas Lübking 2015-01-23 12:11:45 UTC
description sounds like triple buffer misdetection.
as there's more than one report, we've to assume that sth. one some machines and/or during startup seems to break the heuristics.

@alexander, do you have triple buffering enabled?
grep -i triple /var/log/Xorg.0.log
Comment 3 Alexander 2015-01-23 12:17:43 UTC
Created attachment 90604 [details]
Xorg log

@Martin, oops, sorry, I do use kde 4.14, will be able to provide the requested output later today.
@Thomas, seems no, the provided command returned no output. Xorg log attached.
Comment 4 Thomas Lübking 2015-01-23 15:24:31 UTC
To enable triple buffering:

--- /etc/X11/xorg.conf.d/20-nvidia.conf ---

Section "Device"
    Identifier "Default nvidia Device"
    Driver      "nvidia"
        Option  "TripleBuffer"                  "True"
EndSection

----

Have you exported __GL_YIELD?
env | grep __GL_YIELD

In case not, this might be a really troublesome condition, since
a) triple buffering is not available
b) but kwin thinks it is, so it will perform a synced swap
-> c) swapping blocks with cpu load (busy wait)
--> d) our timing calculation will be messed up (we're gonna loose a frame to the blocking swap)
Comment 5 Alexander 2015-01-24 08:23:42 UTC
Created attachment 90624 [details]
KWin supportInformation
Comment 6 Alexander 2015-01-24 08:32:51 UTC
@Thomas,

Added triple buffering config, the entire configuration: http://pastie.org/pastes/9856407/text?key=unggt7alw0oik5od9rmlfw

Also forgot to mention, I have 2 monitors, one is 2560x1440, and another 1280x1024.

>> Have you exported __GL_YIELD?
Yes, $ env | grep __GL_YIELD
=> __GL_YIELD=USLEEP

Testing if addid triple buffer config helps now.
Comment 7 Alexander 2015-01-24 09:18:39 UTC
@Thomas, adding triple buffering seems solves the problem. Will do more testing today.
Comment 8 Thomas Lübking 2015-01-24 15:53:49 UTC
Thanks.

If you should not want to use TB for any reason, you can hint that to kwin

    export KWIN_TRIPLE_BUFFER=0
Comment 9 Alexander 2015-01-28 21:15:09 UTC
Just wanted to confirm that this is also valid for Kwin 5, but the performance in Kwin 5 is much-much better! Moving windows is almost the same fast as if compositing is disabled.
Comment 10 Saygın Bakşi 2015-02-11 03:19:29 UTC
(In reply to Thomas Lübking from comment #4)
> To enable triple buffering:
> 
> --- /etc/X11/xorg.conf.d/20-nvidia.conf ---
> 
> Section "Device"
>     Identifier "Default nvidia Device"
>     Driver      "nvidia"
>         Option  "TripleBuffer"                  "True"
> EndSection
> 
> ----
> 
> Have you exported __GL_YIELD?
> env | grep __GL_YIELD
> 
> In case not, this might be a really troublesome condition, since
> a) triple buffering is not available
> b) but kwin thinks it is, so it will perform a synced swap
> -> c) swapping blocks with cpu load (busy wait)
> --> d) our timing calculation will be messed up (we're gonna loose a frame
> to the blocking swap)

This works for me. (Fedora 21, kwin 5.2.0)
Comment 11 Thomas Lübking 2015-11-11 21:36:09 UTC
Git commit 0788890233850ca598af55abe52641d7b4254f14 by Thomas Lübking.
Committed on 11/11/2015 at 21:15.
Pushed by luebking into branch 'master'.

re-detect triple-buffering after compositor resume

and also hint the proper blocking condition (if turning
off swap control)

The detection vars are global, but the swap control requirement
is not preserved, so the detection must re-occur.

Alternatively (and better) the swap control should be saved
and re-applied, but there's trouble on initial detection
REVIEW: 125659

M  +8    -3    eglonxbackend.cpp
M  +7    -3    glxbackend.cpp

http://commits.kde.org/kwin/0788890233850ca598af55abe52641d7b4254f14
Comment 12 Thomas Lübking 2016-04-26 21:31:48 UTC
*** Bug 362312 has been marked as a duplicate of this bug. ***
Comment 13 Shannon 2016-08-15 17:40:54 UTC
I think this remains a problem or there was a regression.

Gentoo
KDE 5.6.5
nVidia proprietary drivers 367.35
nVidia-xconfig xorg.conf

I have to twiddle the Compositor settings for the tearing to stop.
Comment 14 kde.org 2021-11-06 23:12:42 UTC
This issue report is quite old. Can you please confirm, that it still persists with Plasma 5.23?
Comment 15 Bug Janitor Service 2021-11-21 04:38:57 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 16 Bug Janitor Service 2021-12-06 04:38:20 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!