konsole eats cpu redraw compiled with qt5.5. There are no problems with qt4.4 or konsole-4.14.3. Reproducible: Always Steps to Reproduce: 1. Launch any program with lot's of output (fill konsole's output buffer) 2. Try to select text with mouse - move mouse pointer constantly. Actual Results: 100% cpu usage Expected Results: low cpu usage Selecting text with mouse it not root cause of the problem. High cpu usage can be noticed during any text output (redrawing).
The same problem here. This bug on my system is related to qt-5.5.1. With qt-5.4.2 everything was OK.
Additional info to my previous comment. Everything is slow. Choosing a menu, switching between tabs, selecting text, typing text, etc. I don't have any problems with other programs (dolphin, kcalc, etc). My system: qt-5.5.1 KF-5.15 Plasma-5.4.2 If you need any info or test patches I can do that
QPainter::drawText() causes high CPU usage. Callgrind when CPU goes 100% Frame: Ir Backtrace for Thread 1 [ 0] 4,731,312 0x0000000000042a20 (315421 x) [ 1] 139,363,373 __strtof_internal (367991 x) [ 2] 769,839,725 _IO_vfscanf (893695 x) [ 3] 902,211,714 vsscanf (893695 x) [ 4] 223,944,842 sscanf (52570 x) [ 5] 125,954,300 FT_Library_SetLcdFilter (26285 x) [ 6] 5,813,230,932 QFontEngineFT::loadGlyph(QFontEngineFT::QGlyphSet*, unsigned int, QFixed, QFontEngine::GlyphFormat, bool) const (52512 x) [ 7] 4,526,732,790 QFontEngineFT::loadGlyphFor(unsigned int, QFixed, QFontEngine::GlyphFormat, QTransform const&, bool) (26545 x) [ 8] 5,876,314,105 QFontEngineFT::lockedAlphaMapForGlyph(unsigned int, QFixed, QFontEngine::GlyphFormat, QTransform const&, QPoint*) (26545 x) [ 9] 5,880,075,343 QRasterPaintEngine::drawCachedGlyphs(int, unsigned int const*, QFixedPoint const*, QFontEngine*) (245 x) [10] 5,881,099,208 QRasterPaintEngine::drawTextItem(QPointF const&, QTextItem const&) (245 x) [11] 5,882,249,055 0x00000000002e0500 (245 x) [12] 5,866,103,556 QTextLine::draw(QPainter*, QPointF const&, QTextLayout::FormatRange const*) const (215 x) [13] 5,935,230,553 0x00000000002d6620 (245 x) [14] 5,917,082,161 QPainter::drawText(QRect const&, int, QString const&, QRect*) (214 x) [15] 5,917,687,848 Konsole::TerminalDisplay::drawCharacters(QPainter&, QRect const&, QString const&, Konsole::Character const*, bool) (214 x) [16] 5,918,124,988 Konsole::TerminalDisplay::drawTextFragment(QPainter&, QRect const&, QString const&, Konsole::Character const*) (214 x) [17] 3,910,286,730 Konsole::TerminalDisplay::drawContents(QPainter&, QRect const&) (6 x) [18] 3,848,926,916 Konsole::TerminalDisplay::paintEvent(QPaintEvent*) (4 x) [19] 3,848,949,537 QWidget::event(QEvent*) (7 x) [20] 5,943,738,468 Konsole::TerminalDisplay::event(QEvent*) (107 x) [21] 5,984,771,204 QApplicationPrivate::notify_helper(QObject*, QEvent*) (2415 x) [22] 5,984,939,256 QApplication::notify(QObject*, QEvent*) (2415 x) [23] 5,951,145,765 QCoreApplication::notifyInternal(QObject*, QEvent*) (36 x) [24] 3,864,521,726 QWidgetPrivate::sendPaintEvent(QRegion const&) (7 x) [25] 3,868,309,475 QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) (5 x) [26] 3,855,962,842 0x00000000001685a0 (3 x) [27] 3,855,963,001 0x0000000000169ca0 (4 x) [28] 3,855,963,174 QWidgetPrivate::syncBackingStore() (4 x) [29] 3,856,152,888 QWidget::event(QEvent*) (159 x) [30] 3,856,163,443 QMainWindow::event(QEvent*) (155 x) [31] 3,856,267,760 KMainWindow::event(QEvent*) (154 x) [32] 3,856,086,968 KXmlGuiWindow::event(QEvent*) (16 x) [33] 6,156,252,233 QApplicationPrivate::notify_helper(QObject*, QEvent*) (491 x) [34] 6,156,285,205 QApplication::notify(QObject*, QEvent*) (491 x) [35] 4,041,255,892 QCoreApplication::notifyInternal(QObject*, QEvent*) (395 x) [36] 4,041,424,608 QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (96 x) [37] 4,041,432,288 QCoreApplication::sendPostedEvents(QObject*, int) (96 x) [38] 4,041,433,720 0x00000000002a5200 (96 x) [39] 6,156,572,354 g_main_context_dispatch (110 x) [40] 6,156,851,601 0x000000000004b920 (110 x) [41] 5,985,678,816 g_main_context_iteration (105 x) [42] 5,985,776,834 QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (105 x) [43] 6,156,933,240 0x000000000006d3a0 (106 x) [44] 6,156,934,088 QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (106 x) [45] 6,156,935,580 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (1 x) [46] 6,156,938,243 0x0000000000015060 (1 x) [47] 6,156,938,674 QCoreApplication::exec() (1 x) [48] 6,156,941,246 0x0000000000015060 (1 x) [49] 6,157,137,483 QGuiApplication::exec() (1 x) [50] 6,157,139,997 0x0000000000015060 (1 x) [51] 6,157,140,003 QApplication::exec() (1 x) [52] 6,157,142,492 0x0000000000015060 (1 x) [53] 6,411,194,200 kdemain (1 x) [54] 6,411,194,808 0x0000000000015060 (1 x) [55] 6,411,194,823 main (1 x) [56] 6,411,195,026 (below main) (1 x) [57] 6,411,200,813 0x0000000000015060 (1 x) [58] 6,411,200,829 _start (1 x) [59] . 0x0000000000000c40
QT_NO_FT_CACHE=1 konsole helps a little bit but font's are ugly.
It looks like freetype2 infinality was the cause of this behaviour. After uninstalling infinality everything is OK
Same issue here, I can confirm the fix as well.
konsole-4 have no problems with infinality. Also getting rid of infinality is really not an option IMHO.
Yes I guess this is a Qt5.5+ bug, no?
Any news on this? Currently I have the choice between ugly and dog-slow font rendering, which is really annoying. :(
Strange. I'm still using qt.5.5.1 but I'm not able to reproduce this bug anymore. I have strange feeling that breeze style was the root this problem. For example this commit resolved slow startup and memory leak https://quickgit.kde.org/?p=breeze.git&a=commitdiff&h=2cae9359188af85ac884e2709c17592bc67b0e73
Bug still exists. I'm using gentoo ~x64. I've tried both konsole-4 and latest konsole. My test is to launch top in konsole and to constantly make text selection. konsole-4 eats less then 5% of cpu while latest konsole eats more then 50% cpu.
I also have not noticed improvements with this. it might be related to the theme, I'll check. I will set this to confirmed as several users are affected and I can clearly link this issue to infinality on two machines.
I also see excess cpu usage. Moving cursor in vim produces high cpu usage, and stutters a bit, enough to be extremely annoying. Using QT5.6.0 and konsole 15.12.3.
Any chances for fix :( Bug is still here...
It seems that konsole renders lot's of 'spaces' and glyph height is zero in that case. I've created small hacky patch and performance is OK now. Also I've not noticed any artifacts. Sorry if I'm mistaken, this is my first time I'm in touch with qt in any way. diff -r 6c0e7b4f5bc5 src/gui/text/qfontengine_ft.cpp — a/src/gui/text/qfontengine_ft.cpp Fri Jul 08 13:10:54 2016 +0300 +++ b/src/gui/text/qfontengine_ft.cpp Fri Jul 08 13:13:55 2016 +0300 @@ -1756,6 +1756,9 @@ Glyph *glyph = loadGlyphFor(glyphIndex, subPixelPosition, neededFormat, t); + if (glyph != 0 && glyph->height == 0) + return ¤tlyLockedAlphaMap; + if (offset != 0 && glyph != 0) *offset = QPoint(glyph->x, glyph>y);
If that indeed improves things, you should definitely submit it to Qt. Here is not a good place for it :)
Already done.
(In reply to Viktor Kuzmin from comment #17) > Already done. Link, please?
https://bugreports.qt.io/browse/QTBUG-49452
I had no time currently to investigate problem completely -> this patch is 'hack' for me right now. Will have more time next week. Anyway I have normal cpu usage in konsole (5-7% one core max) and I see no glitches.
Cool, many thanks for investigating this! Your fix looks sensible to me (if the glyph height is zero there is nothing to do), but I'm not really qualified to review it. Did you submit it to the Qt code review system? In the bug tracker it will probably get lost ... people don't review patches there.
Can we maybe fix this in konsole instead? Its use of the API does seem strange judging from what you describe.
how is the API usage strange? it just calls QPainter::drawText().
Which fonts are you using? However, it seems to be fixed upstream in Qt, so I'm closing this.
Can you link to the upstream change which fixed this issue?
the Qt bug report was linked above, and was closed with this: https://codereview.qt-project.org/#/c/166532