matvt icon indicating copy to clipboard operation
matvt copied to clipboard

Fixed endless scroll bug + ghost clicks bug + latency issues

Open aquirozc opened this issue 2 years ago • 4 comments

Previously, when swipe gestures were performed by the accessibility service, they were all handled in the same thread, which meant that no swipes were overlapped, as each individual gesture wouldn't be executed until the previous one was completed. However, with the recent revamp of the Mouse Emulation Engine to be ADB-based, gestures are now handled on a parallel thread. This has resulted in the overlapping of swipes, as the key listener process continues to add extra swipes to the queue while a single movement is being executed, leading to an extremely large and almost endless scroll.

The overlapping of swipes was also the cause of the "ghost clicks" bug, as the operating system itself interpreted multiple swipes that are extremely close to each other as a standard tap. To address this issue, I proposed to put the main thread to sleep for the same amount of time each swipe would take to complete, before making another call to the system shell to perform a new gesture. As a result, the scroll now stops immediately after the key is released, with no extra delay or latency, no matter how long the key was pressed.

Overall experience is almost identical to the one which was achieved by using the Accessibility Service.

Note: Some now unused code lines were deleted, but I am aware that it is preferred to just comment them out rather than erase them. However, I am planning to add a "Use Legacy Engine" option, so I'd like to keep them in a separate method.

Here is a live demonstration of the improvements, just a reminder that everything shown is entirely ADB-based.

https://youtu.be/B9BbyHxBgoU

aquirozc avatar Feb 14 '23 00:02 aquirozc