fix(whiteboard): prevent eraser skipping on fast swipe#20581
Merged
criticalAY merged 1 commit intoankidroid:mainfrom Apr 5, 2026
Merged
fix(whiteboard): prevent eraser skipping on fast swipe#20581criticalAY merged 1 commit intoankidroid:mainfrom
criticalAY merged 1 commit intoankidroid:mainfrom
Conversation
Sometimes the whiteboard eraser on the new study screen would miss erasing a path if the eraser swipe was fast Fixed by keeping track of previous and current eraser coordinates and checking for path intersections along the eraser line segment, rather than just using the current eraser location
|
First PR! 🚀 We sincerely appreciate that you have taken the time to propose a change to AnkiDroid! Please have patience with us as we are all volunteers - we will get to this as soon as possible. |
criticalAY
approved these changes
Apr 5, 2026
Contributor
criticalAY
left a comment
There was a problem hiding this comment.
Clean code! thanks lets get it in
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Purpose / Description
The new study screen whiteboard eraser occasionally skips parts of a drawn path when the user swipes quickly across the screen.
Fixes
Approach
eraserLastXanderaserLastYinWhiteboardViewModelto remember the previous eraser coordinates during an erase gestureHow Has This Been Tested?
Tested on a physical device - drew a line with width 10 on the new whiteboard and tested a quick swipe with eraser width 10 to ensure the line is erased. Also checked that existing eraser functionality works as expected.
Before:
Screen_recording_20260325_135143.mp4
After:
Screen_recording_20260325_135206.mp4
Learning (optional, can help others)
Android MotionEvent touch coordinates can have large gaps between ACTION_MOVE events during fast gestures. These events can batch together coordinates, but even processing the batched coordinates for the eraser, it was still possible for lines to be missed during very fast swipes.
Interpolating between eraser positions by sampling many points along the eraser segment and checking each one against every path was too slow. Instead, projecting each point on the drawn paths onto the eraser line segment to find the shortest distance was much faster.
Checklist
Please, go through these checks before submitting the PR.