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

Removed optimization for events without target in ReactNativeEventEmitter #9219

Merged
merged 2 commits into from
Mar 21, 2017

Conversation

shergin
Copy link
Contributor

@shergin shergin commented Mar 19, 2017

This PR fixes the problem originally introduced in #6590
The problem is that ResponderEventPlugin (and ResponderTouchHistoryStore) relies on that fact that touch events are balanced.
So if one startish event happened, should be coming endish event. Otherwise there is no way to maintain internal trackedTouchCount counter. So, if we drop some events, we break this logic.

Moreover, that optimization clearly contradict with this statement from ResponderEventPlugin:

We must be resilient to `targetInst` being `null` on `touchMove` or
`touchEnd`. On certain platforms, this means that a native scroll has
assumed control and the original touch targets are destroyed.

This issue causes several major problems in React Native, and one of them (finally!) is easy to reproduce: facebook/react-native#12976 .

The test also illustrates this problem.

@spicyj, please review. 😄

Copy link
Collaborator

@sophiebits sophiebits left a comment

Choose a reason for hiding this comment

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

This looks good though I'm unsure about the test.

(I would have liked to match this change in the corresponding DOM code at src/renderers/dom/shared/ReactEventListener.js handleTopLevelImpl but it seems like maybe the logic there is different enough due to the nested roots logic that it is probably fine to leave them separate.)


expect(getResponderId()).toBe(null);

expect(log).toEqual([
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if I'm missing something obvious, but how does this test the codepath in question? It seems to me that the simulated touches you have both hit mounted views.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for feedback, Ben!
I changed the test to match the original conditions.

…tter

This PR fixes the problem originally introduced in facebook#6590
The problem is that `ResponderEventPlugin` (and `ResponderTouchHistoryStore`) relies on that fact that touch events are balanced.
So if one `startish` event happened, should be coming `endish` event. Otherwise there is no way to maintain internal `trackedTouchCount` counter. So, if we drop some events, we break this logic.

Moreover, that optimization clearly contradict with this statement from `ResponderEventPlugin`:
```
We must be resilient to `targetInst` being `null` on `touchMove` or
`touchEnd`. On certain platforms, this means that a native scroll has
assumed control and the original touch targets are destroyed.
```

This issue causes several major problems in React Native, and one of them (finally!) is easy to reproduce: facebook/react-native#12976 .

The test also illustrates this problem.
@sophiebits sophiebits merged commit 97ab3f5 into facebook:master Mar 21, 2017
@sophiebits
Copy link
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants