Skip to content

fix(whiteboard): prevent eraser skipping on fast swipe#20581

Merged
criticalAY merged 1 commit intoankidroid:mainfrom
JoelHorrocks:fix-whiteboard-eraser
Apr 5, 2026
Merged

fix(whiteboard): prevent eraser skipping on fast swipe#20581
criticalAY merged 1 commit intoankidroid:mainfrom
JoelHorrocks:fix-whiteboard-eraser

Conversation

@JoelHorrocks
Copy link
Copy Markdown
Contributor

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

  • Added eraserLastX and eraserLastY in WhiteboardViewModel to remember the previous eraser coordinates during an erase gesture
  • Replaced the check if the current eraser location is close enough to a drawn path with a check if any drawn path is close enough to the last line segment of the eraser stroke

How 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.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

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
@welcome
Copy link
Copy Markdown

welcome bot commented Mar 25, 2026

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.

@david-allison david-allison requested a review from BrayanDSO March 25, 2026 14:08
@david-allison david-allison added this to the 2.24 release milestone Mar 26, 2026
@david-allison david-allison added the Review High Priority Request for high priority review label Apr 5, 2026
Copy link
Copy Markdown
Member

@BrayanDSO BrayanDSO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks

@BrayanDSO BrayanDSO added Needs Second Approval Has one approval, one more approval to merge and removed Needs Review labels Apr 5, 2026
Copy link
Copy Markdown
Contributor

@criticalAY criticalAY left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean code! thanks lets get it in

@criticalAY criticalAY added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Second Approval Has one approval, one more approval to merge labels Apr 5, 2026
@criticalAY criticalAY added this pull request to the merge queue Apr 5, 2026
Merged via the queue into ankidroid:main with commit 40a6b91 Apr 5, 2026
19 checks passed
@github-actions github-actions bot removed Review High Priority Request for high priority review Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) labels Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New Study Screen - Whiteboard Eraser may not erase quick strokes

4 participants