Text immediately before an `<img>` sometimes fails to repaint on iOS after a screen revisit (`EnrichedText`)
维护者通常 4 天内回复
已经有一个关联 PR 被合并了。
- #804 来自 @hejsztynx —— 已合并
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 38/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- ios, objective-c, react-native
- 领域
- mobile
调研方向
从 EnrichedTextView.mm 开始,重点查看 renderContent,并将其对 textStorage 和 layout 的处理与 EnrichedTextInputView.mm 和 _performRelayout 进行比较。通过 expo-router 或使用 react-native-screens 的 React Navigation,在 iOS 上离开并重新访问该屏幕来复现问题。完成标准是:后续访问时,紧邻 之前的文本能够始终绘制出来,同时不影响首次渲染。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
When EnrichedText renders HTML containing an <img>, the text on the line immediately before that image can fail to visually paint on iOS. The text is still present and correctly positioned (confirmed via the accessibility tree), but it never gets drawn. The rest of the surrounding content renders fine.
This issue is specifically correlated with revisiting a screen via React Navigation (@react-navigation/native + react-native-screens native-stack, via expo-router). A fresh first visit renders correctly, but navigating away and then back causes the line to reliably or intermittently fail to paint. This is an iOS-only issue and does not reproduce on Android.
Investigation ruled out JS-side remount timing issues (the bug persists even with zero remounts/key changes on revisit, or when forcing fixed-delay remounts).
To Reproduce
Steps to reproduce the behavior:
- In an app using
expo-routeror@react-navigation/native(withreact-native-screens), create a screen that rendersEnrichedText. - Provide HTML ending in a text block immediately followed by an
<img>, e.g.,...<div>Some text</div><img src="..." width="..." height="..." />. - Navigate to that screen. (Observe that it renders correctly).
- Navigate back to the previous screen.
- Navigate forward to the same screen again.
- See error: The line of text immediately before the
<img>is now blank (though still present and correctly positioned in the accessibility tree).
Expected behavior
The text immediately preceding the <img> tag should consistently paint and remain visible on subsequent visits to the screen, mirroring the behavior of the initial visit.
Screenshots
(Not applicable/No screenshot provided — visually, it manifests as empty space where the text should be).
Device (please complete the following information):
- Device: iPhone 17 Pro (iOS Simulator)
- OS: iOS 26.4
- Version:
react-native-enriched-htmlv1.1.1 (Running on React Native 0.86.3, Expo ~57.0.20, Fabric new architecture)
Additional context
Reproduction context: This issue could not be reproduced in isolation (e.g., via a Storybook story with identical HTML and remount behavior). It strictly depends on real React Navigation transition/view-controller behavior.
Potential contributing factor identified: In EnrichedTextView.mm, renderContent fully rebuilds textView.textStorage on every render but never explicitly invalidates/re-lays-out the NSLayoutManager around the changed content. This contrasts with the editable EnrichedTextInputView.mm, which works around similar TextKit gaps via _performRelayout. Patching EnrichedTextView to mirror this sequence did not reliably fix this specific bug on its own, but it highlights a potential TextKit gap.
Questions for maintainers:
- Is there a known interaction between
EnrichedTextView's render/layout cycle and view controller appearance/reappearance (e.g.,viewWillAppear/native view recycling) that could cause a stale/incomplete TextKit layout pass specifically on a view's second-or-later appearance in a navigation stack? - Are there any existing instrumentation or debug flags in the library for tracing
NSLayoutManagerinvalidation timing to help build a tighter reproduction?
- 主要语言
- C
- 星标
- 1.4k
- 派生
- 74
- 平均合并
- 3 天 8 小时
- 30 天内合并 PR
- 23
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
software-mansion/react-native-enriched-html 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 70/100
software-mansion/react-native-enriched-html#855 ·
维护者通常 4 天内回复
-
[iOS] Deadlock: measureContent dispatch_syncs to main while holding the shadow tree lock可能已有人在做 @szydlovsky 于 1 天前认领。 未关闭bug
难度 4/5 3-5 天 新手友好度 48/100
software-mansion/react-native-enriched-html#848 · 2 条评论 ·
维护者通常 4 天内回复
-
[Feature request] Vertical spacing (margins) for headings and lists in htmlStyle可能已有人在做 @henrikra 于 13 天前认领。 未关闭enhancement
难度 4/5 3-5 天 新手友好度 20/100
software-mansion/react-native-enriched-html#832 · 1 条评论 · 1 个 reaction ·
维护者通常 4 天内回复
-
[iOS] Tags not parsed on iOS below a certain string length可能已有人在做 @hejsztynx 于 21 天前认领。 未关闭bug
难度 4/5 3-5 天 新手友好度 42/100
software-mansion/react-native-enriched-html#811 · 3 条评论 ·
维护者通常 4 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 50/100
software-mansion/react-native-enriched-html#810 · 1 条评论 ·
维护者通常 4 天内回复
查看 software-mansion/react-native-enriched-html 的全部 Issue
相似的 Issue
-
[compiler-rt] Rtsan-aarch64-NoInstTest: error: no such file or directory: 'NOTFOUND' (libatomic)未关闭build-problem compiler-rt:rtsan platform:linux
难度 2/5 1-3 小时 新手友好度 63/100
llvm/llvm-project#239039 ·
维护者通常 1 天内回复
-
component:obi contribfest go test
难度 2/5 1 小时以内 新手友好度 83/100
open-telemetry/opentelemetry-ebpf-instrumentation#4143 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 64/100
checkpoint-restore/criu#3304 ·
维护者通常 1 天内回复
-
Separate Installation Commands into Individual Code Blocks可能已有人在做 @andrySD 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
colbymchenry/codegraph#3241 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复