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

Issue #1152: Fix crash in _setIsFirstTouchInView and setIsTap for iOS 14 #1153

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions Additions/UITouch-KIFAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ - (void)setPhase:(UITouchPhase)touchPhase;
- (void)setGestureView:(UIView *)view;
- (void)_setLocationInWindow:(CGPoint)location resetPrevious:(BOOL)resetPrevious;
- (void)_setIsFirstTouchForView:(BOOL)firstTouchForView;
- (void)_setIsTapToClick:(BOOL)tapToClick;

- (void)_setHidEvent:(IOHIDEventRef)event;

Expand Down Expand Up @@ -65,8 +66,21 @@ - (id)initAtPoint:(CGPoint)point inWindow:(UIWindow *)window;

[self setView:hitTestView];
[self setPhase:UITouchPhaseBegan];
[self _setIsFirstTouchForView:YES];
[self setIsTap:YES];

if ([self respondsToSelector:@selector(_setIsFirstTouchForView:)]) {
[self setIsTap:YES];
[self _setIsFirstTouchForView:YES];
} else {
[self _setIsTapToClick:YES];

// We modify the touchFlags ivar struct directly.
// First entry is _firstTouchForView
Ivar flagsIvar = class_getInstanceVariable(object_getClass(self), "_touchFlags");
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we assert that the the ivar exists?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea! Given how that code writes into memory, it would corrupt the isa pointer if this is not found.

Copy link
Contributor

Choose a reason for hiding this comment

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

@dostrander ^ making sure you saw this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep added it to the xcode upgrades PR. Going to split some of the issues I found with it up today and early next week and i'll split that one out as well.

ptrdiff_t touchFlagsOffset = ivar_getOffset(flagsIvar);
char *flags = (__bridge void *)self + touchFlagsOffset;
*flags = *flags | (char)0x01;
}

[self setTimestamp:[[NSProcessInfo processInfo] systemUptime]];

if ([self respondsToSelector:@selector(setGestureView:)]) {
Expand Down