Bug 450911 - Buggy touchpad/touch screen behaviour "2 in 1" convertible laptop + partial fix
Summary: Buggy touchpad/touch screen behaviour "2 in 1" convertible laptop + partial fix
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: libinput (show other bugs)
Version: 5.24.3
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 453161 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-02-27 07:22 UTC by PK
Modified: 2022-09-10 13:47 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
this bar I mean, at the top of the screen (3.83 MB, image/jpeg)
2022-03-03 18:20 UTC, PK
Details
output of "journaldctl -b -1" (345.82 KB, text/plain)
2022-05-06 06:45 UTC, PK
Details
part where the word "crash" appears a lot. To view quickly (895.76 KB, image/jpeg)
2022-05-06 06:48 UTC, PK
Details
line 3075-3150 of "journaldctl -b -1" in text (11.05 KB, text/plain)
2022-05-06 06:52 UTC, PK
Details

Note You need to log in before you can comment on or make changes to this bug.
Description PK 2022-02-27 07:22:22 UTC
SUMMARY
***
I work on a Surface Pro 3. When I work with Plasma, after a while I suddenly always loose control over the touchpad and even mouse cursor click.
There is always a strange phenomenon that precedes this crash. That can be a configuration bar coming unexpectedly from the top of my screen, the window sticking to my pointer or even other things.
Directly after that I can't use the touchpad no more. That is to say: I can move the pointer but no more than that. No clicking, dragging etc.
Because I'm no more than an enthusiastic user I had to guess the "product" for this bug.
Strange thing is that this never occurs on Ubuntu - the second system on this machine. So I guess it is Plasma-related.
It is not that I WANT to make this Surface Pro 3 work with Plasma because I cope with Ubuntu. But I hope to help make plasma more robust perhaps also in other hardware configurations.
If there is something I can do to help (send some logfile or so) I would be happy to do so.
I will submit this bug, I'm writing it with Ubuntu. After that I will startup Plasma and attache my hardware-configuration.
***


STEPS TO REPRODUCE
1. Startup plasma Wayland on the MS Surface Pro 3 (can be Neon, Kubuntu of Tumbleweed)
2. Work with it for a wile
3. 

OBSERVED RESULT
Sometimes very soon or sometimes after a few minutes the touchpad looses functionality

EXPECTED RESULT
I can keep on working.
Comment 1 PK 2022-02-27 07:26:16 UTC
Operating System: KDE neon 5.24
KDE Plasma Version: 5.24.2
KDE Frameworks Version: 5.91.0
Qt Version: 5.15.3
Kernel Version: 5.13.0-30-generic (64-bit)
Graphics Platform: Wayland
Processors: 4 × Intel® Core™ i5-4300U CPU @ 1.90GHz
Memory: 3.7 GiB of RAM
Graphics Processor: Mesa DRI Intel® HD Graphics 4400
Comment 2 PK 2022-03-03 18:20:02 UTC
Created attachment 147264 [details]
this bar I mean, at the top of the screen

I just went back to Plasma. I let it upgrade very gently. Without touching anything. As you see in the attached image to process is ongoing. Suddenly this bar drop from the top and I totally loose control over the system.
Comment 3 PK 2022-03-11 16:34:34 UTC
B.t.w. I find exactly the same result with Fedora KDE spin 35, Opensuse Tumbleweed and Neon User Edition.
Comment 4 Nate Graham 2022-03-27 17:21:33 UTC
That bar appears when you click-and-hold (pr press-and-hold) o the desktop. I would guess that's a symptom of the issue, rather than the cause.

Moving to kwin | libinput since this is on Wayland.
Comment 5 PK 2022-03-27 17:41:20 UTC
I totally agree with your Vision on the cause and effect. It could very well be that Ubuntu suffers from the same, but that they wrote a systemd service to te start libinput when it behaves abnormally. I Searched for such a service in my Ubuntu system but I couldn't find it. Something like that could never harm and could also be a good temporary Solution. I also made this suggesties here https://github.com/jakeday/linux-surface/issues/400 .
Comment 6 PK 2022-03-29 12:44:23 UTC
Discovery:
I was trying to get X working. On this MS Surface Pro 3 I never had a cursor using X. Exept when I was installing linux. E.g. Calamares uses the X environment but is had a cursor! So I just gambled and installed the package xserver-xorg-input-multitouch.
This gave me a totally working cursor in X. 
With xserver-xorg-input-multitouch installed I went back to Wayland. The laptop just works better with Wayland only the touchpad used to be so unstable
BUT
now the touchpad isn't unstable anymore!
Suddenly I can work as long as I want and the touchpad remains working!
Only one time I had a tiny strange thing, that used to have led me to a touchpad crash and this time it didn't.
Plasma is with this package installed totally back on the level of gnome/ubuntu or even better.
So the remedy of this problem is installing the package xserver-xorg-input-multitouch on kde...
Just to let you know. 
Thank you.
Comment 7 PK 2022-03-30 06:12:49 UTC
I spoke too soon. The Surface Pro 3 still suffers from libinput crashes. Only they really happen later (hours, not minutes)
Comment 8 PK 2022-03-30 13:30:37 UTC
One Sphh suggested here https://github.com/jakeday/linux-surface/issues/400 that I could try to install the surface kernel. I did. Successfully (!). I will test it.
I'll tell what the result was on this place.
Comment 9 PK 2022-03-31 15:47:11 UTC
The surface kernel makes my (surface) laptop boot and close down faster imo and I think it remains cooler too. But the libinput crashes remain using Plasma
Comment 10 PK 2022-04-25 10:59:48 UTC
Just after starting Plasma I did lsmod. And after the touchpad-crash I did it again. There was only one changed....
"i915  2568192  31" had become "i915  2568192  32".
I have no clue what this could mean. But I leave it here...
Comment 11 PK 2022-05-01 20:00:51 UTC
All my troubles seem to have gone...
Of all the possible solutions I tried the last one actually worked!

I found it here https://askubuntu.com/questions/965856/kworker-blocked-for-more-than-120-seconds-ubuntu-17-10/1363359#1363359
"The solution was for me to switch the whole KWin compositing from OpenGL / GLX to OpenGL ES / EGL. For this, the corresponding config file must be edited."
I really not have so much a clue what that means but it works 100%!
The result is impressive.
Comment 12 PK 2022-05-01 20:40:14 UTC
Too bad... still a crash! But things seem better...
Comment 13 Nate Graham 2022-05-03 16:41:17 UTC
*** Bug 453161 has been marked as a duplicate of this bug. ***
Comment 14 PK 2022-05-03 17:11:03 UTC
A clear cause of this touchpad crash is when I touch the touch-sensitive part of the screen in the neighborhood of "home-button". Then the touchpad crashes immediately. This can be cured by putting a script-file in the folder  /etc/profile.d/ with in it "export KWIN_COMPOSE=O2ES". This works great for the home-button thing and apart from that makes the touchpad crash less often. But still it keeps crashing.
Comment 15 PK 2022-05-05 06:27:43 UTC
Just to say that I solved this bug... At least on my Surface laptop on my linux-distribution that uses systemd.
How?
By reading/trial and error/pure luck I came more and more convinced that this cursor-instability wasn't caused by libinput but by kwin!
Long story short:
I added the lines

Restart=always
RestarSec=0,1

to the file /usr/lib/systemd/user/plasma-kwin_wayland.service and that really seems to do the trick!
This seems to me sort of a workaround, if not to say a "dirty hack". But it works, only of course provided that your distribution uses systemd.
Now I am very happy with my KDE Surface-laptop, a little proud on myself en very grateful to you, who took the time to read this bug.
Comment 16 PK 2022-05-05 19:56:59 UTC
Still plasma crashes... I give up with kde on this machine...
Comment 17 PK 2022-05-06 06:45:56 UTC
Created attachment 148598 [details]
output of "journaldctl -b -1"
Comment 18 PK 2022-05-06 06:48:56 UTC
Created attachment 148599 [details]
part where the word "crash" appears a lot. To view quickly

Also I see here in this part: The Wayland connection broke. Did the Wayland compositor die?
Four times...
Comment 19 PK 2022-05-06 06:52:28 UTC
Created attachment 148600 [details]
line 3075-3150 of "journaldctl -b -1" in text

Here is the text-version of perhaps the relevant part of journaldctl -b -1
Comment 20 PK 2022-05-06 10:25:18 UTC
This time I really think I found it.
I was reading the systemd log-file and came under the impression that Baloo had something to do with it.
I read in the file that Baloo crashes, then it drags the whole qt-system with it in its fall, then the system tries to get qt running again but doesn't succeed in that.
So I turned off baloo and to my great surprise the system was stable.
Then I did a quick search on the web and found this https://www.reddit.com/r/kde/comments/bayy70/fix_for_file_search_and_baloo_crashing/
So I went in the folder ~/.local/share/baloo and found exactly the same file of 3,5 mb, I deleted it and the other file in the folder too.
The I rebooted, activated baloo again and since then plasma on the Surface Pro 3 runs like a charm!
Strange thing is that I never had this issue with any other machine but obviously had the problem on this machine with Neon kde, Fedora kde, Opensuse tumbleweed kde and with Kubuntu.
As far as I know this bug is solved.
Comment 21 PK 2022-05-06 11:13:06 UTC
Again I spoke too soon... After a reboot (baloo-system off) plasma crashed.
Comment 22 PK 2022-05-11 05:55:33 UTC
I installed Windows 10 on the Surface and looked if there were updates. And indeed there were: even four firmware-upgrades (one 2016 and three 2019). I was under the impression that I already did this but it turned out I was wrong.
After this action I put Kubuntu back and the problem is solved for 97%!
When the cursor starts doing strange, and that happens no more than one time per session but very often not at all, I can bring the cursor to life again by moving with my finger over the touch-screen.
The result is very workable.
I have good hope for plasma 5.25. I will come back here when I have tried that.
Comment 23 PK 2022-05-23 17:22:33 UTC
Installing the firmware didn't do the trick. 
Naturally I blamed the "exotic hardware" of this MS Surface pro 3 and even myself but only yesterday I did a search on the internet to look if there were more types of touch screen laptop with complains like mine from people using Plasma. And there were. A lot. This doesn't seem to be one of the stronger sides of Plasma. 
But I found a way to get tap-to-click to life again when it stopped. Just touching the screen with a finger. Or tap on it. Then tap-to-click comes to life again. That can be within a second but it can also happen after five seconds trying or so.
I found forum issues from years ago about this. It would be great if this was repaired.
Comment 24 PK 2022-06-19 19:07:29 UTC
I found out that it really helps almost 100% when I blacklist the kernel modules 
- hid_sensor_hub and
- hid
Then it becomes much quieter. The double-click-and-hold-on-the-desktop" quick settings bar doesn't appear randomly no more and tap-to-click stays working. And strangely enough there are no drawbacks.
Only after suspension it often doesn't work no more. Then I have to wake it by tapping the screen with my finger on various places. That works most of the time.
I hope this helps more people with "2 in 1" convertible laptops.
Comment 25 PK 2022-09-10 13:46:40 UTC
This turns out to be caused by the Intel Panel Self Refresh (PSR). PSR seems to be causing all sorts of problems on all kinds of systems. I disabled it and now Plasma behaves 100% as it should. 
At last I had luck!
In the file /etc/default/grub change the line 
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
to
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i915.enable_psr=0"
save, update grub and reboot.
Problem solved. Plasma is stable.
I tested extensively.