[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.5k
- 平均合併
- 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
-
難度 2/5 1-3 小時 新手友好度 78/100
NVIDIA-RTX/NRI#312 ·
維護者通常 1 天內回覆
-
permute_q_b_proj / permute_wv_proj accept scale factors from another device可能已有人在做 @0z5a 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
deepseek-ai/FlashMLA#247 ·
維護者通常 1 天內回覆
-
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 天內回覆