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: fe60fe08929ed29a570a860d49915b6f5ae4a542
  • Loading branch information
Alex Danoff authored and facebook-github-bot committed Jun 9, 2023
1 parent 72eadcf commit 96fd107
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 96fd107

Please sign in to comment.