Bug 431415 - Maximize animation does not work on Wayland
Summary: Maximize animation does not work on Wayland
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: aurorae (show other bugs)
Version: git master
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-11 01:08 UTC by David Rubio
Modified: 2021-01-15 15:43 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
vlad.zahorodnii: Wayland+
vlad.zahorodnii: X11-


Attachments
qdbus org.kde.KWin /KWin supportInformation (6.46 KB, text/plain)
2021-01-11 01:12 UTC, David Rubio
Details
kwinrc (1.18 KB, text/plain)
2021-01-14 20:55 UTC, David Rubio
Details
hotspot (417.17 KB, image/png)
2021-01-15 07:26 UTC, Vlad Zahorodnii
Details
ftrace (168.06 KB, image/png)
2021-01-15 08:21 UTC, Vlad Zahorodnii
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Rubio 2021-01-11 01:08:51 UTC
SUMMARY
Maximize animation does not work when using Aurorae themes on Wayland.
Switching to Breeze makes it work properly again.

STEPS TO REPRODUCE
1. Switch to an Aurorae theme
2. Minimize/Maximize a window a few dozen times

OBSERVED RESULT
The animation plays rarely, and most of the times it doesn't play at all. This was tested with the Qogir Aurorae theme and Plastik.

EXPECTED RESULT
The Maximize animation should play 100% of the times.

SOFTWARE/OS VERSIONS
Linux: 
KDE Plasma Version: 5.20.80 (plasma-desktop git)
KDE Frameworks Version: 5.79
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Built from git master today. Everything from KWin down to plasma-desktop is built from master. Commit built on plasma-desktop is a274b24e29feebdfac16d7ae262a21cf14710896, commit built on KWin is 68a7daff58a4f34c48f0cb23ed0b49d04d255934
Comment 1 David Rubio 2021-01-11 01:12:14 UTC
Created attachment 134725 [details]
qdbus org.kde.KWin /KWin supportInformation
Comment 2 David Rubio 2021-01-11 01:12:32 UTC
Video of the issue: https://www.youtube.com/watch?v=HS4vYuRlL1I
Comment 3 David Rubio 2021-01-11 01:13:58 UTC
If you try to replicate this issue, this *might* work sometimes, then out of nowhere the effect will stop playing completely, then start again. Try using your computer for 10 minutes or so with an Aurorae theme on Wayland, and you ought to hit it.
Comment 4 Vlad Zahorodnii 2021-01-11 07:48:57 UTC
Cannot reproduce.

I wonder if kwin has a huge frame drop. Can you reduce the animation speed in the system settings?
Comment 5 David Rubio 2021-01-11 14:37:04 UTC
(In reply to Vlad Zahorodnii from comment #4)
> Cannot reproduce.
> 
> I wonder if kwin has a huge frame drop. Can you reduce the animation speed
> in the system settings?

I tried the minimum speed and the minimize animation still only played around 1/4th of the times I tried. 

There's a lot of frame drops on KWin Wayland master, but this doesn't seem to be a frame drop here, as even with the minimum animation speed the minimize animation is instant. Thing is, like one in 10 times it would *actually* play, so I know it's *active*.

This does NOT happen with Breeze, so for me it looks to be Aurorae-specific, but I could repro it with basically any aurorae theme, all the time. 

I tried on 5.20.5 and the maximize animation plays fine 100% of the times.
Comment 6 David Rubio 2021-01-11 14:38:40 UTC
Also for CSD windows it also plays 100% of the times. It's only when the window is decorated by Aurorae.
Comment 7 David Rubio 2021-01-11 14:50:23 UTC
(In reply to David Rubio from comment #5)
> (In reply to Vlad Zahorodnii from comment #4)
> > Cannot reproduce.
> > 
> > I wonder if kwin has a huge frame drop. Can you reduce the animation speed
> > in the system settings?
> 
> I tried the minimum speed and the minimize animation still only played
> around 1/4th of the times I tried. 
> 

I put the animation at the slowest notch. Besides systemsettings5 crashing inmediatly after that (report coming...) the animation definitely wasn't playing. Sometimes it would, and it would be unsufferably slow (as you would expect from it being set at the slowest speed), but when it didn't play Maximize was instant.
Comment 8 David Rubio 2021-01-13 15:26:30 UTC
Reverting:
kwayland-server: f67daa0711584058a8fefda76e898fe58d53ace7
kwin: 26b249061ee49dacc29320f93984de3d35012e1f

to those commit hashes makes this issue dissapear.
Comment 9 Vlad Zahorodnii 2021-01-14 07:20:00 UTC
The problem is that aurorae decoration engine is inefficient. KWin gets the data from a texture where Aurorae composites the decoration and uploads it to another decoration texture atlas. Performance-wise, that's not good. By delaying compositing, we just made it more easier to miss the next vblank. Perhaps, we should increase the latency policy to "extremely high" to work around this bug until the performance hog is properly fixed.
Comment 10 Bug Janitor Service 2021-01-14 08:38:10 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/589
Comment 11 David Rubio 2021-01-14 20:09:03 UTC
(In reply to Vlad Zahorodnii from comment #9)
> The problem is that aurorae decoration engine is inefficient. KWin gets the
> data from a texture where Aurorae composites the decoration and uploads it
> to another decoration texture atlas. Performance-wise, that's not good. By
> delaying compositing, we just made it more easier to miss the next vblank.
> Perhaps, we should increase the latency policy to "extremely high" to work
> around this bug until the performance hog is properly fixed.

I did set it to extremely high (well, as high as it went), and the problem is still there, just less so. It's just really annoying, but I don't think that much people use Aurorae, thankfully? :P

I just can't live without the theme I've used for so many years, but that's me.
Comment 12 David Rubio 2021-01-14 20:10:01 UTC
(In reply to David Rubio from comment #11)
> (In reply to Vlad Zahorodnii from comment #9)
> > The problem is that aurorae decoration engine is inefficient. KWin gets the
> > data from a texture where Aurorae composites the decoration and uploads it
> > to another decoration texture atlas. Performance-wise, that's not good. By
> > delaying compositing, we just made it more easier to miss the next vblank.
> > Perhaps, we should increase the latency policy to "extremely high" to work
> > around this bug until the performance hog is properly fixed.
> 
> I did set it to extremely high (well, as high as it went), and the problem
> is still there, just less so. It's just really annoying, but I don't think
> that much people use Aurorae, thankfully? :P
> 
> I just can't live without the theme I've used for so many years, but that's
> me.

Weirdly enough, double-clicking the titlebar plays the animation just fine 90% of the times, but clicking the "maximize" button barely plays it at all. Dunno what sort of difference that'd even make.
Comment 13 Vlad Zahorodnii 2021-01-14 20:39:20 UTC
Okay, I closed the merge request. I wonder if switching to the cubic easing curve has something to do with this "bug." (kwin drops a lot of frames because aurorae is inefficient). In Plasma <= 5.20.x, the maximize effect uses the linear easing curve, while in 5.21.x, it is going to use the cubic easing curve.
Comment 14 David Rubio 2021-01-14 20:46:16 UTC
I find it really weird that the animation works only if I double click the titlebar, but clicking the maximize button does absolutely nothing.

I tried reverting the cubic animation curve and that didn't do it either.

Video: https://youtu.be/9prO3kiB6-w
Comment 15 Vlad Zahorodnii 2021-01-14 20:48:52 UTC
On my machine, the maximize animation is choppy no matter where I click.
Comment 16 David Rubio 2021-01-14 20:50:18 UTC
(In reply to Vlad Zahorodnii from comment #15)
> On my machine, the maximize animation is choppy no matter where I click.

The animation is definitely choppy even when double-clicking. When I click the maximize button the animation outright doesn't play at all for some cursed reason (setting it to the slowest animation speed notch still plays it instantly instead of it taking forever). I'd blame the theme but it works before 507.
Comment 17 Vlad Zahorodnii 2021-01-14 20:53:03 UTC
> setting it to the slowest animation speed notch still plays
Make sure that you don't have AnimationDurationFactor in your kwinrc file.
Comment 18 David Rubio 2021-01-14 20:55:50 UTC
Created attachment 134863 [details]
kwinrc

(In reply to Vlad Zahorodnii from comment #17)
> > setting it to the slowest animation speed notch still plays
> Make sure that you don't have AnimationDurationFactor in your kwinrc file.

I don't. I'm attaching my kwinrc. Anything odd in here?
Comment 19 Vlad Zahorodnii 2021-01-15 07:25:20 UTC
I don't see anything suspicious in your kwinrc file.
Comment 20 Vlad Zahorodnii 2021-01-15 07:26:39 UTC
Created attachment 134879 [details]
hotspot

When I maximize/restore a window, kwin spends a reasonable amount of time decoding png images. This is odd...
Comment 21 Vlad Zahorodnii 2021-01-15 07:30:29 UTC
I use the following https://store.kde.org/p/1191690/ aurorae theme.
Comment 22 Vlad Zahorodnii 2021-01-15 08:21:24 UTC
Created attachment 134881 [details]
ftrace

The first 100-150ms of the maximize animation are very crucial, but it looks like kwin spends most of that time updating the contents of the aurorae decoration.
Comment 23 David Edmundson 2021-01-15 11:28:52 UTC
This is interesting:

11:27:17.632 Plasma::FrameItemNode::updateTexture QSize(1392, 1011) "decoration-center" 1


It's rendering the middle of the frame (the part that no-one can see) at absolutely massive resolutions, with the slowest of all 3 FrameSVGItemNode paths.
Comment 24 David Edmundson 2021-01-15 11:36:45 UTC
Turns out the center is still visible slightly in the top. We can't just disable it.

It's fixable with a oneline in the theme, adding an element with the ID hint-tile-center. I can't think of any super easy fix plasma side.
Comment 25 Vlad Zahorodnii 2021-01-15 13:27:15 UTC
Git commit 2d1994e06691e79c4754d60634fb5c8b3e9f4e02 by Vlad Zahorodnii.
Committed on 15/01/2021 at 13:26.
Pushed by vladz into branch 'master'.

aurorae: Make direct connection to maximizedChanged signal

If the maximizedChanged connection is queued, several configure events
will be sent. If the client acks the first configure event and later on
acks the second one, the maximize animation will be cancelled due to
"unexpected" geometry change.

Based on the code, there is no clear reason why the connection is queued
in the first place.

M  +1    -1    plugins/kdecorations/aurorae/src/aurorae.cpp

https://invent.kde.org/plasma/kwin/commit/2d1994e06691e79c4754d60634fb5c8b3e9f4e02
Comment 26 Vlad Zahorodnii 2021-01-15 13:29:20 UTC
@David Rubio Can you please check whether 2d1994e0669 made things better?
Comment 27 David Rubio 2021-01-15 14:13:43 UTC
(In reply to Vlad Zahorodnii from comment #26)
> @David Rubio Can you please check whether 2d1994e0669 made things better?

It fixes it for me. Also the maximize animation is way smoother for some weird reason.

But yeah, that fixed the issue for what I could test (by spamming the maximize button like 30 times)
Comment 28 David Rubio 2021-01-15 14:41:06 UTC
(In reply to David Edmundson from comment #24)
> Turns out the center is still visible slightly in the top. We can't just
> disable it.
> 
> It's fixable with a oneline in the theme, adding an element with the ID
> hint-tile-center. I can't think of any super easy fix plasma side.

Would that element have to be empty or does it need to contain something?
Comment 29 David Edmundson 2021-01-15 15:27:06 UTC
Best answer is to copy plasma-framework/  dialogs/background.svg


It has 

    <rect
       style="opacity:1;fill:#ff6600;fill-opacity:1;stroke:none"
       id="hint-tile-center"
       width="5"
       height="5"
       x="0"
       y="904.36218" />

But ultimately we're just looking for any element matching the ID.
Comment 30 Vlad Zahorodnii 2021-01-15 15:29:09 UTC
(In reply to David Rubio from comment #27)
> It fixes it for me. Also the maximize animation is way smoother for some
> weird reason.
> 
> But yeah, that fixed the issue for what I could test (by spamming the
> maximize button like 30 times)

Thanks, that's great. I'll create a generic bug report to track performance issues in Aurorae and close this one.
Comment 31 David Rubio 2021-01-15 15:42:54 UTC
(In reply to Vlad Zahorodnii from comment #30)
> (In reply to David Rubio from comment #27)
> > It fixes it for me. Also the maximize animation is way smoother for some
> > weird reason.
> > 
> > But yeah, that fixed the issue for what I could test (by spamming the
> > maximize button like 30 times)
> 
> Thanks, that's great. I'll create a generic bug report to track performance
> issues in Aurorae and close this one.

Thanks you very much.