Fixed endless scroll bug + ghost clicks bug + latency issues #67
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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