Bug 393639 - Mouse cursor flicker when passing window borders
Summary: Mouse cursor flicker when passing window borders
Status: RESOLVED DUPLICATE of bug 424896
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 5.20.5
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL: https://phabricator.kde.org/D12631
Keywords:
: 447141 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-04-29 12:42 UTC by petrk
Modified: 2022-07-21 09:50 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:
mgraesslin: Wayland+
mgraesslin: X11-
mgraesslin: ReviewRequest+


Attachments
Explanation of my issue (358.81 KB, image/png)
2018-04-29 19:13 UTC, petrk
Details
potato quality proof (1.75 MB, video/webm)
2018-04-30 20:40 UTC, petrk
Details
better recording (867.26 KB, video/x-matroska)
2018-05-01 19:59 UTC, petrk
Details
debug info from plasmashell launched from tty with "WAYLAND_DEBUG=1" (1.14 MB, text/x-log)
2018-05-03 18:05 UTC, petrk
Details
Patch on top of https://phabricator.kde.org/D12631 (1.19 KB, patch)
2018-05-03 18:43 UTC, Martin Flöser
Details
logs after second patch (1.10 MB, text/x-log)
2018-05-03 19:58 UTC, petrk
Details

Note You need to log in before you can comment on or make changes to this bug.
Description petrk 2018-04-29 12:42:14 UTC
When mouse passes window-decoration border, or plasmashell bar and space above it there is a cursor flicker.

I was able to reproduce it before 5.12, just haven't bothered to report since wayland session had bigger problems for me then.
Comment 1 Martin Flöser 2018-04-29 15:41:27 UTC
Please explain "flicker"
Comment 2 petrk 2018-04-29 16:02:27 UTC
It looks like cursor is disappearing for few miliseconds.

Intel hadrware with modesetting driver.
Comment 3 Martin Flöser 2018-04-29 18:34:20 UTC
Which cursor theme, which cursor images are involved, which cursor sizes?
Comment 4 petrk 2018-04-29 19:12:46 UTC
Sorry, I shouldn't have been so brief on details.

Breeze, I need to force it to 24px since it's improperly set to 36px by part of applications.
Standard cursor image is the problem here. Basically it happens when cursor passes some borders between stuff. Explained more in attachment.
My resolution is 1600x900.

Can it be related to size misdetection?
Comment 5 petrk 2018-04-29 19:13:34 UTC
Created attachment 112311 [details]
Explanation of my issue
Comment 6 Martin Flöser 2018-04-29 19:40:13 UTC
the screenshot shows blender, which is rather "special". Does it also happen with other applications when going from window content to decoration? If yes with which one?

I want to understand the conditions.
Comment 7 petrk 2018-04-29 20:21:04 UTC
I have tried do be as diverse as possible: systemsettings, gnome-disks, yakuake, xsensors.

gnome-disks is not affected thanks csd, it has other problems caused by csd though...
yakuake is interesting, normal windows change cursor on borders for resizing, this one is locked in size and cursor does disappear for few ms when passing borders from each side.

Can I record plasmashell session or do I have to wait for portal/pipewire support to land, and then for OBS to catch up?
Comment 8 Patrick Silva 2018-04-29 23:28:40 UTC
I can reproduce the behavior described here on Arch Linux (plasma 5.12.4)

I just move the cursor from wallpaper to plasma panel. When entire cursor is finally on the panel, it blinks quickly (maybe 100 milliseconds).

I also use intel hd graphics and modesetting driver.
Comment 9 Martin Flöser 2018-04-30 17:22:29 UTC
I don't see the effects, but from implementation I know that there is a risk of a temporary non cursor set. If anyone would be able to record this (best external to not influence the system) that would be appreciated.
Comment 10 petrk 2018-04-30 20:40:25 UTC
Created attachment 112332 [details]
potato quality proof

Apologies for quality, my proper phone failed to make it noticeable, I had to record with a phone which doesn't properly focus at close while recording.
Cursor blinking is visible at the beginning, if proof is not conclusive then you can always listen to birds in background ;)
Comment 11 Martin Flöser 2018-04-30 21:12:57 UTC
Thanks. I guess I have to watch frame by frame. In that video I cannot notice it (doesn't surprise me, I also fail to notice small glitches or tearing)
Comment 12 Martin Flöser 2018-05-01 07:21:47 UTC
Just watched the video frame by frame. The cursor is always there, but sometimes a frame has a "weak" cursor. It looks like it's not completely solid. This might now be either the video not being a high speed camera and the cursor is in truth missing or some other effect that temporarily a different cursor is loaded. I assume it's the first.
Comment 13 Martin Flöser 2018-05-01 09:35:25 UTC
I might have a 1-line fix for the problem. If I attach a patch would someone be able to test it? Given that I have problems seeing the issue it might be helpful to have it validated by someone who notices this.
Comment 14 petrk 2018-05-01 12:21:36 UTC
Go ahead, I can test it for you.
Comment 15 Martin Flöser 2018-05-01 13:43:05 UTC
Patch at https://phabricator.kde.org/D12631
Comment 16 petrk 2018-05-01 19:59:19 UTC
Created attachment 112358 [details]
better recording

It doesn't seem to have an effect for me. However I have a treat for you. It also blinks in virtualbox, so I was able to record it with higher quality. Also recorded another bug there for lack of configuration.

neon dev-unstable from today
Comment 17 petrk 2018-05-02 22:05:27 UTC
Patched both 5.12.5 and master. No changes unfortunately. I will switch my desktop to nouveau to see if it's also affected.
Comment 18 Martin Flöser 2018-05-03 04:25:05 UTC
Does it neither work for the panel nor for the deco issue? I would have assumed it fixes for the panel and maybe for the deco.
Comment 19 petrk 2018-05-03 06:09:00 UTC
Problem persists on both.
Comment 20 Martin Flöser 2018-05-03 15:35:37 UTC
I start to think the problem is not in KWin. Could you please run Plasmashell with WAYLAND_DEBUG=1 and trigger the flicker?
Comment 21 petrk 2018-05-03 18:05:39 UTC
Created attachment 112393 [details]
debug info from plasmashell launched from tty with "WAYLAND_DEBUG=1"

I am attaching debug information.
What I've done during this session:
export WAYLAND_DEBUG=1
startplasmacompositor
After that I played around with plasma taskbar, after that I launched dolphin to play with decorations, then logout.
Comment 22 Martin Flöser 2018-05-03 18:42:30 UTC
We have here a sequence which I kind of expected:

[3931322,539] wl_pointer@15.enter(17, wl_surface@68, 622,000000, 2,000000)
[3931322,651]  -> wl_pointer@15.set_cursor(17, wl_surface@16, 4, 4)
[3931322,717]  -> wl_surface@16.attach(wl_buffer@50, 0, 0)
[3931322,757]  -> wl_surface@16.damage(0, 0, 32, 32)
[3931322,805]  -> wl_surface@16.commit()


Qt first sets the new cursor to surface 16, then attaches the buffer and commits the surface. This could result in KWin resetting the cursor. KWin reacts on the set_cursor call and if the surface has no buffer attached it will update cursor to invalid. It looks like everything is save here, but it's a potential risky area. I have to look up whether that's wrong in Qt or in KWin.

Anyway I did some more investigation and found another code path which could result in resetting the cursor. I'll attach a patch on top of the other patch.
Comment 23 Martin Flöser 2018-05-03 18:43:14 UTC
Created attachment 112394 [details]
Patch on top of https://phabricator.kde.org/D12631
Comment 24 petrk 2018-05-03 19:52:48 UTC
Ok, I applied your patch on top of previous one. Partial success, plasma taskbar stopped messing with cursor, it still happens on decoration/window border.
Comment 25 petrk 2018-05-03 19:58:00 UTC
Created attachment 112397 [details]
logs after second patch

Here are logs post patch, maybe something interesting in there for you.
Comment 26 Martin Flöser 2018-05-04 04:17:09 UTC
Good :-) we are getting closer.
Comment 27 petrk 2018-05-04 06:08:59 UTC
Just a small hint :) Flicker on decoration happens when moving mouse from decoration to window. It doesn't happen when I move mouse from window to decorations.
Comment 28 Martin Flöser 2018-05-04 15:16:34 UTC
(In reply to Piotr Kloc from comment #27)
> Just a small hint :) Flicker on decoration happens when moving mouse from
> decoration to window. It doesn't happen when I move mouse from window to
> decorations.

That's something I saw already in the video and also matches my expectation. Moving to the deco means KWin sets the cursor and there is no chance that this would miss a frame.
Comment 29 petrk 2018-05-06 19:27:22 UTC
Alright, I finally had time to test on my GTX 970 Nvidia system. There cursor doesn't misbehave.
Comment 30 Martin Flöser 2018-05-19 07:00:23 UTC
Git commit e3250460cc62800d706d02eda78e866efb12da55 by Martin Flöser.
Committed on 19/05/2018 at 06:58.
Pushed by graesslin into branch 'Plasma/5.12'.

Do not unset cursor image when cursor enters a surface

Summary:
>From Wayland documentation:
"When a seat's focus enters a surface, the pointer image is undefined and
a client should respond to this event by setting an appropriate pointer
image with the set_cursor request."

KWin's interpretation so far for the undefined pointer image was to
remove the pointer image when entering a surface waiting for the client
to set a cursor image. This can result in a short flicker as there might
be a frame without a cursor image.

This patch changes the behavior by keeping the previous image till the
application set a new one. This brings some advantages:
 * if the application is not responding a cursor is still shown
 * if the same cursor is used as in the previous window we don't have a
flicker

Test Plan: I cannot see the flicker, so only tested with the adjusted tests

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D12631

M  +7    -5    autotests/integration/pointer_input.cpp
M  +6    -7    autotests/integration/scene_qpainter_test.cpp
M  +9    -2    pointer_input.cpp

https://commits.kde.org/kwin/e3250460cc62800d706d02eda78e866efb12da55
Comment 31 twinshadows404 2020-12-14 22:53:27 UTC
I cannot reproduce this on 5.20.4 
Can someone else test to confirm?
Comment 32 Bug Janitor Service 2020-12-29 04:34:22 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 33 petrk 2021-01-08 17:50:14 UTC
Still an issue.
5.20.5 on Intel HD 4000 modesetting driver.
Moving cursor between titlebar and window content produces cursor flicker.
Comment 34 postix 2022-02-15 19:03:18 UTC
Sounds like a dup for me.

*** This bug has been marked as a duplicate of bug 447141 ***
Comment 35 twinshadows404 2022-02-15 20:05:14 UTC
Shouldn't the other be marked as a duplicate of this as it was reported 3 years later?
Comment 36 twinshadows404 2022-02-15 20:05:42 UTC
*** Bug 447141 has been marked as a duplicate of this bug. ***
Comment 37 dpanter 2022-02-24 15:50:01 UTC
Still seeing the issue with KDE 5.24.1 Wayland.
Using Siduction (Debian sid base) with Norbert Preinings KDE repo, RX6900XT/AMDGPU/Mesa-git 22.1
Really any mouse cursor change shows the flickering glitch. I believe #447797 is another duplicate of the same issue.
Comment 38 David Edmundson 2022-07-21 09:50:10 UTC

*** This bug has been marked as a duplicate of bug 424896 ***