[Android][0.87.1] numberOfLines crashes when a decorated nested Text range is outside the truncated layout
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 75/100
調査の方向性
TextDecorationStyle.kt から始め、特に getPrimaryHorizontal の呼び出しを確認し、その後 ReactUnderlineSpan.kt と ReactStrikethroughSpan.kt を調べて、両方の装飾パスを追跡してください。npm install、npm start、npm run android を使って必須の reproducer を実行し、装飾範囲が切り詰められたレイアウトの範囲外にある場合でも、underline と line-through のどちらもクラッシュしなくなっていることを確認してください。
索引モデルが issue の本文から書いたものです。
説明
Description
On Android, a Text with numberOfLines can crash the application when a nested Text has textDecorationLine: 'underline' or 'line-through' and the decorated range starts after content that is omitted by the truncated native layout.
Both decoration types fail in the same native drawing path. This is a fatal main-thread exception rather than a redbox or a JavaScript error.
Additional context
drawSpannedDecoration() obtains start and end from the complete Spanned text, then calls layout.getPrimaryHorizontal(start/end). With numberOfLines, the native Layout can end before the decorated span. In this example, the span starts at offset 60 while the only layout line ends at offset 19, so Android throws before drawing the decoration.
Underline and line-through share this drawing function, which explains why both variants crash. A safe fix likely needs to skip or clip decoration ranges to offsets represented by the truncated Layout before calling getPrimaryHorizontal.
Relevant React Native 0.87.1 source:
TextDecorationStyle.kt, especially the calls togetPrimaryHorizontalpackages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/internal/span/ReactUnderlineSpan.ktpackages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/internal/span/ReactStrikethroughSpan.kt
This may be adjacent to #57900, which reports Android text-decoration rendering differences. This report is specifically about a fatal out-of-bounds exception caused by a decorated range outside a truncated layout.
Steps to reproduce
- Clone
[react-native-text-decoration-crash-repro](https://github.com/ouabing/react-native-text-decoration-crash-repro). npm install.npm start.npm run android.- Press Reproduce with underline or Reproduce with line-through.
The minimal trigger is:
<Text numberOfLines={1} ellipsizeMode="tail">
{'Visible first line\n\nThird paragraph\n\nHidden decorated text: '}
<Text style={{textDecorationLine: 'line-through'}}>
decorated text outside the one-line layout
</Text>
</Text>
Changing line-through to underline reproduces the same crash. Removing numberOfLines, the line breaks, or textDecorationLine avoids it.
React Native Version
0.87.1
Affected Platforms
Runtime - Android
Output of npx @react-native-community/cli info
System:
OS: macOS 26.6.1
CPU: Apple M1 Pro (arm64)
Binaries:
Node: 22.13.1
npm: 10.9.2
Java: 17.0.16
npmPackages:
react: 19.2.3
react-native: 0.87.1
Android:
Android 14 / API 34 arm64 emulator
hermesEnabled: true
newArchEnabled: true
Stacktrace or Logs
FATAL EXCEPTION: main
Process: com.rntextdecorationcrashrepro
java.lang.IndexOutOfBoundsException: offset(60) should be less than line limit(19)
at android.text.TextLine.measure(TextLine.java:389)
at android.text.Layout.getHorizontal(Layout.java:1390)
at android.text.Layout.getHorizontal(Layout.java:1366)
at android.text.Layout.getPrimaryHorizontal(Layout.java:1336)
at android.text.Layout.getPrimaryHorizontal(Layout.java:1325)
at com.facebook.react.views.text.TextDecorationStyleKt.drawSpannedDecoration(TextDecorationStyle.kt:182)
at com.facebook.react.views.text.internal.span.ReactUnderlineSpan.onDraw(ReactUnderlineSpan.kt:31)
at com.facebook.react.views.text.ReactTextView.drawTextEffects(ReactTextView.java:283)
at com.facebook.react.views.text.ReactTextView.onDraw(ReactTextView.java:227)
MANDATORY Reproducer
https://github.com/ouabing/react-native-text-decoration-crash-repro
Screenshots and Videos
No response
- 主要言語
- C++
- スター
- 127k
- フォーク
- 25.3k
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
react/react-native のほかの issue
-
Needs: Author Feedback Needs: Repro
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
react/react-native#58621 · コメント 1 件 ·
-
Needs: Author Feedback Needs: Repro
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
react/react-native#58610 · コメント 1 件 ·
-
Needs: Triage :mag:
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
react/react-native#58565 · コメント 1 件 · リアクション 2 件 ·
-
Needs: Author Feedback Needs: Repro
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
react/react-native#58555 · コメント 4 件 · リアクション 1 件 ·
-
Needs: Attention Needs: Repro
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
react/react-native#58526 · コメント 2 件 ·
react/react-native の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
AXERA-TECH/ax-llm#77 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
games-on-whales/wolf#509 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
bug-unconfirmed
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
NVIDIA/cuda-samples#453 ·