[iOS] App hangs on iOS 27: SimpleThreadSafeCache runs text measurement while holding its lock
维护者通常 2 天内回复
还没有人认领这个 Issue。
- #59614 来自 @kasik96 —— 已关闭,未合并
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 20/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- cpp, ios, react-native
- 领域
- mobile, performance
调研方向
Read SimpleThreadSafeCache::getMapIterator and the unit test in #59614, which the issue says demonstrates the lock problem without iOS. Trace how TextLayoutManager uses the cache and how a cache miss runs its generator while the mutex is held. The issue links fix #59614, which is closed and unmerged; check that work before starting.
由索引模型根据 Issue 内容生成。
描述
Description
On iOS 27 devices, an app can hang for good when the JS thread and the main thread measure text at the same time.
SimpleThreadSafeCache::getMapIterator holds mutex_ while it runs the generator for a cache miss. TextLayoutManager uses this cache for text measurement, and on iOS the generator creates an NSTextStorage. On iOS 27 devices, -[NSTextStorage processEditing] posts a notification that waits for the main queue (_CFXNotificationPost → -[NSOperation waitUntilFinished]).
If the main thread measures text at that moment, for example in a synchronous commit from Reanimated, it waits for mutex_:
- JS thread: holds
mutex_and waits for the main queue. - Main thread: waits for
mutex_.
The observer that the notification waits for comes from iOS, not from app code. The iOS 27.0 simulator does not wait there, so the hang shows only on devices (seen on iOS 27.0.1 and 27.2).
The same code is on main.
Steps to reproduce
- Run on a device with iOS 27.
- Render a list of about 100 rows with text, and run a Reanimated animation.
- Replace the list data while the animation runs.
The app hangs within a few tries.
To see it on the simulator, first add a main-queue observer in lldb:
expr -l objc -- (id)[[NSNotificationCenter defaultCenter] addObserverForName:@"NSTextStorageDidProcessEditingNotification" object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *n){}]
React Native Version
0.86.3
Affected Platforms
Runtime - iOS
Output of npx @react-native-community/cli info
System:
OS: macOS 27.0.1
CPU: (10) arm64 Apple M1 Pro
Binaries:
Node: 24.14.1
Yarn: 4.3.1
npm: 11.11.0
Managers:
CocoaPods: 1.16.2
IDEs:
Xcode: 26.6/17F113
npmPackages:
react: 19.2.3
react-native: 0.86.3
react-native-reanimated: 4.5.1
iOS:
hermesEnabled: true
newArchEnabled: true
Stacktrace or Logs
Main thread:
reanimated::ReanimatedModuleProxy::commitUpdates
facebook::react::ShadowTree::commit
facebook::react::RootShadowNode::layoutIfNeeded
...
facebook::react::ParagraphShadowNode::measureContent
facebook::react::TextLayoutManager::measure
facebook::react::SimpleThreadSafeCache<...>::getMapIterator
std::mutex::lock
JS thread:
facebook::react::UIManager::completeSurface
facebook::react::ShadowTree::commit
facebook::react::RootShadowNode::layoutIfNeeded
...
facebook::react::TextLayoutManager::measure
facebook::react::SimpleThreadSafeCache<...>::getMapIterator
-[RCTTextLayoutManager measureAttributedString:paragraphAttributes:layoutContext:layoutConstraints:]
-[RCTTextLayoutManager _textStorageAndLayoutManagerWithAttributesString:paragraphAttributes:size:]
-[NSConcreteTextStorage initWithAttributedString:]
-[NSTextStorage processEditing]
-[NSNotificationCenter postNotificationName:object:userInfo:]
_CFXNotificationPost
-[NSOperation waitUntilFinished]
Reproducer
No standalone reproducer: the hang needs an iOS 27 device, or the lldb step above. The unit test in #59614 shows the lock problem without iOS.
Fix: #59614
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.4k
- 平均合并
- 3 天 8 小时
- 30 天内合并 PR
- 118
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
react/react-native 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
react/react-native#59722 ·
维护者通常 2 天内回复
-
Android: new WebSocket() crashes the app for a URL that OkHttp or java.net.URI rejects可能已有人在做 @sorinc03 于 3 天前认领。 未关闭🌐Networking Needs: Author Feedback Needs: Repro Platform: Android
难度 2/5 1-3 小时 新手友好度 72/100
react/react-native#59704 · 1 条评论 ·
维护者通常 2 天内回复
-
On the nightly, @react-native-community/cli 20 finds no platforms or commands, with no warning that it needs CLI 21可能已有人在做 @LuisPeixoto 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
react/react-native#59694 ·
维护者通常 2 天内回复
-
Image.resolveAssetSource's TypeScript declaration drops the null it returns for an unknown asset可能已有人在做 @Hassan1305 于 5 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
react/react-native#59648 · 1 条评论 ·
维护者通常 2 天内回复
-
Linking.getInitialURL() returns the task's first link after a link relaunches a reclaimed Android app可能已有人在做 @YevheniiKotyrlo 于 22 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
react/react-native#59006 · 2 条评论 ·
维护者通常 2 天内回复
查看 react/react-native 的全部 Issue
相似的 Issue
-
Linux npm packaging leaves workspace files that block subsequent CI checkout可能已有人在做 @Spockkk0225 今天认领。 未关闭ci
难度 2/5 1-3 小时 新手友好度 73/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 3 天内回复
-
QA/No release-notes/exclude tests tests/missing-coverage tests/test-quality
难度 2/5 1-3 小时 新手友好度 71/100
brave/brave-browser#61019 ·
维护者通常 1 天内回复
-
? - Needs Triage bug CUTLASS C++
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 4 天内回复