From 6b11259c46f3133ee48a21561fe0dab58cee6847 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 19 Sep 2017 14:15:11 -0700 Subject: [PATCH] Fixed issue with measuring text with NaN width Summary: Looks like `-[NSLayoutManager ensureLayoutForTextContainer:textContainer]` has a bug that cause infinite loop inside this method during measuring some special characters AND when specified `width` equals NaN (which is useless anyways). So, we cover this case in this diff. Reviewed By: javache Differential Revision: D5859767 fbshipit-source-id: 58a5910f21f282bf5b82494916b5b02ad72d357f --- Libraries/Text/RCTShadowText.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Libraries/Text/RCTShadowText.m b/Libraries/Text/RCTShadowText.m index f7fb71110..b25c8c744 100644 --- a/Libraries/Text/RCTShadowText.m +++ b/Libraries/Text/RCTShadowText.m @@ -220,7 +220,10 @@ static YGSize RCTMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, f } textContainer.maximumNumberOfLines = _numberOfLines; - textContainer.size = (CGSize){widthMode == YGMeasureModeUndefined ? CGFLOAT_MAX : width, CGFLOAT_MAX}; + textContainer.size = (CGSize){ + widthMode == YGMeasureModeUndefined || isnan(width) ? CGFLOAT_MAX : width, + CGFLOAT_MAX + }; [layoutManager addTextContainer:textContainer]; [layoutManager ensureLayoutForTextContainer:textContainer];