Bug 178210 - kwin with effects enabled uses a lot of cpu with shaped windows
Summary: kwin with effects enabled uses a lot of cpu with shaped windows
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: compositing (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: VHI normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 166271 181186 189975 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-12-19 19:20 UTC by Ander Conselvan de Oliveira
Modified: 2009-08-12 12:43 UTC (History)
15 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Test program (Written by Gustavo Boiko) (1.01 KB, application/x-bzip)
2008-12-19 19:21 UTC, Ander Conselvan de Oliveira
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ander Conselvan de Oliveira 2008-12-19 19:20:06 UTC
Version:            (using Devel)
OS:                Linux
Installed from:    Compiled sources

As reported on https://qa.mandriva.com/show_bug.cgi?id=44440

When displaying a window with a complex shape mask, kwin uses a lot of cpu and
seems to freeze for a big while. During this freeze, the system is unusable.

This is visible with firefox 3 drag 'n' drop effect, where a shaped window is
used to display the selected content following the mouse cursor. This effect is
reproducible using the attached test program.

Both metacity with compisiting enabled and compiz work fine with this pro


Steps to Reproduce:
1. Enable kwin compositing effects
2. Run the attached shape program
3. The system will freeze, and stay that way until the program shape is killed.
Actually, it may take a few minutes for the system to be usable again.
Comment 1 Ander Conselvan de Oliveira 2008-12-19 19:21:05 UTC
Created attachment 29455 [details]
Test program (Written by Gustavo Boiko)
Comment 2 Ed 2008-12-29 02:28:58 UTC
I can confirm this on KDE 4.2 Beta 2. This also happened on KDE 4.1 and 4.0. As mentioned, this only happens when desktop effects are enabled (no problem with Compiz on Intel 945GM).

It can be reproduced by dragging some text in Firefox 3. Dragging a single word is usually OK. As the number of dragged words is increased the lag becomes progressively worse and CPU goes to 100%. In KDE 4.1 the remedy was usually to completely power off the system. Since 4.2 the freeze is detected and the desktop effects are switched off, at which point everything returns to normal.

This bug was already reported but for some reason it was closed (Bug 166271)
Comment 3 Petr Mrázek 2009-01-10 12:27:43 UTC
I can confirm this one too.

I'm using KDE 4.1.87 with a radeon X800 card and the free radeon driver (v 6.9.0). My motherboard is based on the nForce2 chipset.

Device section from my xorg.conf:
Section "Device"
        Identifier  "Card0"
        Driver          "radeon"
#       # Options recommended on dri.freedesktop.org
        #Option     "AccelMethod"       "XAA"
        Option      "AccelMethod"       "EXA"
        Option      "RenderAccel"       "true"
        Option      "ColorTiling"       "true"
        Option      "AccelDFS"          "true"
        #Option     "DynamicClocks"     "true"
        Option      "DRI"               "true"
        Option      "GARTSize"          "64"
        Option      "EnablePageFlip"    "true"
#       #  Options recommended on dri.freedesktop.org
        Option "XAANoOffscreenPixmaps" "true"
EndSection
Comment 4 Karsten König 2009-01-18 16:39:07 UTC
*** Bug 181186 has been marked as a duplicate of this bug. ***
Comment 5 Karsten König 2009-01-18 16:44:14 UTC
(Info from duplicate bug report)

The errormessage from kwin is:
kwin(23210) KWin::checkGLError: GL error ( PostPaint ): 0x "502" 

using an integrated x4500mhd from intel


wstephenson could not reproduce on his nvidia card with binary driver
Comment 6 Martin Flöser 2009-01-18 17:34:03 UTC
I just tried the test program and I don't think it is causing a lot of CPU, but memory usage. At least when I succeeded in closing the test program again there were 1,5 GB of swap space used. I have 2 GB of RAM and the swap is almost never used. This would explain the behaviour: the system starts to swap resulting in the unusable system and after suspending compositing the system has to get the applications back into RAM resulting again in lot of I/O.

The test program is also causing the GL_INVALID_OPERATION errors (0x502). Those could be caused by an effects. I tried the program again with some effects disabled (fade, transluency, shadow) and I did not receive the errors. But I would not count on it as the behaviour of the system was more than bad.
Comment 7 Dave Taylor 2009-01-19 13:16:36 UTC
I get the same thing and it is reproducible every time when a chunk of text is selected in Firefox and then dragged and then the right mouse button is released. Kwin goes bananas slowing the machine to a crawl and eventually a pop up appears saying that my system is running too slow for Kwin effects so it has been disabled at which point the machine is usable again.

Pressing shift-alt-F12 after that has happened just makes the harddrive spin the system gets slower and then the system returns to normal but Kwin effects still don't switch on.

Going in to - 'System Settings' -> 'Desktop' shows the desktop effects checkbox is checked (Of course the effects are not actually enabled). So one unchecks the box presses apply and checks the box and presses apply and the effects start working again with the exception of the transparency on the panels.
Comment 8 lucas 2009-01-19 14:22:55 UTC
(In reply to comment #6)

My memory usage does not increase at all but I do get high CPU usage and slow compositing on nVidia 177.82 7800GT with all effects disabled.
Comment 9 Petr Mrázek 2009-01-19 14:29:41 UTC
Ok, I've got my hands on a new-ish motherboard and graphics card (nforce4 + 7600GT).
When I run htop in yakuake along with ff, it's clearly visible that kwin uses 100% CPU. There's no memory leak in my case. When I keep dragging the selection around after the effects shut down it flickers and eventually X dies.

Same thing happens when I drag around lots of icons from a Plasma folder view. Slowness -> effects shutdown -> flickering -> X dies.

When I start dragging with effects off, I get only the flicker - the dragged 'window' has white background that takes roughly half a second to go back to transparent when the 'window' moves. I can paint the whole desktop white and panels black this way. X doesn't die, there's only high CPU utilization.

All this with nvidia driver 180.22
Comment 10 Dave Taylor 2009-01-19 15:44:35 UTC
It's probably best to point out I am using an ATI card and the OSS driver so it isn't particular to a driver nor a piece of hardware.
Comment 11 Florian Eßer 2009-01-30 08:54:41 UTC
Same problem for me, also using ATI card (fglrx) and OSS driver
Comment 12 Michal Vyskocil 2009-01-30 10:14:04 UTC
kwin in 4.2 has detection of a slow composite and turn it off in that case. Reproducible always when I use drag and drop in Firefox.
Comment 13 Ruchir Brahmbhatt 2009-01-31 11:41:45 UTC
I can also reproduce in 4.2.
Comment 14 Viktor Rasmussen 2009-02-04 16:53:29 UTC
The problem is reproducible on Kubuntu 8.10 with Kde 4.2, Firefox 3.05, Nvidia binary driver 180.11. 
Comment 15 lucas 2009-02-05 04:22:48 UTC
*** Bug 166271 has been marked as a duplicate of this bug. ***
Comment 16 Giovanni Masucci 2009-02-05 22:10:38 UTC
happens with my intel gm945 too
Comment 17 Karsten König 2009-02-10 17:50:05 UTC
It's getting better (openSUSE KDE4.2 packages), it is not disabling the composite extension anymore and doesn't freeze, cpu usage jumps close to 100% though
Comment 18 Ruchir Brahmbhatt 2009-02-11 06:42:07 UTC
It still disables compositing with same platform here.
Comment 19 Martin Flöser 2009-04-18 16:20:21 UTC
*** Bug 189975 has been marked as a duplicate of this bug. ***
Comment 20 Ruchir Brahmbhatt 2009-07-06 16:06:46 UTC
I'm not able to reproduce on 4.3 rc1. Can someone confirm?
Comment 21 Jacob Welsh 2009-07-11 09:00:31 UTC
I also had this problem on 4.2.4, and it appears to be fixed in SVN.
Still rather sluggish to drag a lot of text, but not much worse than without compositing, and nothing slows to a crawl.

I'll try with firefox 3.5 shortly.
Comment 22 Viktor Rasmussen 2009-07-17 20:38:19 UTC
I can confirm. This bug seems to be gone in KDE 4.3 RC2
Comment 23 Martin Flöser 2009-07-17 20:52:41 UTC
(In reply to comment #22)
> I can confirm. This bug seems to be gone in KDE 4.3 RC2
Thanks for the info. Please reopen bug if anyone is still able to reproduce with 4.3.

I'm really glad that this bug is fixed, although I have no idea what actually fixed it.
Comment 24 Ed 2009-07-18 16:58:45 UTC
If you are testing with Firefox 3.5, it could be the case that Firefox 3.5 is no longer using shaped windows.
IIRC when I upgraded my Firefox to 3.5 the problem went away immediately without updating KDE.
Comment 25 Viktor Rasmussen 2009-07-18 18:00:54 UTC
I am using using Kubuntu 9.04 with Firefox 3.0.11 (and KDE 4.3 RC2 from ppa.launchpad.net) and the bug is gone. It seems to be the new KDE 4.3 that helped but I cannot say for sure
Comment 26 Jacob Welsh 2009-07-19 02:58:18 UTC
(In reply to comment #24)
> If you are testing with Firefox 3.5, it could be the case that Firefox 3.5 is
> no longer using shaped windows.

Correct, Firefox 3.5 uses composited transparency when available, and some hack when it's not, as opposed to complex shaped windows for text dragging (which had always been ugly and slow). Firefox 3.0.x was just a good test case for this kwin bug which does appear to be fixed.
Comment 27 Ruchir Brahmbhatt 2009-08-11 14:29:18 UTC
This issue has popped up again on kde 4.3.0 final and firefox 3.5.2. Should I reopen the bug?
Comment 28 Jacob Welsh 2009-08-12 00:39:57 UTC
(In reply to comment #27)
> This issue has popped up again on kde 4.3.0 final and firefox 3.5.2.

Not for me. (Arch Linux builds, intel gm965, x server 1.6.3, or svn builds on nvidia) Although it does appear that firefox 3.5.2 is back to using shaped windows for text when compositing is NOT active.

Are you sure it's the same problem - compositing enabled, firefox creates a shaped window for text dragging (the edges of the text would look jagged), kwin locks up when dragging a lot of text?
Comment 29 Ruchir Brahmbhatt 2009-08-12 12:43:58 UTC
Yes the text moves very slowly, looks jagged and compositing end up being disabled.

Intel Corporation Mobile GM965/GL960 Integrated Graphics Controller
X.Org X Server 1.5.2