[iOS] App hangs on iOS 27: SimpleThreadSafeCache runs text measurement while holding its lock
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
- #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時間
- マージ済み PR(30日)
- 118
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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
alibaba/neug#1195 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 3 日以内に返信