Skip to content

Commit

Permalink
W3CPointerEvents: fix NPE due to null targetView
Browse files Browse the repository at this point in the history
Summary:
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.

Differential Revision: D46562263

fbshipit-source-id: 65048caa2d49f759ec09799bd7d9209eeb5c60d0
  • Loading branch information
Alex Danoff authored and facebook-github-bot committed Jun 8, 2023
1 parent f3c8636 commit f1e9c6b
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 f1e9c6b

Please sign in to comment.