Bug 462005 - Window shadow outlines have artifacts with fractional scale factors
Summary: Window shadow outlines have artifacts with fractional scale factors
Status: RESOLVED FIXED
Alias: None
Product: Breeze
Classification: Plasma
Component: window decoration (show other bugs)
Version: 5.27.10
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords: regression
: 468020 479866 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-11-18 18:43 UTC by Janet Blackquill
Modified: 2024-02-22 16:12 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.0


Attachments
screenshot of window with described bug (710.74 KB, image/png)
2022-11-18 18:43 UTC, Janet Blackquill
Details
HiDPI 175% scaling Wayland (26.34 KB, image/png)
2022-11-22 20:35 UTC, Derek Christ
Details
HiDPI 175% scaling Wayland (21.98 KB, image/png)
2022-11-22 20:36 UTC, Derek Christ
Details
HiDPI 200% scaling Wayland (26.34 KB, image/png)
2022-11-22 20:37 UTC, Derek Christ
Details
KDE Neon Unstable scaling 200% x11 (12.27 KB, image/png)
2022-12-03 14:15 UTC, Akseli Lahtinen
Details
Different scalings (155.69 KB, image/png)
2023-01-03 20:25 UTC, Derek Christ
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Janet Blackquill 2022-11-18 18:43:27 UTC
Window shadows have a visible gap on the top and left sides between the shadow and the window, as well as noticeable visible oddities on the corners.
Comment 1 Janet Blackquill 2022-11-18 18:43:51 UTC
Created attachment 153871 [details]
screenshot of window with described bug
Comment 2 Janet Blackquill 2022-11-18 18:44:30 UTC
Bisected to 8a91ef78d5069603369600ca1fc715f782d917fb.
Comment 3 Janet Blackquill 2022-11-18 18:52:51 UTC
Also, when maximised, the top border of windows flickers for a long while before becoming opaque. (No video because hardware can't handle screen capture at 4k at high enough FPS to illustrate the flickering)
Comment 4 Akseli Lahtinen 2022-11-18 18:55:00 UTC
Seems the outline coordinates do not scale well with HiDPI settings. Unfortunately I do not have HiDPI monitor, so I don't know if I can work on this.

And flickering sounds like it's drawing shadows very rapidly for some reason.
Comment 5 Derek Christ 2022-11-22 06:53:38 UTC
Can confirm, I have a HiDPI monitor with 175% scaling on Wayland and the outline doesn't look right.
Comment 6 Akseli Lahtinen 2022-11-22 07:14:31 UTC
Does the bug happen when using 200% scaling? Or does it only happen with 125%, 150% and 175%?
Comment 7 Derek Christ 2022-11-22 20:35:46 UTC
Created attachment 153948 [details]
HiDPI 175% scaling Wayland

From what I can tell, with 200% scaling, the artifact is less significant but can still be observed.
Looking at the border of a window from the inside to the outside, it first gets brighter, then darker and finally brighter again.

Added some screenshots.
Comment 8 Derek Christ 2022-11-22 20:36:34 UTC
Created attachment 153949 [details]
HiDPI 175% scaling Wayland
Comment 9 Derek Christ 2022-11-22 20:37:11 UTC
Created attachment 153950 [details]
HiDPI 200% scaling Wayland
Comment 10 Nate Graham 2022-11-30 02:42:45 UTC
> Unfortunately I do not have HiDPI monitor,

You can still test scaling without needing a High DPI monitor; just set the systemwide scale to 125% and live with everything being a bit bigger than normal while you investigate the bug. :)
Comment 11 Akseli Lahtinen 2022-11-30 19:40:33 UTC
(In reply to Nate Graham from comment #10)
> > Unfortunately I do not have HiDPI monitor,
> 
> You can still test scaling without needing a High DPI monitor; just set the
> systemwide scale to 125% and live with everything being a bit bigger than
> normal while you investigate the bug. :)

Oh, good to know! I will see if I can fix this issue or if it's somewhere else: I was thinking are shadows drawn wrong with higher scaling but it never showed up because they're less "in your face?"
Comment 12 Akseli Lahtinen 2022-12-03 14:14:36 UTC
I am unable to replicate the issue when using the KDE Neon Unstable inside VM. Could this have been a bug in somewhere else?
Comment 13 Akseli Lahtinen 2022-12-03 14:15:42 UTC
Created attachment 154266 [details]
KDE Neon Unstable scaling 200% x11

Added an image of the scaling in VM. As you can see the border looks normal.
Comment 14 Akseli Lahtinen 2022-12-03 14:19:36 UTC
.. Oops, my bad. I had X11 and not Wayland. :P In Wayland I can see the bug.
Comment 15 Akseli Lahtinen 2022-12-13 21:12:20 UTC
I managed to find the cause of the bug: https://invent.kde.org/plasma/breeze/-/blob/master/kdecoration/breezedecoration.cpp#L831

The QMarginsF is not being scaled properly by Wayland/Qt, or its the pen size itself. Check this part for possible causes why its happening: https://doc.qt.io/qt-5/qrectf.html#rendering

Basically the width of the pen changes -> its drawn differently on the rectangle, depending if the width is even or odd value.
If the pen could be changed to always draw outside of the rectangle, no matter what width, this might work better.

That, or make scale the value so that its always odd, no matter what the scaling setting is.
Comment 16 Akseli Lahtinen 2022-12-17 15:26:40 UTC
I think I have fixed it for 200% scaling, but fractional scaling has issues due to rendering to nearest integer size.

I'm afraid there is nothing else I can do until Plasma 6 / Qt 6. At least, I have no idea what to do. :(

Here's the commit I've done to fix the 200% scaling if you wish to give it a try however. I can't see the issue as prominent anymore, but I do not know for 100% if it's fixed.  

https://invent.kde.org/akselmo/breeze/-/commit/825d1e80863b96b10d36fa939bcbceb295ac126e
Comment 17 Akseli Lahtinen 2022-12-31 20:03:38 UTC
Could you please check if this works on the newer builds of KWin that have Wayland Fractional Scaling implemented?

I think I see less artifacts now, however I do believe I may have to change the shadow rectangles (which the outlines use) from using integers (QRect) to using floats (QRectF). This requires modifying KDecoration2.
Comment 18 Derek Christ 2023-01-03 20:25:45 UTC
Created attachment 155000 [details]
Different scalings

I tested with a fresh master build and then with the patch applied.

Unfortunately it looks like problem persists in all cases.
Comment 19 Nate Graham 2023-04-04 19:47:31 UTC
*** Bug 468020 has been marked as a duplicate of this bug. ***
Comment 20 Akseli Lahtinen 2023-12-19 10:19:06 UTC
Can't reproduce on Plasma 6 anymore after this merge request: https://invent.kde.org/plasma/kwin/-/merge_requests/4793

Tested on 125% and 150% scaling.
Comment 21 Nate Graham 2023-12-20 19:22:27 UTC
I can confirm that the issue is now fixed for me as well!
Comment 22 Luca Carlon 2023-12-20 20:29:59 UTC
Can the fix be backported?
Comment 23 Nate Graham 2023-12-20 20:55:18 UTC
In addition to the fact that no more Plasma 5 bugfix releases are planned, KWin's code has changed enough between Plasma 5 and 6 as to make a backport laborious and risky. So I suspect not.
Comment 24 Luca Carlon 2023-12-20 23:44:28 UTC
Any way to, at least, hide it? It is of no practical use, so hiding it is perfectly acceptable. At least users will not remain with a broken feature for many other months.
Comment 25 Nate Graham 2023-12-21 00:22:26 UTC
There's a setting to hide it in Plasma 6.
Comment 26 Luca Carlon 2023-12-21 08:09:24 UTC
Hiding it would be useful for the systems where it is broken. Would it be possible to hide the broken feature for Plasma5, which is still what users will use for several months? For instance, would it be possible to simply not draw it when scaling != 1? I do not think users will complain for a missing broken feature.
Comment 27 Nate Graham 2024-01-09 22:27:20 UTC
At this point no further Plasma 5 releases are planned, so I don't think so, sorry.
Comment 28 Nate Graham 2024-01-17 15:40:05 UTC
*** Bug 479866 has been marked as a duplicate of this bug. ***
Comment 29 Nate Graham 2024-01-17 22:55:43 UTC
Unfortunately I can still reproduce the issue at 112%, 125%, and 150% scale on a 1080p screen. Interestingly, I cannot reproduce it using 1225% or 250% scale factors on a 4k screen.
Comment 30 Akseli Lahtinen 2024-01-24 21:55:04 UTC
Git commit 6171b3feeabb0860f5b19980e4a302a5a80ee64c by Akseli Lahtinen.
Committed on 24/01/2024 at 22:55.
Pushed by akselmo into branch 'master'.

Move outline drawing to Decoration::paint

Instead of drawing window outline in the shadow drawcall, draw it on top of border instead.

This helps keeping the outline size in sync with the window size and has less glitches.

Also moved shadow a tiny bit under the window, so it wont snap from next of the window when using fractional scaling.

Should at the very least alleviate the issues, if not fix them all.

M  +54   -59   kdecoration/breezedecoration.cpp
M  +7    -1    kdecoration/breezedecoration.h

https://invent.kde.org/plasma/breeze/-/commit/6171b3feeabb0860f5b19980e4a302a5a80ee64c
Comment 31 Bug Janitor Service 2024-01-24 22:17:34 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/breeze/-/merge_requests/412
Comment 32 Akseli Lahtinen 2024-01-24 22:43:37 UTC
Git commit ff0635d876a00754d3ce421a40a91ae7c24b0738 by Akseli Lahtinen.
Committed on 24/01/2024 at 23:16.
Pushed by akselmo into branch 'Plasma/6.0'.

Move outline drawing to Decoration::paint

Instead of drawing window outline in the shadow drawcall, draw it on top of border instead.

This helps keeping the outline size in sync with the window size and has less glitches.

Also moved shadow a tiny bit under the window, so it wont snap from next of the window when using fractional scaling.

Should at the very least alleviate the issues, if not fix them all.


(cherry picked from commit 6171b3feeabb0860f5b19980e4a302a5a80ee64c)

M  +54   -59   kdecoration/breezedecoration.cpp
M  +7    -1    kdecoration/breezedecoration.h

https://invent.kde.org/plasma/breeze/-/commit/ff0635d876a00754d3ce421a40a91ae7c24b0738
Comment 33 Nate Graham 2024-02-22 16:12:43 UTC
Fixed for Plasma 6.0.1 with the commits in https://invent.kde.org/plasma/kdecoration/-/merge_requests/56 and https://invent.kde.org/plasma/breeze/-/merge_requests/416, but only for Breeze.

In Plasma 6.1, we're going to try to come up with something more comprehensive that works for everything.