Bug 351844 - KWIN_EXPLICIT_SYNC causes freezes (and GPU reset warnings) on double buffered swapcontrol
Summary: KWIN_EXPLICIT_SYNC causes freezes (and GPU reset warnings) on double buffered...
Status: RESOLVED UNMAINTAINED
Alias: None
Product: kwin
Classification: Plasma
Component: compositing (show other bugs)
Version: 5.4.3
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-27 10:31 UTC by Nikola Schnelle
Modified: 2023-09-06 10:38 UTC (History)
1 user (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 Nikola Schnelle 2015-08-27 10:31:28 UTC
Since Plasma 5 is released I get random kwin freezes and restarts. Now I know the reason: export __GL_YIELD="USLEEP" workaround. Works great for kwin4 but crashes kwin5.

1) With opensource drivers no kwin freezes/crashes
2) With nvidia driver no crashes
3) export __GL_YIELD="USLEEP" + nvidia driver = kwin restarts "due to graphics resets"

Is there any other workaround to get tear free desktop on nvidia which doesn't crash kwin5?
I tried  export KWIN_EXPLICIT_SYNC=0 but tearing is present.


Reproducible: Always
Comment 1 Nikola Schnelle 2015-08-27 10:31:38 UTC
nikola@Plasma5:~$ qdbus org.kde.kwin /KWin supportInformation
Service 'org.kde.kwin' does not exist.
nikola@Plasma5:~$ qdbus org.kde.KWin /KWin supportInformation
KWin Support Information:
The following information should be used when requesting support on e.g. http://forum.kde.org.
It provides information about the currently running instance, which options are used,
what OpenGL driver and which effects are running.
Please post the information provided underneath this introductory text to a paste bin service
like http://paste.kde.org instead of pasting into support threads.

==========================

Version
=======
KWin version: 5.3.95
Qt Version: 5.4.2
Qt compile version: 5.4.2
XCB compile version: 1.11

Operation Mode: X11 only

Build Options
=============
KWIN_BUILD_DECORATIONS: yes
KWIN_BUILD_TABBOX: yes
KWIN_BUILD_ACTIVITIES: yes
HAVE_WAYLAND: yes
HAVE_WAYLAND_EGL: yes
HAVE_WAYLAND_CURSOR: yes
HAVE_XKB: yes
HAVE_INPUT: yes
HAVE_DRM: yes
HAVE_GBM: yes
HAVE_X11_XCB: yes

X11
===
Vendor: The X.Org Foundation
Vendor Release: 11702000
Protocol Version/Revision: 11/0
SHAPE: yes; Version: 0x11                                                                                           
RANDR: yes; Version: 0x14                                                                                           
DAMAGE: yes; Version: 0x11                                                                                          
Composite: yes; Version: 0x4                                                                                        
RENDER: yes; Version: 0xb                                                                                           
XFIXES: yes; Version: 0x50                                                                                          
SYNC: yes; Version: 0x31                                                                                            
GLX: yes; Version: 0x0                                                                                              
                                                                                                                    
Decoration                                                                                                          
==========                                                                                                          
Plugin: org.kde.breeze                                                                                              
Theme:                                                                                                              
Blur: 0                                                                                                             
onAllDesktopsAvailable: false                                                                                       
alphaChannelSupported: true                                                                                         
closeOnDoubleClickOnMenu: false                                                                                     
decorationButtonsLeft: 0, 2                                                                                         
decorationButtonsRight: 6, 3, 4, 5                                                                                  
borderSize: 3                                                                                                       
gridUnit: 10                                                                                                        
font: Oxygen-Sans,10,-1,5,50,0,0,0,0,0                                                                              
smallSpacing: 2                                                                                                     
largeSpacing: 10                                                                                                    
                                                                                                                    
Options                                                                                                             
=======                                                                                                             
focusPolicy: 0                                                                                                      
nextFocusPrefersMouse: false                                                                                        
clickRaise: true                                                                                                    
autoRaise: false                                                                                                    
autoRaiseInterval: 0
delayFocusInterval: 0
shadeHover: false
shadeHoverInterval: 250
separateScreenFocus: false
placement: 4
focusPolicyIsReasonable: true
borderSnapZone: 10
windowSnapZone: 10
centerSnapZone: 0
snapOnlyWhenOverlapping: false
rollOverDesktops: true
focusStealingPreventionLevel: 1
legacyFullscreenSupport: false
operationTitlebarDblClick: 5000
operationMaxButtonLeftClick: 5000
operationMaxButtonMiddleClick: 5015
operationMaxButtonRightClick: 5014
commandActiveTitlebar1: 0
commandActiveTitlebar2: 30
commandActiveTitlebar3: 2
commandInactiveTitlebar1: 4
commandInactiveTitlebar2: 30
commandInactiveTitlebar3: 2
commandWindow1: 7
commandWindow2: 8
commandWindow3: 8
commandWindowWheel: 31
commandAll1: 10
commandAll2: 3
commandAll3: 14
keyCmdAllModKey: 16777251
showGeometryTip: false
condensedTitle: false
electricBorderMaximize: true
electricBorderTiling: true
electricBorderCornerRatio: 0.25
borderlessMaximizedWindows: false
killPingTimeout: 5000
hideUtilityWindowsForInactive: true
inactiveTabsSkipTaskbar: false
autogroupSimilarWindows: false
autogroupInForeground: true
compositingMode: 1
useCompositing: true
compositingInitialized: true
hiddenPreviews: 1
unredirectFullscreen: false
glSmoothScale: 2
colorCorrected: false
xrenderSmoothScale: false
maxFpsInterval: 16666666
refreshRate: 0
vBlankTime: 6000000
glStrictBinding: false
glStrictBindingFollowsDriver: true
glCoreProfile: false
glPreferBufferSwap: 99
glPlatformInterface: 1

Screen Edges
============
desktopSwitching: false
desktopSwitchingMovingClients: false
cursorPushBackDistance: 1x1
timeThreshold: 150
reActivateThreshold: 350
actionTopLeft: 0
actionTop: 0
actionTopRight: 0
actionRight: 0
actionBottomRight: 0
actionBottom: 0
actionBottomLeft: 0
actionLeft: 0

Screens
=======
Multi-Head: no
Active screen follows mouse:  no
Number of Screens: 1

Screen 0:
---------
Name: VGA-0
Geometry: 0,0,1680x1050
Refresh Rate: 59.9543


Compositing
===========
Compositing is active
Compositing Type: OpenGL
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce GT 730/PCIe/SSE2
OpenGL version string: 4.5.0 NVIDIA 355.06
OpenGL platform interface: GLX
OpenGL shading language version string: 4.50 NVIDIA
Driver: NVIDIA
Driver version: 355.6
GPU class: Unknown
OpenGL version: 4.5
GLSL version: 4.50
X server version: 1.17.2
Linux kernel version: 4.1
Direct rendering: Requires strict binding: no
GLSL shaders:  yes
Texture NPOT support:  yes
Virtual Machine:  no
OpenGL 2 Shaders are used
Painting blocks for vertical retrace:  no

Loaded Effects:
---------------
zoom
slidingpopups
kwin4_effect_login
slide
screenshot
minimizeanimation
kwin4_effect_translucency
desktopgrid
kwin4_effect_windowaperture
kwin4_effect_maximize
presentwindows
kwin4_effect_dialogparent
highlightwindow
blur
contrast
logout
dashboard
startupfeedback
screenedge
kscreen

Currently Active Effects:
-------------------------
blur
contrast

Effect Settings:
----------------
zoom:
zoomFactor: 1.2
mousePointer: 0
mouseTracking: 0
enableFocusTracking: false
followFocus: true
focusDelay: 350
moveFactor: 20
targetZoom: 1

slidingpopups:
fadeInTime: 150
fadeOutTime: 250

kwin4_effect_login:

slide:

screenshot:

minimizeanimation:

kwin4_effect_translucency:

desktopgrid:
zoomDuration: 300
border: 10
desktopNameAlignment: 0
layoutMode: 0
customLayoutRows: 2
usePresentWindows: true

kwin4_effect_windowaperture:

kwin4_effect_maximize:

presentwindows:
layoutMode: 0
showCaptions: true
showIcons: true
doNotCloseWindows: false
ignoreMinimized: false
accuracy: 20
fillGaps: true
fadeDuration: 150
showPanel: false
leftButtonWindow: 1
rightButtonWindow: 2
middleButtonWindow: 0
leftButtonDesktop: 2
middleButtonDesktop: 0
rightButtonDesktop: 0

kwin4_effect_dialogparent:

highlightwindow:

blur:
blurRadius: 12
cacheTexture: true

contrast:

logout:
useBlur: true

dashboard:
brightness: 0.5
saturation: 0.5
blur: false

startupfeedback:
type: 1

screenedge:

kscreen:
Comment 2 Thomas Lübking 2015-08-27 11:08:25 UTC
iow, swapcontrol causes the graphics reset.

This means "vertical synchronisation 'crashes'* kwin" ie. vsync is impossible.
I however have some doubts in this regard.

> Painting blocks for vertical retrace:  no
This means either triple buffering is (considered) enabled or v'sync swapcontrol disabled (no triple buffering and OpenGL doesn't yield)

> I tried  export KWIN_EXPLICIT_SYNC=0 but tearing is present.
this has nothing to do with vblank alignment, but command control between OpenGL and X11.
It's however been reported to cause trouble on legacy nvidia drivers, could cause other trouble as well, ie. try

   export KWIN_EXPLICIT_SYNC=0
   export __GL_YIELD=USLEEP
   kwin_x11 --replace &

Another solution is of course to enable triple buffering in the driver since that gets you non-blocking swap control:

/etc/X11/xorg.conf.d/20-nvidia.conf
-------------
Section "Device"
    Identifier "Default nvidia Device"
    Driver      "nvidia"
    Option      "NoLogo"                                "True"
    Option  "CoolBits"                              "1"
    Option  "TripleBuffer"                  "True"
    Option  "ExactModeTimingsDVI"   "True"
    # other settings
EndSection

----------

If the problem is however in the explicit_sync extension, this will cause similar issues.


* I assume crash does not mean "segfault" but the GPU hangs?
Comment 3 Nikola Schnelle 2015-08-27 13:05:10 UTC
> > Painting blocks for vertical retrace:  no
> This means either triple buffering is (considered) enabled or v'sync
> swapcontrol disabled (no triple buffering and OpenGL doesn't yield)

I don't remember if I did qdbus org.kde.kwin /KWin supportInformation with  export __GL_YIELD=USLEEP enabled.


>    export KWIN_EXPLICIT_SYNC=0
>    export __GL_YIELD=USLEEP
>    kwin_x11 --replace &
> 
> Another solution is of course to enable triple buffering in the driver since
> that gets you non-blocking swap control:
> 
> /etc/X11/xorg.conf.d/20-nvidia.conf
> -------------
> Section "Device"
>     Identifier "Default nvidia Device"
>     Driver      "nvidia"
>     Option      "NoLogo"                                "True"
>     Option  "CoolBits"                              "1"
>     Option  "TripleBuffer"                  "True"
>     Option  "ExactModeTimingsDVI"   "True"
>     # other settings
> EndSection

I will try these solutions and report back.

> * I assume crash does not mean "segfault" but the GPU hangs?

Whole screen freezes (I can only move mouse but nothing responds to clicks), then after few seconds kwin resets and everything works normal (I get "desktop effects were restarted due to graphics reset" message).
Comment 4 Nikola Schnelle 2015-08-27 14:18:31 UTC
Using both
export KWIN_EXPLICIT_SYNC=0
export __GL_YIELD=USLEEP
works! No crashes so far :))) Thank you Thomas.

I will test  triple buffering thing when I have spare time.
Comment 5 Nikola Schnelle 2015-08-30 09:07:52 UTC
Tripple buffering fixes tearing too without kwin resets/crashes.

But on one reboot I had tearing back. Should I use triple buffering with export __GL_YIELD=USLEEP?
Comment 6 Nikola Schnelle 2015-08-30 20:13:05 UTC
(In reply to Nikola Schnelle from comment #5)
> Tripple buffering fixes tearing too without kwin resets/crashes.
> 
> But on one reboot I had tearing back. Should I use triple buffering with
> export __GL_YIELD=USLEEP?

To answer my question. Yes, triple buffering + export __GL_YIELD=USLEEP works well. No crashes.
Comment 7 Thomas Lübking 2015-08-30 20:20:57 UTC
(In reply to Nikola Schnelle from comment #5)
> Tripple buffering fixes tearing too without kwin resets/crashes.
> 
> But on one reboot I had tearing back.

You'll be running into bug #343184

Technically, __GL_YIELD=USLEEP makes hardly a difference w/ enabled triple buffering.

Does this mean, you don't need to "export KWIN_EXPLICIT_SYNC=0" w/ triple buffering enabled?
Comment 8 Nikola Schnelle 2015-08-30 20:51:07 UTC
With only triple buffering enabled I get tearing sometimes, sometimes my system boots up into tear-free desktop, at random.
Triple buffering +  __GL_YIELD=USLEEP = no tearing (I don't use export KWIN_EXPLICIT_SYNC=0).

Only  __GL_YIELD=USLEEP - no tearing but kwin freezes/resets. 
__GL_YIELD=USLEEP +  export KWIN_EXPLICIT_SYNC=0 = no tearing no kwin resets.

These are my findings. Hope it helps :)
Comment 9 Thomas Lübking 2015-08-30 21:15:55 UTC
(In reply to Nikola Schnelle from comment #8)
> With only triple buffering enabled I get tearing sometimes, sometimes my

Yes, this will be bug #343184
If you encouter tearing, check the output of "qdbus org.kde.KWin /KWin supportInformation" on whether swapping is considered to block (w/o USLEEP, this will make kwin turn off swapcontrol)

> Triple buffering +  __GL_YIELD=USLEEP = no tearing (I don't use export
> KWIN_EXPLICIT_SYNC=0).
Ok, so this implies this is a problem with the double buffering path only.
Comment 10 Janek Bevendorff 2015-11-29 12:00:18 UTC
I have the same issue, but here it also appears when using TripleBuffering + __GL_YIELD=USLEEP.
It doesn't occur very often, but once or twice every day.

I'll try setting KWIN_EXPLICIT_SYNC=0 and will report back if I still see kwin freezes and graphics resets.
Comment 11 Thomas Lübking 2015-11-29 12:14:19 UTC
You *do* have the reset warnings?
Please attach the output of "qdbus.org.kde.KWin /KWin supportInformation"
Comment 12 Janek Bevendorff 2015-11-29 12:23:11 UTC
Yes. When it happens, kwin freezes for a couple of seconds and then resets with a desktop notification.

supportInformation output: http://pastebin.com/K9n7zW6e
Comment 13 Janek Bevendorff 2015-11-29 12:24:48 UTC
Addition: the qdbus output above is now with KWIN_EXPLICIT_SYNC=0. I haven't had any freezes since then. But as I said: it only happens once or twice every day, so I can't say yet if that is a working fx or not.
Comment 14 Thomas Lübking 2015-11-29 12:37:23 UTC
Thanks for clarification, in general please stay away from pastebins when adding informations to bugs (gets autodeleted, thus lost)

KWin Support Information:
The following information should be used when requesting support on e.g. http://forum.kde.org.
It provides information about the currently running instance, which options are used,
what OpenGL driver and which effects are running.
Please post the information provided underneath this introductory text to a paste bin service
like http://paste.kde.org instead of pasting into support threads.

==========================

Version
=======
KWin version: 5.4.3
Qt Version: 5.5.1
Qt compile version: 5.5.1
XCB compile version: 1.11

Operation Mode: X11 only

Build Options
=============
KWIN_BUILD_DECORATIONS: yes
KWIN_BUILD_TABBOX: yes
KWIN_BUILD_ACTIVITIES: yes
HAVE_WAYLAND: yes
HAVE_WAYLAND_EGL: yes
HAVE_WAYLAND_CURSOR: yes
HAVE_XKB: yes
HAVE_INPUT: yes
HAVE_DRM: yes
HAVE_GBM: yes
HAVE_X11_XCB: yes

X11
===
Vendor: The X.Org Foundation
Vendor Release: 11604000
Protocol Version/Revision: 11/0
SHAPE: yes; Version: 0x11
RANDR: yes; Version: 0x14
DAMAGE: yes; Version: 0x11
Composite: yes; Version: 0x4
RENDER: yes; Version: 0xb
XFIXES: yes; Version: 0x50
SYNC: yes; Version: 0x31
GLX: yes; Version: 0x0

Decoration
==========
Plugin: org.kde.breeze
Theme: 
Blur: 0
onAllDesktopsAvailable: true
alphaChannelSupported: true
closeOnDoubleClickOnMenu: false
decorationButtonsLeft: 0, 9
decorationButtonsRight: 6, 3, 4, 5
borderSize: 3
gridUnit: 12
font: Oxygen-Sans,11,-1,5,50,0,0,0,0,0
smallSpacing: 3
largeSpacing: 12

Options
=======
focusPolicy: 0
nextFocusPrefersMouse: false
clickRaise: true
autoRaise: false
autoRaiseInterval: 0
delayFocusInterval: 0
shadeHover: false
shadeHoverInterval: 250
separateScreenFocus: false
placement: 4
focusPolicyIsReasonable: true
borderSnapZone: 10
windowSnapZone: 10
centerSnapZone: 0
snapOnlyWhenOverlapping: false
rollOverDesktops: true
focusStealingPreventionLevel: 1
legacyFullscreenSupport: false
operationTitlebarDblClick: 5000
operationMaxButtonLeftClick: 5000
operationMaxButtonMiddleClick: 5015
operationMaxButtonRightClick: 5014
commandActiveTitlebar1: 0
commandActiveTitlebar2: 30
commandActiveTitlebar3: 2
commandInactiveTitlebar1: 4
commandInactiveTitlebar2: 30
commandInactiveTitlebar3: 2
commandWindow1: 7
commandWindow2: 8
commandWindow3: 8
commandWindowWheel: 31
commandAll1: 10
commandAll2: 3
commandAll3: 14
keyCmdAllModKey: 16777251
showGeometryTip: false
condensedTitle: false
electricBorderMaximize: true
electricBorderTiling: true
electricBorderCornerRatio: 0.25
borderlessMaximizedWindows: false
killPingTimeout: 5000
hideUtilityWindowsForInactive: true
inactiveTabsSkipTaskbar: false
autogroupSimilarWindows: false
autogroupInForeground: true
compositingMode: 1
useCompositing: true
compositingInitialized: true
hiddenPreviews: 1
unredirectFullscreen: false
glSmoothScale: 2
colorCorrected: false
xrenderSmoothScale: false
maxFpsInterval: 16666666
refreshRate: 0
vBlankTime: 6000000
glStrictBinding: false
glStrictBindingFollowsDriver: true
glCoreProfile: true
glPreferBufferSwap: 99
glPlatformInterface: 1

Screen Edges
============
desktopSwitching: false
desktopSwitchingMovingClients: false
cursorPushBackDistance: 1x1
timeThreshold: 150
reActivateThreshold: 350
actionTopLeft: 2
actionTop: 0
actionTopRight: 0
actionRight: 0
actionBottomRight: 0
actionBottom: 0
actionBottomLeft: 0
actionLeft: 0

Screens
=======
Multi-Head: no
Active screen follows mouse:  no
Number of Screens: 2

Screen 0:
---------
Name: DVI-I-1
Geometry: 0,0,2560x1440
Refresh Rate: 59.9506

Screen 1:
---------
Name: DVI-D-0
Geometry: 2560,0,2560x1440
Refresh Rate: 59.9506


Compositing
===========
Compositing is active
Compositing Type: OpenGL
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce GTX 960/PCIe/SSE2
OpenGL version string: 3.1.0 NVIDIA 352.30
OpenGL platform interface: GLX
OpenGL shading language version string: 1.40 NVIDIA via Cg compiler
Driver: NVIDIA
Driver version: 352.30
GPU class: Unknown
OpenGL version: 3.1
GLSL version: 1.40
X server version: 1.16.4
Linux kernel version: 4.1.4
Direct rendering: Requires strict binding: no
GLSL shaders:  yes
Texture NPOT support:  yes
Virtual Machine:  no
OpenGL 2 Shaders are used
Painting blocks for vertical retrace:  no

Loaded Effects:
---------------
zoom
dimscreen
slidingpopups
kwin4_effect_login
wobblywindows
slide
screenshot
magiclamp
kwin4_effect_windowaperture
glide
desktopgrid
kwin4_effect_translucency
kwin4_effect_fade
kwin4_effect_maximize
presentwindows
kwin4_effect_dialogparent
highlightwindow
blur
contrast
logout
dashboard
startupfeedback
screenedge
kscreen

Currently Active Effects:
-------------------------
blur
contrast

Effect Settings:
----------------
zoom:
zoomFactor: 1.2
mousePointer: 0
mouseTracking: 0
enableFocusTracking: false
followFocus: true
focusDelay: 350
moveFactor: 20
targetZoom: 1

dimscreen:

slidingpopups:
fadeInTime: 150
fadeOutTime: 250

kwin4_effect_login:

wobblywindows:
stiffness: 0.14999999999999999
drag: 0.55000000000000004
moveFactor: 0.10000000000000001
xTesselation: 20
yTesselation: 20
minVelocity: 0
maxVelocity: 1000
stopVelocity: 0.5
minAcceleration: 0
maxAcceleration: 1000
stopAcceleration: 0.5
moveEffectEnabled: true
openEffectEnabled: false
closeEffectEnabled: false
moveWobble: true
resizeWobble: true

slide:

screenshot:

magiclamp:
animationDuration: 250

kwin4_effect_windowaperture:

glide:
duration: 350
effect: 0
angle: 1

desktopgrid:
zoomDuration: 300
border: 10
desktopNameAlignment: 0
layoutMode: 0
customLayoutRows: 2
usePresentWindows: true

kwin4_effect_translucency:

kwin4_effect_fade:

kwin4_effect_maximize:

presentwindows:
layoutMode: 0
showCaptions: true
showIcons: true
doNotCloseWindows: false
ignoreMinimized: false
accuracy: 20
fillGaps: true
fadeDuration: 150
showPanel: false
leftButtonWindow: 1
rightButtonWindow: 2
middleButtonWindow: 0
leftButtonDesktop: 2
middleButtonDesktop: 0
rightButtonDesktop: 0

kwin4_effect_dialogparent:

highlightwindow:

blur:
blurRadius: 12
cacheTexture: true

contrast:

logout:
useBlur: true

dashboard:
brightness: 0.5
saturation: 0.5
blur: false

startupfeedback:
type: 0

screenedge:

kscreen:
Comment 15 Janek Bevendorff 2015-11-29 12:40:41 UTC
I pasted it using my pastebin account with expiry set to never. ;-)
Comment 16 Justin Zobel 2021-03-10 00:32:23 UTC
Thank you for the bug report.

As this report hasn't seen any changes in 5 years or more, we ask if you can please confirm that the issue still persists.

If this bug is no longer persisting or relevant please change the status to resolved.
Comment 17 David Edmundson 2023-09-06 10:38:03 UTC
This bug was reported against an outdated version of KWin. We have made many changes since the. 
If the issue persists in newer versions can you reopen the bug report updating the version number.