Return early from textview layout pass if text layout is null
Summary: Could not repro myself, but logview shows steady low number of crashes coming from this mid. Current fix returns early if the layout is not defined, relying on the following layout passes to position view correctly. Changelog: [Android][Fixed] Exit early from layout in textview if text layout is null Reviewed By: JoshuaGross Differential Revision: D29636040 fbshipit-source-id: 876ce80222cbc5ff09450224f6808f9f6433c62a
This commit is contained in:
Родитель
ca440b9100
Коммит
8dfc3bcda1
|
@ -124,6 +124,17 @@ public class ReactTextView extends AppCompatTextView implements ReactCompoundVie
|
||||||
|
|
||||||
Spanned text = (Spanned) getText();
|
Spanned text = (Spanned) getText();
|
||||||
Layout layout = getLayout();
|
Layout layout = getLayout();
|
||||||
|
if (layout == null) {
|
||||||
|
// Text layout is calculated during pre-draw phase, so in some cases it can be empty during
|
||||||
|
// layout phase, which usually happens before drawing.
|
||||||
|
// The text layout is created by private {@link assumeLayout} method, which we can try to
|
||||||
|
// invoke directly through reflection or indirectly through some methods that compute it
|
||||||
|
// (e.g. {@link getExtendedPaddingTop}).
|
||||||
|
// It is safer, however, to just early return here, as next measure/layout passes are way more
|
||||||
|
// likely to have the text layout computed.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
TextInlineViewPlaceholderSpan[] placeholders =
|
TextInlineViewPlaceholderSpan[] placeholders =
|
||||||
text.getSpans(0, text.length(), TextInlineViewPlaceholderSpan.class);
|
text.getSpans(0, text.length(), TextInlineViewPlaceholderSpan.class);
|
||||||
ArrayList inlineViewInfoArray =
|
ArrayList inlineViewInfoArray =
|
||||||
|
|
Загрузка…
Ссылка в новой задаче