Skip to content

Fix NPE in handleTouchMove when activePath is null#144

Merged
mattsilber merged 3 commits intojackpocket:mainfrom
kharrison-jp:fix/activePath-npe
Mar 20, 2026
Merged

Fix NPE in handleTouchMove when activePath is null#144
mattsilber merged 3 commits intojackpocket:mainfrom
kharrison-jp:fix/activePath-npe

Conversation

@kharrison-jp
Copy link
Copy Markdown
Contributor

@kharrison-jp kharrison-jp commented Mar 19, 2026

Summary

  • Fixes NullPointerException in ScratchPathManager.handleTouchMove() when activePaths[pointerIndex] is null
  • This occurs when touch MOVE events are replayed from the pending queue during layout initialization, but the corresponding DOWN event was lost across an attach cycle
  • Adds a null guard that safely skips the move event; the next DOWN event creates the path normally
  • Adds a null guard that creates a new path starting from the current touch position, preserving the scratch stroke rather than dropping the entire movement

Crash

  java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Path.isEmpty()' on a null object reference
      at ScratchPathManager.handleTouchMove (ScratchPathManager.java:86)

Reproduced when using ScratchableLinearLayout inside Jetpack Compose via AndroidView.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 20, 2026

Codecov Report

❌ Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.18%. Comparing base (d255539) to head (c9ca291).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...om/jackpocket/scratchoff/ScratchoffController.java 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #144      +/-   ##
==========================================
+ Coverage   83.63%   84.18%   +0.55%     
==========================================
  Files          10       10              
  Lines         611      626      +15     
  Branches       76       78       +2     
==========================================
+ Hits          511      527      +16     
+ Misses         67       66       -1     
  Partials       33       33              
Flag Coverage Δ
unit 84.18% <87.50%> (+0.55%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Collaborator

@mattsilber mattsilber left a comment

Choose a reason for hiding this comment

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

<3

@mattsilber mattsilber merged commit 8b63c7b into jackpocket:main Mar 20, 2026
6 checks passed
@github-actions github-actions bot mentioned this pull request Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants