Bug 172485 - Kopete has full CPU load (freezes) when receiving a long line
Summary: Kopete has full CPU load (freezes) when receiving a long line
Status: RESOLVED FIXED
Alias: None
Product: kopete
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Unspecified
: NOR crash
Target Milestone: ---
Assignee: Kopete Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-10 01:11 UTC by Matija Šuklje
Modified: 2008-10-19 19:30 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matija Šuklje 2008-10-10 01:11:51 UTC
Version:            (using KDE 3.5.9)
Compiler:          x86_64-pc-linux-gnu-g++ 4.1.2 20070214 (  (gdc 0.24, using dmd 1.020)) (Gentoo 4.1.2 p1.1) 
Installed from:    Gentoo Packages

Kopete eats up all the CPU load and freezes when the user receives a long line of characters.

Steps of reproduction:
* start Kopete
* go online
* let someone send you a very long line (e.g. your girlfriend throwing you a :******** kiss with a few hundred *'s in it)
* enjoy the CPU load and killing Kopete after it freezes

Expected results:
* show the line
* no freeze, no high CPU usage
* your girlfriend not having the upper hand on remotely crashing your IM any more ;)

I've only tested this with MSN so far and I managed to reproduce the bug 4 out of 4 tries.

Interestingly when I *send* an immensely long line it doesn't crash.
Comment 1 Matija Šuklje 2008-10-11 06:59:22 UTC
Oh, dear. It seems I've misunderstood her — she didn't try to send me a long line of characters, but cca. a hundred animated smiles (the same one, only repeated a hundred times in the same "line").

Hmm, should I close this one and make a new bug?
Comment 2 Roman Jarosz 2008-10-17 00:28:49 UTC
The slow part is QTextDocument::setHtml in libkopete/kopetemessage.cpp Message::doSetBody. We use QTextDocument because we need toPlainText function. So is there any faster way to convert html to plain text?

The next slower part is KEmoticonsTheme::tokenize but tokenize is 6 times faster than setHtml.
Comment 3 Roman Jarosz 2008-10-17 23:16:14 UTC
SVN commit 872704 by rjarosz:

Fix bug 172485 Kopete has full CPU load (freezes) when receiving a long line.

The message.setHtmlBody( message.parsedBody() ); which should cache the emoticons actually didn't cache it and it made it even worse because setHtml is much slower than parsedBody if we have many emoticons (html tags).

So this patch removes this line and adds caching into the parsedBody function. The great thing is that we don't have to call setHtml which was the bottleneck.

BUG: 172485



 M  +1 -9      kopete/chatwindow/chatmessagepart.cpp  
 M  +14 -3     libkopete/kopetemessage.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=872704
Comment 4 Matija Šuklje 2008-10-17 23:47:42 UTC
Will this be uploaded to trunk and if so, which version(s) will include the patch already?
Comment 5 Roman Jarosz 2008-10-18 09:12:03 UTC
This is already in trunk see Comment #3, I'll also backport it for KDE 4.1.3.
Comment 6 Roman Jarosz 2008-10-18 11:13:22 UTC
SVN commit 872808 by rjarosz:

Backport SVN commit 872704.
Fix bug 172485 Kopete has full CPU load (freezes) when receiving a long line.

CCBUG: 172485



 M  +0 -5      kopete/chatwindow/chatmessagepart.cpp  
 M  +13 -3     libkopete/kopetemessage.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=872808
Comment 7 Matija Šuklje 2008-10-19 19:30:11 UTC
Thank you :)