Skip to content

Commit

Permalink
Fixed issue with measuring text with NaN width
Browse files Browse the repository at this point in the history
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 6b11259
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Libraries/Text/RCTShadowText.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 6b11259

Please sign in to comment.