Bug 463115 - [Android] Krita loses detection of mouse events on canvas after S-PEN is in range, and it won't come back
Summary: [Android] Krita loses detection of mouse events on canvas after S-PEN is in r...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Shortcuts and Canvas Input Settings (show other bugs)
Version: nightly build (please specify the git hash!)
Platform: Android Android 13.x
: NOR normal
Target Milestone: ---
Assignee: sh_zam
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-16 13:28 UTC by Tyson Tan
Modified: 2023-03-09 13:28 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Tablet log of Samsung Tab S8 with keyboard cover (215.98 KB, text/x-log)
2023-01-28 02:28 UTC, Tyson Tan
Details
krita-s-pen-events.apk pre-install screen (99.40 KB, image/png)
2023-03-01 07:32 UTC, Tyson Tan
Details
krita-s-pen-events.apk install failed screen (64.85 KB, image/png)
2023-03-01 07:32 UTC, Tyson Tan
Details
Krita debug tablet and mouse event log (321.43 KB, text/plain)
2023-03-01 13:31 UTC, Tyson Tan
Details
Mouse and trackpad Settings page of Galaxy Tab S8 (263.99 KB, image/png)
2023-03-02 14:40 UTC, Tyson Tan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tyson Tan 2022-12-16 13:28:52 UTC
In Krita's Android version, the app loses detection of mouse events on canvas as soon as a S-PEN has been in range (it being able to control the cursor). Mouse/Touchpad functionalities won't come back, even with the S-PEN removed. The mouse/touchpad still works system-wide. The cursor is still being displayed on Krita's menus, but as soon as the cursor moves into the canvas, it disappears. No mouse click can be registered inside Krita.

Tested on:
Samsung Galaxy Tab S8 with One UI 5.0 (Android 13).
Krita 5.1.4 and latest Krita Next nightlies (5.2.0).
Comment 1 sh_zam 2023-01-25 17:51:31 UTC
Hi Tyson!

If you have an External keyboard, can you please enable Tablet Event Logging (Ctrl + Shift + T), enable logging in Log View docker and then attach the output after performing the buggy action?
Comment 2 Tyson Tan 2023-01-27 01:47:11 UTC
I have tried to log the tablet events today. It seemed to be successful, judging from the prompts. However, I have no idea how to find the log files on Android.

There is a new finding: when the bug happened, I left mouse clicked on the canvas, the cursor returned and it was functional. This felt similar to another bug I reported earlier (after creating/opening a document, the canvas would freeze until I draw something on it)

BTW, this bug has become less relevant to my Krita usage, as I figured out that the most comfortable way to use Krita on an Android tablet -- to ditch the keyboard and mouse completely, and to use the screen vertically, with no docker shown.
Comment 3 sh_zam 2023-01-27 09:38:12 UTC
(In reply to Tyson Tan from comment #2)
> I have tried to log the tablet events today. It seemed to be successful,
> judging from the prompts. However, I have no idea how to find the log files
> on Android.

In the log view docker, there is a save button and that works exactly like how you'd save any other Krita file :)
Comment 4 Tyson Tan 2023-01-28 02:28:03 UTC
Created attachment 155716 [details]
Tablet log of Samsung Tab S8 with keyboard cover
Comment 5 sh_zam 2023-02-25 09:06:59 UTC
Thanks for the logs! I've fixed the bug, but it will be in Nightly only when the dependencies are built (which may take till Monday :) ).
Comment 6 Tyson Tan 2023-02-26 10:48:33 UTC
Hi Shzam,
After upgrading to the latest nighty, the touchpad works after s-pen is in range. Thanks!

However, the S-Pen's side button events seems to be broken now.

I used to be able to being up the Pop-up Palette by simply pressing S-Pen's side button. The even was recognized as a Middle Click. Now I must hold the side button and tap the screen to trigger middle click.
Comment 7 Tyson Tan 2023-02-26 10:58:33 UTC
It seems that the expected behavior of "Hover Click" has been replaced with "Hold and tap" under Android.

I did not observe this issue on Linux.
Comment 8 sh_zam 2023-02-27 05:50:57 UTC
Clearly an oversight on my part! Thanks for letting me know!
Comment 9 sh_zam 2023-02-28 06:44:45 UTC
Hello! Can you please test this: https://drive.google.com/file/d/1PCpq92YRzdiEjMsR3TSwWfFv9Rap4zZ5/view?usp=sharing :)
Comment 10 Tyson Tan 2023-02-28 12:13:37 UTC
Hi Sharaf, the APK file you posted in Comment 9 seems to be broken. 
My Galaxy Tab S8 reported "Invalid Package" and refused to install it. 

I've tried to download it multiple times using different means, the result was the same. 
The file size is 136.3 MiB, which seems to be correct.
Comment 11 sh_zam 2023-03-01 06:02:56 UTC
That's strange. Can you please check if you have some other version of Krita Debug installed? If yes, you may have to uninstall it.
Comment 12 sh_zam 2023-03-01 06:03:32 UTC
It will be named "Krita Debug", if it is "Krita Next" or the one from Play Store they shouldn't conflict with this.
Comment 13 Tyson Tan 2023-03-01 07:19:02 UTC
No I didn't. I've only installed Krita Next. And I tried to uninstall Krita Next and install yours, but the error remained the same.

...and for some reason this deleted all my settings (I checked the keep all data box) I wanna die right now XD
Comment 14 Tyson Tan 2023-03-01 07:32:24 UTC
Created attachment 156852 [details]
krita-s-pen-events.apk pre-install screen
Comment 15 Tyson Tan 2023-03-01 07:32:46 UTC
Created attachment 156853 [details]
krita-s-pen-events.apk install failed screen
Comment 16 Tyson Tan 2023-03-01 07:34:33 UTC
The normal Krita Next is APK 114.1MiB.
Your APK is 136.3 MiB, which is significantly bigger.
Could it be something wrong in the building configuration?
Comment 17 sh_zam 2023-03-01 07:40:10 UTC
Let's try again: https://drive.google.com/file/d/1PCpq92YRzdiEjMsR3TSwWfFv9Rap4zZ5/view?usp=sharing (it's the same url but I've uploaded a different APK).

About losing your config, please check ~/Android/data/org.krita.next/files folder to see if there's any of your config present there. Also did you happen to change the resource location (that can make the resources be not found)?
Comment 18 Tyson Tan 2023-03-01 13:31:15 UTC
Created attachment 156869 [details]
Krita debug tablet and mouse event log

Hi Sharaf, the second APK was able to install, and the S-PEN's side button now works as intended.

But the touchpad event is now all messed up.

1) Krita can only receive Left Button click from the touchpad. It ignores the touchpad's right click events completely (either by clicking on the touchpad's buttom-right corner / or using the 2-finger tapping gesture). These right-clicks works as intended outside of Krita. "Use mouse event for right click" didn't help.

2) Left click on canvas sometimes initiates brush strokes, and the stroke continues to draw even when the left button is released. I must do another left click to end the stroke.

3) Mouse cursor on canvas is still missing after the S-Pen is in range and then removed from range.

I've recorded another input log, and attached in this comment.
Comment 19 Tyson Tan 2023-03-01 13:43:38 UTC
Oh, by the way, don't worry about the config data. They are gone. No big deal though, just 15 minutes of re-setting everything. That's why I always use only the default brushes. XD

I think by checking the option of "Keep all the data", the only data it would keep, was the permissions allowed for the app. All data in /Android/data/org.krita.next/files/ were removed at uninstall, regardless of what you do.

Well, at least now I know I can backup/restore the data via MTP...
Comment 20 sh_zam 2023-03-02 11:57:16 UTC
(In reply to Tyson Tan from comment #18)
> Created attachment 156869 [details]
> Krita debug tablet and mouse event log
> 
> Hi Sharaf, the second APK was able to install, and the S-PEN's side button
> now works as intended.
> 
> But the touchpad event is now all messed up.
> 
> 1) Krita can only receive Left Button click from the touchpad. It ignores
> the touchpad's right click events completely (either by clicking on the
> touchpad's buttom-right corner / or using the 2-finger tapping gesture).
> These right-clicks works as intended outside of Krita. "Use mouse event for
> right click" didn't help.
> 
> 2) Left click on canvas sometimes initiates brush strokes, and the stroke
> continues to draw even when the left button is released. I must do another
> left click to end the stroke.
> 
> 3) Mouse cursor on canvas is still missing after the S-Pen is in range and
> then removed from range.
> 
> I've recorded another input log, and attached in this comment.

This is weird. Because I didn't touch any of the code which deals with Touchpad... is this behavior reproducible even if you use a mouse? Because I couldn't reproduce with my mouse.
Comment 21 Tyson Tan 2023-03-02 14:40:51 UTC
Created attachment 156925 [details]
Mouse and trackpad Settings page of Galaxy Tab S8

The trackpad on the Samsung official keyboard cover can only produce a Left-Mouse-Button event. 
The trackpad's "Right Click" does not produce a Right-Mouse-Button event. 
It produces an "Opens Contextual Menu" signal instead. 
Krita doesn't seem to recognize that signal.

A Bluetooth mouse can produce a proper Right-Mouse-Button event on Galaxy Tab S8. 
But if in System Settings, the Secondary button is set to None (default is Open Contextual Menu), then RMB is lost.

Krita recognizes RMB event in its configuration dialogue.
However, it doesn't recognize RMB on its canvas.

On Krita's canvas, the first click from a touchpad/mouse is always recognized as "start of a brush stroke", and the second click recognized as "ending of a brush stroke", regardless of Left/Right button.

Notes: 
Galaxy Tab S8 has been updated to the latest One UI 5.1.
The keyboard cover has received a firmware update since the initial report.
Comment 22 Tyson Tan 2023-03-02 14:59:24 UTC
Anyway, I suppose the original bug in this report has been fixed in your latest APK. Maybe we should just mark this bug as fixed, and call it a day? 

I guess the issues I mentioned in Comment 18 and Comment 21 were not caused by your code. Perhaps, they have always been there, I just never paid attention.

Krita not being able to recognize RMB on its canvas is a serious bug, nonetheless. Especially when we routinely recommend users to use Krita with a keyboard.

It seems every Android tablet device invents a different way to deal with RMB/Context Menu events, making it troublesome to support each device properly.
Comment 23 sh_zam 2023-03-09 05:38:41 UTC
Git commit 0bc6830d47e931f8d85cc57590350dfe55a22898 by Sharaf Zaman.
Committed on 09/03/2023 at 05:35.
Pushed by szaman into branch 'master'.

Update the QT_TAG

The fixes include:

1. fixing the bug with S-pen buttons not getting recognized when the
stylus is being hovered.

2. Fixing the code of passing mouse events. For example, you couldn't
double click in Qt5.15. Now it should work like before.

M  +1    -1    3rdparty/ext_qt/CMakeLists.txt

https://invent.kde.org/graphics/krita/commit/0bc6830d47e931f8d85cc57590350dfe55a22898
Comment 24 sh_zam 2023-03-09 05:40:59 UTC
Hi!

I've fixed the bug again, and this time the fix also includes the Right mouse button press. It used to work when Krita was on 5.12, but the bug reappeared when we updated Qt version :)

It is good that we found the bug now and not from the releases. Thanks for reporting! And feel free to test (it should be available in the next nightly once dependencies are freshly built)
Comment 25 sh_zam 2023-03-09 06:14:29 UTC
I've attached an APK for some other MR, but it contains fix for this bug as well, link is in the MR: https://invent.kde.org/graphics/krita/-/merge_requests/1771 :)
Comment 26 Tyson Tan 2023-03-09 13:28:13 UTC
Thanks Sharaf! I've tested the new APK, and I can confirm that the bugs has been fixed.