I've noticed that while I'm playing fullscreen video (e.g. a YouTube Let's Play, VP9 1920x1080@60 fps) in SMPlayer/mpv the kwin_x11 process occasionally starts consuming one CPU core 100%, as if in a busy loop. No visual artefacts or stuttering are visible at this time. I have no fixed steps to reproduce the problem, other than start playing video from youtube fullscreen and watch the CPU load in KSysGuard. The CPU consumption spikes happen at varying intervals, typically ranging from tens of seconds to several minutes, and typically long from a few to tens of seconds. I have these lines in /etc/environment: KWIN_TRIPLE_BUFFER=1 KWIN_USE_BUFFER_AGE=0 __GL_SYNC_TO_VBLANK=1 __GL_SYNC_DISPLAY_DEVICE="DFP-0" __GL_THREADED_OPTIMIZATIONS=1 I tried starting kwin_x11 with __GL_THREADED_OPTIMIZATIONS=0, but that doesn't fix the problem, although maybe it reduces it a little. mpv is configured to output video using VDPAU. I'm not seeing this problem with other window managers, such as compiz or xfwm4+compton. Kubuntu 17.10, x86_64, KWin 5.10.5, Nvidia driver 387.22, GTX980.
5.10 is no longer supported by us. Please try again with 5.11.
I'm not going to be able to test it until it is available in Kubuntu. If it can be built against Kubuntu 17.10 packages, I can try building it but I will need instructions.
I have compiled Kwin 5.11.3 on Kubuntu 17.10 (all other packages taket from Kubuntu repos) and can reproduce the CPU spikes. The spikes seem to happen only if I have KWIN_TRIPLE_BUFFER=1 in /etc/environment. If I comment that line and instead put __GL_YIELD="USLEEP" to Kwin startup line I can see no spikes, at least not for about an hour I tested. So, to summarize: 1. /etc/environment: KWIN_TRIPLE_BUFFER=1 KWIN_USE_BUFFER_AGE=0 __GL_SYNC_TO_VBLANK=1 __GL_SYNC_DISPLAY_DEVICE="DFP-0" __GL_THREADED_OPTIMIZATIONS=1 Kwin startup command: __GL_THREADED_OPTIMIZATIONS=0 kwin_x11 Problem happens. 2. /etc/environment: #KWIN_TRIPLE_BUFFER=1 KWIN_USE_BUFFER_AGE=0 __GL_SYNC_TO_VBLANK=1 __GL_SYNC_DISPLAY_DEVICE="DFP-0" __GL_THREADED_OPTIMIZATIONS=1 Kwin startup command: __GL_THREADED_OPTIMIZATIONS=0 __GL_YIELD="USLEEP" kwin_x11 Problem does not happen. In both cases I'm playing this video fullscreen in mpv: https://www.youtube.com/watch?v=dFW0BSdR2G4 The video is vp9 1920x1080 60.000fps, fullscreen on a secondary screen that has resolution 1920x1080. mpv options are: --cache-initial=2048 --vf-add=gradfun --vf-add="vdpaupp=hqscaling=1" --ytdl-format="((bestvideo[height<=?1080][vcodec=vp9]/bestvideo[height<=?1080])+(bestaudio[acodec=opus]/bestaudio[acodec=vorbis]/bestaudio[acodec=aac]/bestaudio))/best" --ytdl-raw-options="socket-timeout=10" --network-timeout=10
I've also tested without KWIN_TRIPLE_BUFFER=1 and __GL_YIELD="USLEEP" and I'm also seeing CPU spikes.
I fear this are problems caused by the Nvidia driver. Many of those environment variables are only relevant for the Nvidia driver. My suggestion is to try with everything on default, maybe even with a new user.
If I remove all environment variables I get tearing and no CPU spikes. I found that the minimal setup to get CPU spikes is to have KWIN_USE_BUFFER_AGE=0 in /etc/environment. The average CPU consumption by Kwin in this setup while playing video fullscreen is noticeable higher (2-3% vs 0-1% as KSysGuard reports) and there are periodic CPU spikes. Adding just __GL_YIELD="USLEEP" to /etc/environment solves the CPU spikes. Other things I've tried: __GL_THREADED_OPTIMIZATIONS=1 alone does not enable CPU spikes, but together with KWIN_USE_BUFFER_AGE=0 it seems to make the spikes more prominent (i.e. more often to appear and longer in duration). Other mentioned environment variables don't seem to affect the problem. "Allow applications to block compositing" in Compositor setting doesn't affect the problem. During all the testing, Rendering backend was OpenGL 3.1, Tearing prevention was Automatic. I cannot permanently remove KWIN_USE_BUFFER_AGE=0 because this is a workaround for https://bugs.kde.org/show_bug.cgi?id=363500.
An increased system usage is to be expected if you disable buffer age. AFAIK __GL_YIELD="USLEEP" is the recommended way for NVIDIA drivers. Overall I don't see an issue here. The system doesn't have CPU spikes in the default setup and only starts to show those spikes when manually modifying KWin through env variables. I'm sorry to say, but you cannot expect all combinations to work equally good.
I didn't have that problem with the same driver on Kubuntu 17.04, i.e. it's a regression. I'm also not having the problem with other WMs like compton or compiz. So I'm expecting Kwin to at least continue to work in the previous config the same way it did before and preferably not worse than alternatives.
Compared to 17.04 you also updated the Nvidia driver. So the problem might also be there. I'm sorry but you cannot expect any support for the proprietary driver.