<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>365317</bug_id>
          
          <creation_ts>2016-07-10 10:13:27 +0000</creation_ts>
          <short_desc>Rapid window title updates cause plasmashell to become unresponsive</short_desc>
          <delta_ts>2018-09-26 08:47:59 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Plasma</classification>
          <product>plasmashell</product>
          <component>Task Manager and Icons-Only Task Manager widgets</component>
          <version>5.7.0</version>
          <rep_platform>Arch Linux</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>1.0</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Martin Doege">mdoege</reporter>
          <assigned_to name="Eike Hein">hein</assigned_to>
          <cc>benjamin.hall</cc>
    
    <cc>bshah</cc>
    
    <cc>grahamperrin</cc>
    
    <cc>kde</cc>
    
    <cc>kde</cc>
    
    <cc>nate</cc>
    
    <cc>nick.craig.law</cc>
    
    <cc>notuxius</cc>
    
    <cc>physios</cc>
    
    <cc>plasma-bugs-null</cc>
          
          <cf_commitlink>https://commits.kde.org/plasma-workspace/ec1931f7b2980a3cd445c09def1bb4a9b5ad607f</cf_commitlink>
          <cf_versionfixedin>5.13.0</cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1606600</commentid>
    <comment_count>0</comment_count>
    <who name="Martin Doege">mdoege</who>
    <bug_when>2016-07-10 10:13:27 +0000</bug_when>
    <thetext>I ran into this bug in 5.7.0 with my Python 3 RSS reader: As the reader fetches new feeds, it updates the unread item count in its window title. This worked without problems with older versions of KDE, but in 5.7.0 it causes the task bar to hang with very high CPU usage. Sometimes it will recover on its own, other times I have to &quot;xkill&quot; it.

Reproducible: Always

Steps to Reproduce:
Run the Python 3 script below. It sets up a Tk app and updates the window title and icon name very quickly, which should trigger this problem.

With longer time intervals between updates (say, &quot;root.after(20&quot;), I also see the plasmashell issue, but the task bar will not lock up for as long.

#!/usr/bin/env python3

from  tkinter import *
import random

def title():
	root.title(&quot;aaaaaaaa %u&quot; % random.randint(1,5))
	root.iconname(&quot;bbbbbbb %u&quot; % random.randint(1,5))
	root.after(5, title)

class TkApp:
	def __init__(s, parent):
		s.parent = parent


root = Tk()
app = TkApp(root)
root.iconname(&quot;test&quot;)
root.after(500, title)
root.mainloop()



Actual Results:  
The Plasma taskbar becomes unresponsive for 45 seconds or so. The clock in the taskbar stops. Task bar cannot be used to switch between apps. CPU usage of plasmashell is very high.

Expected Results:  
Task bar behaves normally.

This is on a dual core Pentium-class system. On a faster CPU, behavior might differ.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1606602</commentid>
    <comment_count>1</comment_count>
      <attachid>99985</attachid>
    <who name="Martin Doege">mdoege</who>
    <bug_when>2016-07-10 10:17:59 +0000</bug_when>
    <thetext>Created attachment 99985
Python 3 test script</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1606606</commentid>
    <comment_count>2</comment_count>
    <who name="Martin Doege">mdoege</who>
    <bug_when>2016-07-10 10:27:25 +0000</bug_when>
    <thetext>P.S. I forgot to mention you are supposed to CTRL-C out of the demo script in the terminal, otherwise it will run forever.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1606633</commentid>
    <comment_count>3</comment_count>
    <who name="Martin Doege">mdoege</who>
    <bug_when>2016-07-10 12:33:48 +0000</bug_when>
    <thetext>P.P.S. And when I wrote Pentium, I was talking about a modern Pentium of course (basically an i3 without multi-threading), not a 1990s Pentium. Just to be clear...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1606636</commentid>
    <comment_count>4</comment_count>
    <who name="Kai Uwe Broulik">kde</who>
    <bug_when>2016-07-10 12:53:51 +0000</bug_when>
    <thetext>I can confirm. It seems like it reloads (or re-queries from the model and thus reloads) the window icon whenever the title changes causing it to go crazy.

#10 0x00007ffff33c7b14 in QImageWriter::write(QImage const&amp;) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#11 0x00007ffff33a1d56 in operator&lt;&lt;(QDataStream&amp;, QImage const&amp;) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#12 0x00007ffff33d31cc in operator&lt;&lt;(QDataStream&amp;, QPixmap const&amp;) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#13 0x00007ffff4f863c4 in ?? () from /usr/lib/x86_64-linux-gnu/libKF5IconThemes.so.5
#14 0x00007ffff4f876a0 in KIconLoader::loadIcon(QString const&amp;, KIconLoader::Group, int, int, QStringList const&amp;, QString*, bool) const ()
   from /usr/lib/x86_64-linux-gnu/libKF5IconThemes.so.5
#15 0x00007ffff4f7da94 in KIconEngine::pixmap(QSize const&amp;, QIcon::Mode, QIcon::State)
    () from /usr/lib/x86_64-linux-gnu/libKF5IconThemes.so.5
#16 0x00007ffff33e5e48 in QIcon::pixmap(QWindow*, QSize const&amp;, QIcon::Mode, QIcon::State) const () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#17 0x00007ffff33e5f0e in QIcon::pixmap(QSize const&amp;, QIcon::Mode, QIcon::State) const
    () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#18 0x00007fffe050699a in ?? ()
   from /usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/org.kde.kwindowsystem.platforms/KF5WindowSystemX11Plugin.so
#19 0x00007fffe0503ee6 in ?? ()
   from /usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/org.kde.kwindowsystem.platforms/KF5WindowSystemX11Plugin.so
#20 0x00007ffff51c04a4 in KWindowSystem::icon(unsigned long long, int, int, bool, int)
    () from /usr/lib/x86_64-linux-gnu/libKF5WindowSystem.so.5
#21 0x00007ffff51c04d7 in KWindowSystem::icon(unsigned long long, int, int, bool) ()
   from /usr/lib/x86_64-linux-gnu/libKF5WindowSystem.so.5
#22 0x00007fff362ecadc in TaskManager::XWindowTasksModel::Private::icon(unsigned long long) () from /usr/lib/x86_64-linux-gnu/libtaskmanager.so.6
#23 0x00007fff362ed373 in TaskManager::XWindowTasksModel::data(QModelIndex const&amp;, int) const () from /usr/lib/x86_64-linux-gnu/libtaskmanager.so.6</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1606638</commentid>
    <comment_count>5</comment_count>
    <who name="Kai Uwe Broulik">kde</who>
    <bug_when>2016-07-10 13:08:50 +0000</bug_when>
    <thetext>Wait a second. You actually constantly change the icon name in your script. So that it announces icon changes is to be expected, I missed that. But still, we should either compress those events or do something else more sensible than freezing. :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1606659</commentid>
    <comment_count>6</comment_count>
    <who name="Martin Doege">mdoege</who>
    <bug_when>2016-07-10 13:44:04 +0000</bug_when>
    <thetext>Yes, and as I wrote this unresponsiveness persists for quite a while after you quit the script. I could understand a little task bar lag while the script is running, but the recovery after that is far too slow.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1606662</commentid>
    <comment_count>7</comment_count>
    <who name="Kai Uwe Broulik">kde</who>
    <bug_when>2016-07-10 13:45:53 +0000</bug_when>
    <thetext>It most likely queues all the events and then processes them one by one so it continues long after the script has already quit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1606666</commentid>
    <comment_count>8</comment_count>
    <who name="Martin Doege">mdoege</who>
    <bug_when>2016-07-10 14:00:21 +0000</bug_when>
    <thetext>Maybe it could use a timestamp for these events and drop them if they are older than a few seconds. Or maybe there should be a maximum length for the queue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1648810</commentid>
    <comment_count>9</comment_count>
    <who name="PhysiOS">physios</who>
    <bug_when>2017-01-01 18:54:14 +0000</bug_when>
    <thetext>I can confirm it as well, I am making a game with libgdx and I ran into this issue. Plasma freezes up temporarily and uses ~95% of one of my cpu cores until it&apos;s unfrozen. 

I am running KDE Plasma 5.8.4, KDE Frameworks 5.28.0 if that is of any help.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1648923</commentid>
    <comment_count>10</comment_count>
    <who name="Eike Hein">hein</who>
    <bug_when>2017-01-02 08:20:19 +0000</bug_when>
    <thetext>This is somewhat a known todo. The old libtaskmanager contained event compression code ignoring updates across time slices of 200ms, the new libtaskmanager currently doesn&apos;t yet. It&apos;s mentioned in the FIXMEs/TODOs of the lib.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1701432</commentid>
    <comment_count>11</comment_count>
    <who name="David Edmundson">kde</who>
    <bug_when>2017-09-16 13:47:00 +0000</bug_when>
    <thetext>Does someone want to test if https://phabricator.kde.org/D7481 has any impact?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1734463</commentid>
    <comment_count>12</comment_count>
    <who name="Alexander Mentyu">notuxius</who>
    <bug_when>2018-02-28 08:17:05 +0000</bug_when>
    <thetext>Upon running the Python script - Panel and Desktop become unresponsive - Plasma displays CPU usage up to 100% in htop utitility - and for one time after killing the script - Plasma didn&apos;t stop to consume CPU - how can i test the https://phabricator.kde.org/D7481 patch?

Plasma: 5.12.2
Apps: 17.12.2
Frameworks: 5.43.0
Qt: 5.10.1
Kernel: 4.14.20-2-MANJARO
OS: Netrunner Rolling</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1741570</commentid>
    <comment_count>13</comment_count>
    <who name="David Edmundson">kde</who>
    <bug_when>2018-03-29 14:38:47 +0000</bug_when>
    <thetext>Git commit ec1931f7b2980a3cd445c09def1bb4a9b5ad607f by David Edmundson.
Committed on 29/03/2018 at 14:38.
Pushed by davidedmundson into branch &apos;master&apos;.

Batch window changes events on XCB

Summary:
In a log from someone talking about high CPU we can see get multiple X
events for the same window as multiple events, but directly next to each
other. This causes the TaskManager to process changes multiple times
instead of just once which is a waste.

An example is just pressing &quot;enter&quot; in konsole, which will pointlessly
update the title.

This causes problems for expensive app lookup and also QML performs text layouts immediately so any text changes cause quite large CPU usage if done more than 60fps; especially a task text resizing
could result in resizing the entire panel.

Something not relevant in kwin that also monitors these rolls.

This class sits between KWindowSystem and XWindowTasksModel
transparently buffering the changes.
Related: bug 378010

Reviewers: #plasma, hein, broulik

Reviewed By: #plasma, hein, broulik

Subscribers: ngraham, cfeck, broulik, hein, graesslin, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D7481

M  +1    -0    libtaskmanager/CMakeLists.txt
M  +0    -1    libtaskmanager/TODO.txt
A  +80   -0    libtaskmanager/xwindowsystemeventbatcher.cpp     [License: BSD]
A  +51   -0    libtaskmanager/xwindowsystemeventbatcher.h     [License: BSD]
M  +6    -5    libtaskmanager/xwindowtasksmodel.cpp

https://commits.kde.org/plasma-workspace/ec1931f7b2980a3cd445c09def1bb4a9b5ad607f</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1754707</commentid>
    <comment_count>14</comment_count>
    <who name="Nate Graham">nate</who>
    <bug_when>2018-05-25 03:38:20 +0000</bug_when>
    <thetext>*** Bug 393748 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1787856</commentid>
    <comment_count>15</comment_count>
    <who name="Kai Uwe Broulik">kde</who>
    <bug_when>2018-09-26 08:46:42 +0000</bug_when>
    <thetext>*** Bug 399088 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>99985</attachid>
            <date>2016-07-10 10:17:59 +0000</date>
            <delta_ts>2016-07-10 10:17:59 +0000</delta_ts>
            <desc>Python 3 test script</desc>
            <filename>title_bug.py</filename>
            <type>text/x-python</type>
            <size>353</size>
            <attacher name="Martin Doege">mdoege</attacher>
            
              <data encoding="base64">IyEvdXNyL2Jpbi9lbnYgcHl0aG9uMwoKZnJvbSAgdGtpbnRlciBpbXBvcnQgKgppbXBvcnQgcmFu
ZG9tCgpkZWYgdGl0bGUoKToKCXJvb3QudGl0bGUoImFhYWFhYWFhICV1IiAlIHJhbmRvbS5yYW5k
aW50KDEsNSkpCglyb290Lmljb25uYW1lKCJiYmJiYmJiICV1IiAlIHJhbmRvbS5yYW5kaW50KDEs
NSkpCglyb290LmFmdGVyKDUsIHRpdGxlKQoKY2xhc3MgVGtBcHA6CglkZWYgX19pbml0X18ocywg
cGFyZW50KToKCQlzLnBhcmVudCA9IHBhcmVudAoKCnJvb3QgPSBUaygpCmFwcCA9IFRrQXBwKHJv
b3QpCnJvb3QuaWNvbm5hbWUoInRlc3QiKQpyb290LmFmdGVyKDUwMCwgdGl0bGUpCnJvb3QubWFp
bmxvb3AoKQoKCgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>