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
This commit is contained in:
Valentin Shergin
2018-12-12 16:55:53 +00:00
committed by Lorenzo Sciandra
parent 83d1e85263
commit b739c115f9
+4 -1
View File
@@ -303,7 +303,10 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
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