Sitelet https://github.com/react/react/pull/9219
Skip to content

Removed optimization for events without target in ReactNativeEventEmitter - #9219

Merged
sophiebits merged 2 commits into
react:masterfrom
shergin:master
Mar 21, 2017
Merged

sophiebits merged 2 commits into
react:masterfrom
shergin:master

Conversation

@shergin

@shergin shergin commented Mar 19, 2017 •

Copy link
Copy Markdown
Contributor

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: react/react-native#12976 .

The test also illustrates this problem.

@spicyj, please review. 😄

@sophiebits sophiebits left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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
Copy Markdown
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 react#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: react/react-native#12976 .

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

Copy link
Copy Markdown
Contributor

Thanks!

bvaughn pushed a commit to bvaughn/react that referenced this pull request Mar 28, 2017
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
…tter (react#9219)

* Removed optimization for events without target in ReactNativeEventEmitter

This PR fixes the problem originally introduced in react#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: react/react-native#12976 .

The test also illustrates this problem.

* Prettier
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