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

Crash with multi RootView by multi touch #9503

Closed
littlesome opened this issue Aug 21, 2016 · 3 comments
Closed

Crash with multi RootView by multi touch #9503

littlesome opened this issue Aug 21, 2016 · 3 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@littlesome
Copy link

littlesome commented Aug 21, 2016

I have many RCTRootView in my app, and got crash like this:
(my app based on 0.30.0 iOS, this repro below uses 0.25.1)

2016-08-21 18:19:36.476 [info][tid:main][RCTPerformanceLogger.m:75] Unbalanced calls start/end for tag 15
2016-08-21 18:19:36.477 [info][tid:main][RCTPerformanceLogger.m:75] Unbalanced calls start/end for tag 15
2016-08-21 18:19:36.482 [info][tid:main][RCTPerformanceLogger.m:75] Unbalanced calls start/end for tag 15
2016-08-21 18:19:39.205 UIExplorer[6490:3038384] sendEvent topTouchStart, 1
2016-08-21 18:19:39.206 UIExplorer[6490:3038384] sendEvent topTouchStart, 1
2016-08-21 18:19:39.206 UIExplorer[6490:3038384] *** Assertion failure in -[RCTEventDispatcher sendEvent:](), /Users/lituo/Documents/rn/react-native/React/Base/RCTEventDispatcher.m:145
2016-08-21 18:19:39.212 UIExplorer[6490:3038384] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Got event <RCTTouchEvent: 0x12f8e5340; name = topTouchStart; coalescing key = 1> which cannot be coalesced, but has the same eventID 343532959170560 as the previous event <RCTTouchEvent: 0x12f8e4c30; name = topTouchStart; coalescing key = 1>'
*** First throw call stack:
(0x180a42db0 0x1800a7f80 0x180a42c80 0x1813c81c0 0x1001642ac 0x10012c0fc 0x10012c250 0x186131f30 0x185d46728 0x185bd37a0 0x186133530 0x185b924d8 0x185b8f254 0x185bd1610 0x185bd0c0c 0x185ba104c 0x185b9f628 0x1809f909c 0x1809f8b30 0x1809f6830 0x180920c50 0x182208088 0x185c0a088 0x1000a8bc8 0x1804be8b8)
libc++abi.dylib: terminating with uncaught exception of type NSException`

UIExplorer's RCTRootView example can reproduces this bug (100%), try to touch the 'Embedded React Native view' and 'React Native Button' at the same time.

I noticed that in RCTEventDispatcher.m RCTGetEventID returns same value

static NSNumber *RCTGetEventID(id<RCTEvent> event)
{
  return @(
    event.viewTag.intValue |
    (((uint64_t)event.eventName.hash & 0xFFFF) << 32) |
    (((uint64_t)event.coalescingKey) << 48)
  );
}

for RCTTouchEvent
viewTag: is always 0
coalescingKey: each RCTRootView's RCTTouchHandler has this value starting from 0

So set a viewTag (maybe just the target view's reactTag) for RCTTouchEvent solves this,
any other better solutions?


And one more thing, I got warning 'Cannot find single active touch.' on JS side, stack:

reactConsoleError   @   ExceptionsManager.js:76
console.error   @   YellowBox.js:59
warning @   warning.js:44
recordTouchTrack    @   ResponderTouchHistoryStore.js:174
extractEvents   @   ResponderEventPlugin.js:441
extractEvents   @   EventPluginHub.js:186
handleTopLevel  @   ReactEventEmitterMixin.js:28
(anonymous function)    @   ReactNativeEventEmitter.js:125
perform @   Transaction.js:138
batchedUpdates  @   ReactDefaultBatchingStrategy.js:63
batchedUpdates  @   ReactUpdates.js:98
_receiveRootNodeIDEvent @   ReactNativeEventEmitter.js:124
receiveTouches  @   ReactNativeEventEmitter.js:186
__callFunction  @   MessageQueue.js:193
(anonymous function)    @   MessageQueue.js:94
guard   @   MessageQueue.js:41
callFunctionReturnFlushedQueue  @   MessageQueue.js:93
onmessage   @   debuggerWorker.js:39

UIExplorer's RCTRootView example can reproduces this bug (not 100% easier on real device), try to hold the 'Embedded React Native view' and then tap the 'React Native Button'.

There's already an issue for this #79, reopen it?

@littlesome
Copy link
Author

littlesome commented Aug 22, 2016

For the first issue, after look into android's impl, I'm sure it's a bug.
Android TouchEvent
iOS RCTTouchEvent viewTag is missing

Touch event's coalesce logic is different on android and iOS,
android's TouchEvent to native MotionEvent is 1: 1 for coalescing, while
iOS's RCTTouchEvent to native UITouch is 1: N, which means 1 RCTTouchEvent may have many view's reactTags, and they all belongs to one same RCTRootView,

I think the easiest way to fix this is pass RCTRootView's tag as RCTTouchEvent's viewTag property, and I checked this works.

If this way is ok, I will send a PR.

@littlesome
Copy link
Author

For the second issue: 'Cannot find single active touch', turnning off the RCTTouchHandler for the inner view solves this warning.

@rainer-liao
Copy link

@littlesome It happened to me, too. Did you send a PR?

littlesome pushed a commit to littlesome/react-native that referenced this issue Sep 16, 2016
ghost pushed a commit that referenced this issue Sep 16, 2016
Summary:
Using target view's reactTag as viewTag for RCTTouchEvent.

Fix issue #9503
Closes #9952

Differential Revision: D3880152

Pulled By: majak

fbshipit-source-id: 1025aae6a6a1d5074496a9e4a6cf7dfebc713dc7
@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

3 participants