Text visually truncated mid-word despite correct onLayout/onTextLayout measurement
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 32/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- android, ios, react-native
- Domínio
- mobile
Direção de pesquisa
Comece pelo reproducer rn-font-issue vinculado e pelo README correspondente, depois execute npm install && npx expo run:ios e inspecione os logs do Metro [REPRO]. Compare as medições de onLayout e onTextLayout enquanto reproduz a truncagem visual. Considera-se concluído quando o parágrafo for renderizado completamente sem a divergência relatada nas plataformas afetadas.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Description
A multi-line <Text> inside a list (FlatList, @shopify/flash-list, or
even a plain ScrollView) is sometimes visually truncated mid-word,
even though onLayout / onTextLayout report a correct and complete
measurement for the same text.
Evidence gathered from a minimal, isolated repro:
onLayoutsometimes reports a height that doesn't matchonTextLayout's
own measured content — either a tiny fractional value (e.g.
479.99993896484375instead of exactly480), or a value roughly one
whole line taller than whatonTextLayoutitself measured as needed
(e.g. container288/12 lines vs text measured at264/11 lines).onTextLayout, for the exact same text and style, can report a
differentlines.lengthbetween two mounts, with the container width
strictly constant.- Despite
onTextLayoutreporting the correct, complete text (including
its exact final characters), the visual render sometimes stops mid-word,
with blank space left where the missing text should be — a divergence
between a correct measure pass and an incomplete native paint pass.
This was first found in a production app and then isolated down to a
minimal case. The following were tested and ruled out as the cause:
- Any specific list component: reproduces identically with
@shopify/flash-list, coreFlatList, and a plainScrollView. - Custom fonts: reproduces identically with the system font (no
fontFamilyset at all). - Special characters: reproduces with plain ASCII English text, no accents,
no quotation marks, periods only. - Insufficient container height:
onLayoutsometimes reserves more
height thanonTextLayoutmeasured as necessary, and the text is still
visually truncated. - A component remount (
keychange): the bug survives a full remount. - A text-measurement cache keyed by content: making every occurrence of a
repeated paragraph textually unique did not spread the bug to more
occurrences.
The bug is intermittent and appears to depend on rendering context
(surrounding items, timing) rather than the text content or any specific
component — the exact same paragraph text reproduces at one list position
and not another, and moving it to a different position moves the
reproduction with it.
Steps to reproduce
- Clone the reproducer: https://github.com/Ge0ffreyS/rn-font-issue
npm install && npx expo run:ios- The app renders ~150 numbered paragraphs on load. Watch the Metro
console for[REPRO] onLayout ... <<< SUSPECTlog lines and look at the
screen for a paragraph whose text stops mid-word with blank space below
it. - If it doesn't reproduce on first load, reload the app a few times
(Cmd+R in the simulator) — it's intermittent. A "Scroll to bottom"
button is provided to check paragraphs further down the list.
Full isolation-testing notes and commit-by-commit findings are in the
repo's README.
React Native Version
0.86.2
Affected Platforms
Runtime - iOS, Android
This minimal repro was tested on iOS (simulator). The underlying text
truncation was also observed on Android (16 / API 36) with the same
fontSize/lineHeight in the production app this repro was extracted
from, though not exhaustively isolated there.
Environment
OS: macOS 26.6.1
Node: 22.23.2
expo: ~57.0.12
react: 19.2.3
react-native: 0.86.2
(npx react-native info doesn't run standalone in this Expo-managed repro;
the versions above are read directly from package.json.)
Stacktrace or Logs
[REPRO] onTextLayout lineCount=11 height=264 lastLineText="...This is repeat number 1." text="18. A former head chef says th..."
[REPRO] onLayout height=287.999755859375 text="18. A former head chef says th..." <<< SUSPECT
onTextLayout measured 11 lines (264px, correct, complete text) but the
container (onLayout) reserved 288px (12 lines) — a full line more than
what was measured as necessary — and the paragraph is visually cut off
mid-word regardless.
Reproducer
- Linguagem predominante
- C++
- Estrelas
- 127k
- Forks
- 25.3k
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de react/react-native
-
Needs: Author Feedback Needs: Repro
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
react/react-native#58659 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
Needs: Author Feedback Needs: Repro
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 92/100
react/react-native#58621 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Needs: Author Feedback Needs: Repro
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
react/react-native#58610 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Needs: Triage :mag:
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
react/react-native#58565 · 1 comentário · 2 reações ·
Mantenedores costumam responder em até 1 dia
-
Needs: Author Feedback Needs: Repro
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
react/react-native#58555 · 5 comentários · 2 reações ·
Mantenedores costumam responder em até 1 dia
Todas as issues de react/react-native
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 90/100
Mantenedores costumam responder em até 1 dia
-
type: bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
RobotLocomotion/drake#25023 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
mamedev/mame#16263 · 4 comentários ·
Mantenedores costumam responder em até 1 dia