Skip to content

Commit

Permalink
W3CPointerEvents: fix NPE due to null targetView (#37785)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #37785

Changelog: [Android] [Fixed] - W3CPointerEvents: fix NPE due to null targetView

For reasons not entirely understood, we sometimes end up with a null `targetView` in this code path during the dispatch of an `ACTION_CANCEL`. This results in an NPE during the call to `getChildOffsetRelativeToRoot`. This change adds a null check before the call to avoid the crash.

Reviewed By: cortinico

Differential Revision: D46562263

fbshipit-source-id: a6e8276cfb7213e5a0f64b78bd0ac8b6220e5f0b
  • Loading branch information
Alex Danoff authored and facebook-github-bot committed Jun 9, 2023
1 parent 6ebee63 commit cf96e45
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ private void dispatchCancelEventForTarget(
int activePointerId = eventState.getActivePointerId();
List<ViewTarget> activeHitPath = eventState.getHitPathByPointerId().get(activePointerId);

if (!activeHitPath.isEmpty()) {
if (!activeHitPath.isEmpty() && targetView != null) {
boolean listeningForCancel =
isAnyoneListeningForBubblingEvent(activeHitPath, EVENT.CANCEL, EVENT.CANCEL_CAPTURE);
if (listeningForCancel) {
Expand Down

0 comments on commit cf96e45

Please sign in to comment.