Bug 485734

Summary: With old Intel GPU, saved items randomly appear empty when hovered
Product: [Plasma] plasmashell Reporter: medin <med.medin.2014>
Component: Clipboard widget & pop-upAssignee: Plasma Bugs List <plasma-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: kdedev, nate
Priority: NOR    
Version First Reported In: 6.0.4   
Target Milestone: 1.0   
Platform: Other   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=478165
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: image1
image2
image3

Description medin 2024-04-18 13:18:39 UTC
Created attachment 168641 [details]
image1

When I scroll down in Klipper applet, some items when highlighted appear empty. Those empty items are randomly selected upon each opening.
Comment 1 medin 2024-04-18 13:19:33 UTC
Created attachment 168642 [details]
image2
Comment 2 medin 2024-04-18 13:20:25 UTC
Created attachment 168643 [details]
image3
Comment 3 Nate Graham 2024-08-16 16:27:40 UTC
Cannot reproduce. However I do have a theory regarding what's happening: the highlight effect applies a graphical effect to the text (which also causes Bug 478165) and I suspect that under certain circumstances it gets broken on certain GPUs and causes this issue.

Long term, we may want to just remove the fancy effect to improve reliability and perceived bugginess here.

What's your GPU hardware?
Comment 4 medin 2024-08-19 09:34:40 UTC
(In reply to Nate Graham from comment #3)
> Cannot reproduce. However I do have a theory regarding what's happening: the
> highlight effect applies a graphical effect to the text (which also causes
> Bug 478165) and I suspect that under certain circumstances it gets broken on
> certain GPUs and causes this issue.
> 
> Long term, we may want to just remove the fancy effect to improve
> reliability and perceived bugginess here.
> 
> What's your GPU hardware?

I only have laptops with Intel iGPU.
Comment 5 Nate Graham 2024-08-20 21:12:12 UTC
Me too, mine is 10th Gen, Intel HD 630. What's yours?
Comment 6 medin 2024-08-21 20:25:36 UTC
(In reply to Nate Graham from comment #5)
> Me too, mine is 10th Gen, Intel HD 630. What's yours?

i3-5005u,  i3-1005g1  and  T4400.
Comment 7 Nate Graham 2024-08-30 23:56:21 UTC
Thanks. So older hardware. That could be related, or I might be off base and it's something else.

Can you test a patch? Find the file ClipboardItemDelegate.qml on your system (on mine it's located at /usr/share/plasma/plasmoids/org.kde.plasma.clipboard/contents/ui/ClipboardItemDelegate.qml) and make the following changes to it:

@@ -113,7 +113,7 @@ PlasmaComponents.ItemDelegate {
         anchors.fill: label
         cached: true
         maskSource: labelMaskSource
-        visible: !!source && menuItem.ListView.isCurrentItem
+        visible: false
 
         TapHandler {
             enabled: !(toolButtonsLoader.item as DelegateToolButtons)?.hovered // https://bugreports.qt.io/browse/QTBUG-108821
@@ -126,7 +126,6 @@ PlasmaComponents.ItemDelegate {
     QQC.Control {
         id: label
         height: implicitHeight
-        visible: !menuItem.ListView.isCurrentItem
         anchors {
             left: parent.left
             leftMargin: Math.ceil(Kirigami.Units.gridUnit / 2) - menuItem.listMargins.left

Save the file, authenticate, then restart either plasmashell or the system.

If that fixes the issue, then it's a glitch in the graphical gradient effect, and I suspect it'll end up being a Qt bug unfortunately.
Comment 8 medin 2024-08-31 12:50:26 UTC
(In reply to Nate Graham from comment #7)
> If that fixes the issue, then it's a glitch in the graphical gradient
> effect, and I suspect it'll end up being a Qt bug unfortunately.

I added those two changes and restarted plasmashell, for now all labels become visible, but those tools buttons are shown overlapping with the text under them.

I suspect there is some error in that gradient which force it to be applied to all label's width, or something elsewhere that makes the current selected label invisible.

I never wrote qml code, but when I added inside onActiveChanged the following line to track the real value of gradientThreshold:
console.log("gradientThreshold: ", (label.width - toolButtonsLoader.width) / label.width);
it prints some real numbers but sometimes returns NaN.
Comment 9 Nate Graham 2024-09-03 19:17:32 UTC
Thanks, that's helpful. I suspect that the label sometimes briefly has a width of zero.

Can you test this change locally and see if it fixes the issue for you?

--- klipper/declarative/qml/ClipboardItemDelegate.qml
+++ klipper/declarative/qml/ClipboardItemDelegate.qml
@@ -33,7 +33,7 @@ PlasmaComponents.ItemDelegate {
     property alias mainItem: label.contentItem
 
     property int maximumNumberOfPreviews: Math.floor(width / (Kirigami.Units.gridUnit * 4 + Kirigami.Units.smallSpacing))
-    readonly property real gradientThreshold: (label.width - toolButtonsLoader.width) / label.width
+    readonly property real gradientThreshold: (width - toolButtonsLoader.width) / width
     // Consider tall to be > about 1.5x the default height for purposes of top-aligning
     // the buttons to preserve Fitts' Law when deleting multiple items in a row,
     // or else the top-alignment doesn't look deliberate enough and people will think
Comment 10 medin 2024-09-10 09:46:58 UTC
(In reply to Nate Graham from comment #9)
> Thanks, that's helpful. I suspect that the label sometimes briefly has a
> width of zero.
> 
> Can you test this change locally and see if it fixes the issue for you?
> 
> --- klipper/declarative/qml/ClipboardItemDelegate.qml
> +++ klipper/declarative/qml/ClipboardItemDelegate.qml
> @@ -33,7 +33,7 @@ PlasmaComponents.ItemDelegate {
>      property alias mainItem: label.contentItem
>  
>      property int maximumNumberOfPreviews: Math.floor(width /
> (Kirigami.Units.gridUnit * 4 + Kirigami.Units.smallSpacing))
> -    readonly property real gradientThreshold: (label.width -
> toolButtonsLoader.width) / label.width
> +    readonly property real gradientThreshold: (width -
> toolButtonsLoader.width) / width
>      // Consider tall to be > about 1.5x the default height for purposes of
> top-aligning
>      // the buttons to preserve Fitts' Law when deleting multiple items in a
> row,
>      // or else the top-alignment doesn't look deliberate enough and people
> will think


Sorry I was away from home for several days, I tested your suggestion but it didn't change the result.

I changed the gradient colors to red and green and forced it to be always visible, and it seems to render perfectly.

I also forced the visibility of the label and it always appears fine.

The problem is surely coming from these two boolean checks:

Item
visible: !menuItem.ListView.isCurrentItem

OpacityMask
 visible: !!source && menuItem.ListView.isCurrentItem

"isCurrentItem" is crazily jumping between "false" and "true", it holds "true" only for certain cases if I scroll via mouse wheel or reenter a previously highlighted item, the same for that "source" it always holds "undefined" when I move mouse pointer over never highlighted items.
Comment 11 Nate Graham 2025-04-08 19:29:49 UTC
There were a number of changes to relevant code recently. Can you check again in Plasma 6.3 or later and see if this is still happening?

If so, it would also be great to learn if it's happening to you only on X11, only on Wayland, or both.

Thanks a lot!
Comment 12 medin 2025-04-09 12:34:12 UTC
(In reply to Nate Graham from comment #11)
> There were a number of changes to relevant code recently. Can you check
> again in Plasma 6.3 or later and see if this is still happening?
> 
> If so, it would also be great to learn if it's happening to you only on X11,
> only on Wayland, or both.
> 
> Thanks a lot!


It's still happening on Plasma 6.3.4 both on Wayland and X11.
Comment 13 Nate Graham 2025-04-09 16:20:00 UTC
Darn. Thanks for checking.
Comment 14 medin 2025-08-29 12:03:27 UTC
It seems to be fixed for now, I tested on two laptops running Wayland with Plasma 6.4.4 and those empty items are not appearing again.