Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

W3CPointerEvents: fix NPE due to missing eventCoords #37761

Closed
wants to merge 1 commit into from

Conversation

adanoff
Copy link

@adanoff adanoff commented Jun 7, 2023

Summary:
Changelog: [Android] [Fixed] - W3CPointerEvents: fix a case where cancel can cause NPE

When we need to dispatch a pointercancel event, we clear the previous state (last coordinates, last hit path) for the active pointer ID (this is needed in order to fire the proper events when the action causing the cancel is over).

Previously, we stored the previous state in the form of references to the corresponding state in the current PointerEventState. However, this PointerEventState is also used later when actually dispatching the events. Since the dispatch can happen asynchronously, alterations to the event state might be visible during the dispatch. In particular, we saw some cases where an NPE can occur due to removing entries from our local state (which got reflected in the event state).

This change fixes the issue by making copies of the data from the PointerEventState instead of just storing references to it.

Reviewed By: rozele

Differential Revision: D46522585

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner fb-exported labels Jun 7, 2023
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46522585

@analysis-bot
Copy link

analysis-bot commented Jun 7, 2023

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,744,467 +46
android hermes armeabi-v7a 8,056,673 +46
android hermes x86 9,235,596 +48
android hermes x86_64 9,086,422 +44
android jsc arm64-v8a 9,307,256 -9
android jsc armeabi-v7a 8,496,789 -18
android jsc x86 9,369,265 -16
android jsc x86_64 9,624,171 -33

Base commit: 4540668
Branch: main

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46522585

adanoff pushed a commit to adanoff/react-native that referenced this pull request Jun 7, 2023
Summary:
Pull Request resolved: facebook#37761

Changelog: [Android] [Fixed] - W3CPointerEvents: fix a case where cancel can cause NPE

When we need to dispatch a pointercancel event, we clear the previous state (last coordinates, last hit path) for the active pointer ID (this is needed in order to fire the proper events when the action causing the cancel is over).

Previously, we stored the previous state in the form of references to the corresponding state in the current `PointerEventState`. However, this PointerEventState is also used later when actually dispatching the events. Since the dispatch can happen asynchronously, alterations to the event state might be visible during the dispatch. In particular, we saw some cases where an NPE can occur due to removing entries from our local state (which got reflected in the event state).

This change fixes the issue by making copies of the data from the PointerEventState instead of just storing references to it.

Reviewed By: rozele

Differential Revision: D46522585

fbshipit-source-id: 5dcefc355d6821d50ca699813a8589fda689d0ba
Summary:
Pull Request resolved: facebook#37761

Changelog: [Android] [Fixed] - W3CPointerEvents: fix a case where cancel can cause NPE

When we need to dispatch a pointercancel event, we clear the previous state (last coordinates, last hit path) for the active pointer ID (this is needed in order to fire the proper events when the action causing the cancel is over).

Previously, we stored the previous state in the form of references to the corresponding state in the current `PointerEventState`. However, this PointerEventState is also used later when actually dispatching the events. Since the dispatch can happen asynchronously, alterations to the event state might be visible during the dispatch. In particular, we saw some cases where an NPE can occur due to removing entries from our local state (which got reflected in the event state).

This change fixes the issue by making copies of the data from the PointerEventState instead of just storing references to it.

Reviewed By: rozele

Differential Revision: D46522585

fbshipit-source-id: c08be1782285d85b9c4dd356fce6c920ca971fe5
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46522585

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jun 8, 2023
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 79ae710.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants