tcorreabr / Parachute

Look at your windows and desktops from above.
GNU General Public License v3.0
356 stars 32 forks source link

Laggy KWin after installing script #68

Closed Kodehawa closed 3 years ago

Kodehawa commented 3 years ago

Seems like 0.9.0 makes KWin (lowlatency, and KWinFT) run really laggy after installation. It's noticeably choppy, and stuff like Yet Another Magic Lamp's animation get funky. This is not noticeable at 60Hz, but at 144Hz it's horrible as it makes the fps constantly jump around.

Disabling the script fixes it all for me, so it's definitely something to do with the script. 0.8 is fine.

Is there something that runs on the background while the viewport is not active?

If you need anything just tell me. Thanks!

P.S: Great script :D

tcorreabr commented 3 years ago

Seems like 0.9.0 makes KWin (lowlatency, and KWinFT) run really laggy after installation. It's noticeably choppy, and stuff like Yet Another Magic Lamp's animation get funky.

Does this happen with classic KWin or only with lowlatency and KWinFT versions?

Is there something that runs on the background while the viewport is not active?

No, this seems more like some kind of conflict on gpu access.

If you need anything just tell me. Thanks!

Since this doesn't happen on my pc, I'll depend a lot on your help to find out what's happening. What is your distribution, cpu and gpu models?

tcorreabr commented 3 years ago

Can you delete (or comment) a line in the file ~/.local/share/kwin/scripts/Parachute/contents/ui/ClientComponent.qml with the content "renderTarget: KWinComponents.ThumbnailItem.FramebufferObject" and see if that solves the problem?

EDIT: run kwin_x11 --replace & after editing the file.

Kodehawa commented 3 years ago

Does this happen with classic KWin or only with lowlatency and KWinFT versions?

I only really tested it with lowlatency and KWinFT. KWin uses a timer for VSync while KWinFT and KWin lowlatency try to use the GPU itself. Might be why?

Since this doesn't happen on my pc, I'll depend a lot on your help to find out what's happening. What is your distribution, cpu and gpu models?

Arch, Ryzen 5 2600, RX 480

Can you delete (or comment) a line in the file ~/.local/share/kwin/scripts/Parachute/contents/ui/ClientComponent.qml with the > content "renderTarget: KWinComponents.ThumbnailItem.FramebufferObject" and see if that solves the problem?

EDIT: run kwin_x11 --replace & after editing the file.

Nope :(

Video of the issue

qdbus org.kde.KWin /KWin supportInformation

It's honestly not that noticeable in a video, but you can tell the cursor is lagging way behind the window with the script enabled, and with it disabled it works fine. For what I can tell, VSync on both KWinFT and lowlatency break, which makes it look way laggier.

tcorreabr commented 3 years ago

Yes, I can see the difference.

I saw that you use two monitors with different refresh rates, maybe that is the cause of the problem? I also use two monitors, but both at 60Hz.

Kodehawa commented 3 years ago

I saw that you use two monitors with different refresh rates, maybe that is the cause of the problem?

Could be. Yeah, it's 144Hz + 60Hz, that's why I use KWin lowlatency or KWinFT usually, since those actually render better with this kinda combination :)

tcorreabr commented 3 years ago

A test that could be done is to run the script in classic KWin, to see if the problem is related to the lowlatency or KWinFT changes.

Kodehawa commented 3 years ago

Maybe. The VSync mechanism on both lowlatency and KWinFT is different. I'll give it a test in a little :)

You could test lowlatency aswell to see if it breaks for you, maybe I'm not the only one.

EDIT: Vanilla KWin itself is quite laggy for me, but the script definitely makes it laggier and choppier, but I can't notice it as much.

tcorreabr commented 3 years ago

I installed lowlatency and although it didn't make much sense I found the animations a little more laggy.

Kodehawa commented 3 years ago

KWin lowlatency really only changes how VSync works, among other minor rendering stuff (like latency controls). I wonder if something breaks GPU VSync? not sure what could break it

Though, for me it's also a little laggier on normal KWin, but not as noticeable. The thing is that at 60Hz it's just about barely noticeable, but at 144Hz it feels really bad.

tcorreabr commented 3 years ago

Ok, can you try one more thing? Insert a line with the following content just below the line with "id: screenItem" in the file ~/.local/share/kwin/scripts/Parachute/contents/ui/ScreenComponent.qml:

enabled: mainWindow.activated

This will disable almost everything from Parachute when offscreen.

Kodehawa commented 3 years ago

Huh. Still very, very laggy.

image I did it like this and ran kwin_x11 --replace. Seems like #72, #71 and #77 are related. I can reproduce all of them.

tcorreabr commented 3 years ago

I installed a game and I can see the fps drop now. At least it's a step to solve the problem. As soon as I fix it I should release a new version 0.9.1.

tcorreabr commented 3 years ago

Well, it seems that if you use visible: mainWindow.activated instead of enabled: mainWindow.activated the problem is solved. At least in case of fps drop in games (#72). As for the other issues reporting lag in KWin (this one, #71 and #77) I need feedback from you guys because they don't happen on my pc.

Kodehawa commented 3 years ago

That works. Yep :)

tcorreabr commented 3 years ago

Did this solve all the mentioned issues for you?

I already used this line in the code and it had some side effect that I don't remember now. So I'll perform some tests before releasing the new version.

Kodehawa commented 3 years ago

It did solve it to me, I haven't found any issues really, but who knows.

It's weird that something harms performance that much though. As in, the script uses quite a lot of resources when running. Well, and before it also did when it wasn't running :P

Kodehawa commented 3 years ago

With Parachute open, KWin's CPU usage goes from 1% to 50~100% (out of 1200%). Not too much, but it's still sizable. I guess it's because of thumbnail gen?

It also uses a single core but I guess that's just how scripts work. image image

tcorreabr commented 3 years ago

Thumbnails, transparencies, blur, shadows of desktops and other visual effects. All this comes at a cost.

Compared to KWin Present Window and Desktop Grid effects (written in C++) for example, the fps drop when they are activated is minimal. Parachute is definitely not for old machines.

Kodehawa commented 3 years ago

It wasn't like this on 0.8 and it blurred, generated thumbnails, transparency and all for sure :P

0.9 is way slower, and uses way (by way I mean 100% of one core) more resources than 0.8. It's nicer, though, and with the stuff you told me to use at least it only does it when opened, so that's fine for me.

trmdi commented 3 years ago

Whenever I try this script, it is not laggy at first, but only after using it for a while, the lag comes. So there could be some memory leak or something like that.

blaster9786 commented 3 years ago

Whenever I try this script, it is not laggy at first, but only after using it for a while, the lag comes. So there could be some memory leak or something like that.

I have the same problem and I had it also on version 0.8 0.9. The lags usually start after a while and if I deactivate the parachute kwin script they stop immediately. Strange thing is that system monitor doesn't show any high CPU/RAM usage..

Edit: I had written the wrong version, sorry