Bug 388759

Summary: Constant screen repaints after display configuration is changed
Product: [Plasma] plasmashell Reporter: valdikss
Component: generalAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED UPSTREAM    
Severity: normal CC: contact, hohenegger, johan, kde, kdebugs, plasma-bugs
Priority: NOR    
Version: master   
Target Milestone: 1.0   
Platform: Neon   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: plasma restart script

Description valdikss 2018-01-09 23:22:50 UTC
The screen starts to repaint multiple times a second if display configuration is changed, causing excessive GPU load, slowdowns, and higher temperature than expected.

How to reproduce with a laptop:
1. Boot KDE without external display connected.
2. Activate "Show Paint" kwin effect to see screen repaints. Notice that the screen does not get repainted if there are no updates on the screen.
3. Connect external display, configure it to be the only active display using KDE display configurator.
4. The screen start to flash because of excessive repaints.
5. Disconnect external display cable and switch to laptop display. The screen still flashes because of repaints.

Tested on Fedora 27 and KDE Neon gitstable 20180109-1047-amd64. Reproducible 100% of the time.

I'm not completely sure if this is kwin bug or not. Please move to appropriate component if it's not kwin.
Comment 1 valdikss 2018-01-09 23:31:32 UTC
This is plasmashell bug.
"kquitapp plasmashell; plasmashell" fixes the issue.

Also, this can only be triggered when switching to external display required resolution switching. Bug is not reproducible without resolution switching involved, also not reproducible when you just change resolution of laptop's display, without external display connected.
Also reproducible without kwin compositing enabled.
Comment 2 Johan Hartzenberg 2018-01-10 04:35:29 UTC
I can confirm this issue.

HP ProBook 6560b
Intel i915
KDE Neon 5.11
Linux komputer 4.10.0-26-generic #30~16.04.1-Ubuntu SMP Tue Jun 27 09:40:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Comment 3 MiXiM 2018-01-10 07:53:13 UTC
I can confirm this issue.

Acer S7
Intel i7-4500
KDE Neon 5.11
Linux Computer 4.4.0-104-generic
Comment 4 Gunter Ohrner 2018-01-10 11:57:43 UTC
I can confirm. Manually running xrandr to modify the screen configuration will trigger this behaviour.

I originally reported this behaviour July 2017 as Bug 382618. Back then, I did not link it to a screen reconfiguration, but meanwhile I identified this as the trigger.

I'm routinely killing plasmashell to get behaviour back to normal...
Comment 5 Gunter Ohrner 2018-01-10 12:05:36 UTC
(In reply to Gunter Ohrner from comment #4)
> I can confirm. Manually running xrandr to modify the screen configuration
> will trigger this behaviour.

Linux Zweiblum 4.13.0-17-generic #20~16.04.1-Ubuntu SMP Mon Nov 6 14:18:00 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

i7-3540M
00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)

$ dpkg -l | egrep 'kwin|plasma' | cut -c1-75
ii  kdeconnect-plasma                                           1.2-0neon+1
ii  kdeplasma-addons-data                                       4:5.11.4-0n
ii  kwin                                                        4:5.11.4-0n
ii  kwin-addons                                                 4:5.11.4-0n
ii  kwin-common:amd64                                           4:5.11.4-0n
ii  kwin-data                                                   4:5.11.4-0n
ii  kwin-style-breeze                                           4:5.11.4-0n
ii  kwin-x11                                                    4:5.11.4-0n
ii  libkdeclarative5                                            4:4.14.16-0
ii  libkf5plasma-dev                                            5.41.0-0neo
ii  libkf5plasma5:amd64                                         5.41.0-0neo
ii  libkf5plasmaquick5:amd64                                    5.41.0-0neo
ii  libkf5windowsystem-dev                                      5.41.0-0neo
ii  libkwin4-effect-builtins1:amd64                             4:5.11.4-0n
ii  libkwineffects11:amd64                                      4:5.11.4-0n
ii  libkwinglutils11:amd64                                      4:5.11.4-0n
ii  libkwinglutils6                                             4:5.4.3-0ub
ii  libkwinxrenderutils11:amd64                                 4:5.11.4-0n
ii  libkwinxrenderutils6                                        4:5.4.3-0ub
ii  libplasma-geolocation-interface5                            4:5.11.4-0n
ii  libplasma3                                                  4:4.14.16-0
ii  libsmokeplasma3                                             4:4.14.2-0u
ii  muon-discover                                               4:5.11.4-0n
ii  muon-notifier                                               4:5.11.4-0n
ii  muon-updater                                                4:5.11.4-0n
ii  plasma-dataengines-addons                                   4:5.11.4-0n
ii  plasma-desktop                                              4:5.11.4-0n
ii  plasma-desktop-data                                         4:5.11.4-0n
ii  plasma-discover                                             5.11.4-0neo
ii  plasma-discover-common                                      5.11.4-0neo
ii  plasma-discover-private                                     5.11.4-0neo
ii  plasma-discover-updater                                     5.11.4-0neo
ii  plasma-framework                                            5.41.0-0neo
ii  plasma-integration                                          5.11.4-0neo
ii  plasma-look-and-feel-org-kde-breezedark-desktop             4:5.11.4-0n
ii  plasma-nm                                                   4:5.11.4-0n
ii  plasma-pa                                                   4:5.11.4-0n
ii  plasma-runners-addons                                       4:5.11.4-0n
ii  plasma-scriptengine-javascript                              4:15.12.3-0
ii  plasma-scriptengine-superkaramba                            4:15.08.3-0
ii  plasma-vault                                                5.11.4-0neo
ii  plasma-wallpapers-addons                                    4:5.11.4-0n
ii  plasma-widget-message-indicator                             0.5.8-3    
ii  plasma-widgets-addons                                       4:5.11.4-0n
ii  plasma-workspace                                            4:5.11.4-0n
ii  qml-module-org-kde-kwindowsystem:amd64                      5.41.0-0neo
Comment 6 valdikss 2018-01-10 20:21:07 UTC
Created attachment 109785 [details]
plasma restart script

(In reply to Gunter Ohrner from comment #4)
> I'm routinely killing plasmashell to get behaviour back to normal...

Here's a temporary hack. Save this as "plasmarestart.sh", chmod +x plasmarestart.sh, and add to KDE's autorun.
Comment 7 Andreas 2018-01-13 10:28:01 UTC
I think, that this is the behavior I see and for which I reported a bug previously. It had been moved to https://bugs.kde.org/show_bug.cgi?id=378010 . I did not know about the constant screen repaints then, but activating "Show Paint" shows that this is the case. Restarting plsasmashell does remove the phenomenon instantaneously, but does not fix the bug.
As a work around, I am using the script below. This will take care of automatically restarting plasmashell, but note that it causes that you will see the taskbar rebuild each time you change displays or unlock the screen.

#!/bin/bash

dbus-monitor --session "type='signal',interface='org.freedesktop.ScreenSaver'" |
  while read x; do
    case "$x" in 
      *"boolean true"*) echo "lock";;
      *"boolean false"*) kquitapp5 plasmashell; sleep 2; kstart5 plasmashell;;  
    esac
  done &

dbus-monitor --session "type='signal',interface='org.kde.kscreen.Backend',path='/backend',member='configChanged'" |
    kquitapp5 plasmashell; sleep 2; kstart5 plasmashell;
Comment 8 Andreas 2018-01-13 10:31:34 UTC
Sorry valdikss@gmail.com . I did not see your last post. That script seems to amount to the same.
Comment 9 David Edmundson 2018-01-19 12:28:19 UTC
Can everyone please mention their Qt versions when commenting. 

There have been multiple potentially relevant commits between Qt5.9 and 5.10. 

Realistically I don't have time to look at Qt issues < 5.10 as they might already be fixed.
Comment 10 valdikss 2018-01-19 13:02:00 UTC
(In reply to David Edmundson from comment #9)

Qt5 5.9.2-1.fc27 on Fedora
Qt5 5.9.3-0neon+16.04+xenial+build22 on Neon gitstable
Comment 11 valdikss 2018-01-19 14:00:49 UTC
The issue is probably in Qt, not Plasma. Manjaro 17.1.1 with Qt 5.10 is not affected.
Comment 12 valdikss 2018-01-19 14:24:31 UTC
It would be helpful if anyone can point to exact patch which fixes this issue, so distro maintainers can apply it on top of current Qt version.
Comment 13 David Edmundson 2018-01-19 16:35:57 UTC
Likely candidate are:
6990ae6c1bad32952e371fa72bee65a7af11c313
9538cd7fbe43b1479f23a37bc8f19012981257a6
93df3e3a3118080dcd6d9416d1622b88d99c4b8d
Comment 14 valdikss 2018-01-19 17:14:37 UTC
(In reply to David Edmundson from comment #13)
> Likely candidate are:
> 6990ae6c1bad32952e371fa72bee65a7af11c313
> 9538cd7fbe43b1479f23a37bc8f19012981257a6
> 93df3e3a3118080dcd6d9416d1622b88d99c4b8d

The last two were already included in 5.9.2, but the first one is exactly what you need. It fixes the issue.
Comment 15 valdikss 2018-01-19 17:54:13 UTC
I filled a bug to Fedora bugtracker: https://bugzilla.redhat.com/show_bug.cgi?id=1536606
Please do the same for your distro if you're affected.
Comment 16 Gunter Ohrner 2018-01-19 20:37:28 UTC
KDE Neon: https://bugs.kde.org/show_bug.cgi?id=389218