Permalink
Browse files

Summary:

Calling -[UIScrollView setContentOffset] with NaN values can cause a crash. That's not clear why exactly the computation returns NaN sometime, but the implemented sanitizing should help to detect this problem during development (and this also prevents the app from crashing).

See attached task for more details.

Reviewed By: fkgozali

Differential Revision: D13242729

fbshipit-source-id: 747bf1b42e02597e9f1300eee24547563ab29b27
  • Loading branch information...
shergin authored and grabbou committed Nov 29, 2018
1 parent 747b5e4 commit f6566c77b128f22ae3eaa413ab04de94ea639281
Showing with 4 additions and 1 deletion.
  1. +4 −1 React/Views/ScrollView/RCTScrollView.m
@@ -303,7 +303,10 @@ - (void)setContentOffset:(CGPoint)contentOffset
contentOffset.y = -(scrollViewSize.height - subviewSize.height) / 2.0;
}
}
super.contentOffset = contentOffset;

super.contentOffset = CGPointMake(
RCTSanitizeNaNValue(contentOffset.x, @"scrollView.contentOffset.x"),
RCTSanitizeNaNValue(contentOffset.y, @"scrollView.contentOffset.y"));
}

- (void)setFrame:(CGRect)frame

0 comments on commit f6566c7

Please sign in to comment.