[ReactNative] Native touch unique identifier
Summary: This bug was causing a redbox when touching rapidly because multiple touches had the same identifier. This code was meant to ensure that a unique ID is found, but it was checking against the wrong property in the react touch array. I don't think this was really affecting prod, because the invariant is guarded by a __DEV__ check @public Test Plan: - Start several touches at once (or just rapidly jam fingers on your device), and you won't see a redbox - Also verify that single touches, touch moves, and multi touches work as before
This commit is contained in:
parent
30fc7389d1
commit
f744c7c444
|
@ -89,11 +89,11 @@ typedef NS_ENUM(NSInteger, RCTTouchEventType) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get new, unique touch id
|
// Get new, unique touch identifier for the react touch
|
||||||
const NSUInteger RCTMaxTouches = 11; // This is the maximum supported by iDevices
|
const NSUInteger RCTMaxTouches = 11; // This is the maximum supported by iDevices
|
||||||
NSInteger touchID = ([_reactTouches.lastObject[@"target"] integerValue] + 1) % RCTMaxTouches;
|
NSInteger touchID = ([_reactTouches.lastObject[@"identifier"] integerValue] + 1) % RCTMaxTouches;
|
||||||
for (NSDictionary *reactTouch in _reactTouches) {
|
for (NSDictionary *reactTouch in _reactTouches) {
|
||||||
NSInteger usedID = [reactTouch[@"target"] integerValue];
|
NSInteger usedID = [reactTouch[@"identifier"] integerValue];
|
||||||
if (usedID == touchID) {
|
if (usedID == touchID) {
|
||||||
// ID has already been used, try next value
|
// ID has already been used, try next value
|
||||||
touchID ++;
|
touchID ++;
|
||||||
|
|
Loading…
Reference in New Issue