Permalink
Browse files

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
  • Loading branch information...
shergin authored and facebook-github-bot committed Sep 19, 2017
1 parent a43a988 commit 6b11259c46f3133ee48a21561fe0dab58cee6847
Showing with 4 additions and 1 deletion.
  1. +4 −1 Libraries/Text/RCTShadowText.m
@@ -220,7 +220,10 @@ - (NSTextStorage *)buildTextStorageForWidth:(CGFloat)width widthMode:(YGMeasureM
}
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];

0 comments on commit 6b11259

Please sign in to comment.