[0.88] Fix Android crash drawing text decorations in numberOfLines-truncated Text
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
Research direction
Read the two linked commits in order, focusing on TextDecorationStyle.kt and TextDecorationStyleTest. Reproduce the crash with Android text decorations inside a numberOfLines-truncated Text, then run the focused tests. Done when the crash is fixed, partially visible decoration reaches the ellipsis, and empty or fully hidden ranges are covered.
Written by the indexing model from the issue text.
Description
Target Branch
0.88
Link to commit or PR to be picked
https://github.com/react/react-native/commit/ca8504b1caa9f79152cc14fcc6c0d7e46ada2633 and https://github.com/react/react-native/commit/dbd5b3b770039b86cf8c538cb52eb860717d0e88
Description
Picks #58366 (merged to main as ca8504b) and its follow-up #59050 (merged as dbd5b3b). Together they fix a crash in Android text decoration drawing, which is new in 0.88 (#56768).
Problem: Since 0.88, Android draws underline and line-through itself (ReactUnderlineSpan / ReactStrikethroughSpan → drawSpannedDecoration). It passes the span's offsets from the full text to Layout.getPrimaryHorizontal(). When numberOfLines truncates the text before the decorated span ends, this throws IndexOutOfBoundsException: offset(N) should be less than line limit(M) from onDraw and the app crashes. 0.87 doesn't crash here, because the platform UnderlineSpan handled truncation.
Impact: We hit this in our production app right after moving to 0.88.0 (Expo SDK 58). Café descriptions are collapsed with numberOfLines={3}, and glossary terms inside them are nested Text with textDecorationLine: 'underline'. A screen whose underlined term sat past the third line crashed as soon as it opened, and collapsing an expanded description crashed too. Any app with an underlined or struck-through nested Text inside a truncated Text can hit this, and the result is a crash, not a rendering glitch.
Risk: Low. Both commits only change TextDecorationStyle.kt (clamp the offsets to the last position the truncated, possibly ellipsized layout can resolve; skip empty and fully hidden ranges) and add tests to TextDecorationStyleTest. Applied in order, they apply cleanly to 0.88-stable. We're carrying them as a local patch on 0.88.0 for now, which means building React Native from source on Android, since the prebuilt react-android can't be patched. With the patch the crash no longer reproduces on an Android emulator, and partially visible terms are underlined up to the ellipsis.
- Dominant language
- No language data
- Stars
- 429
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from reactwg/react-native-releases
-
Type Pick Request
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
reactwg/react-native-releases#1435 · 1 comment ·
-
Type Pick Request
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
reactwg/react-native-releases#1427 · 1 comment ·
-
Type Pick Request
Difficulty 1/5 Under an hour Newbie friendliness 78/100
reactwg/react-native-releases#1349 · 1 comment · 1 reaction ·
-
Type Pick Request
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
reactwg/react-native-releases#1326 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 35/100
reactwg/react-native-releases#1458 ·
All issues in reactwg/react-native-releases
Similar issues
-
documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
jainam6610/calm-ui#11 ·
Maintainers usually reply within 1 day
-
bug e2e-testing mobile P2 XS
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
-
Toast NotificationsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
open-learning-exchange/myplanet#18392 ·
Maintainers usually reply within 2 days