[iOS] App hangs on iOS 27: SimpleThreadSafeCache runs text measurement while holding its lock
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
- #59614 di @kasik96 — chiusa senza merge
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 20/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- cpp, ios, react-native
- Ambito
- mobile, performance
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- C++
- Stelle
- 127k
- Fork
- 25.5k
- Merge medio
- 3g 8h
- PR unite (30g)
- 118
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di react/react-native
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
react/react-native#59722 ·
I maintainer di solito rispondono entro 2 giorni
-
Android: new WebSocket() crashes the app for a URL that OkHttp or java.net.URI rejectsForse già presa @sorinc03 l’ha presa 3 giorni fa. Aperta🌐Networking Needs: Author Feedback Needs: Repro Platform: Android
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
react/react-native#59704 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
On the nightly, @react-native-community/cli 20 finds no platforms or commands, with no warning that it needs CLI 21Forse già presa @LuisPeixoto l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
react/react-native#59694 ·
I maintainer di solito rispondono entro 2 giorni
-
Image.resolveAssetSource's TypeScript declaration drops the null it returns for an unknown assetForse già presa @Hassan1305 l’ha presa 5 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
react/react-native#59648 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Linking.getInitialURL() returns the task's first link after a link relaunches a reclaimed Android appForse già presa @YevheniiKotyrlo l’ha presa 22 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
react/react-native#59006 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di react/react-native
Issue simili
-
Linux npm packaging leaves workspace files that block subsequent CI checkoutForse già presa @Spockkk0225 l’ha presa oggi. Apertaci
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
alibaba/neug#1195 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 3 giorni
-
QA/No release-notes/exclude tests tests/missing-coverage tests/test-quality
Difficoltà 2/5 1-3 ore Idoneità per principianti 71/100
brave/brave-browser#61019 ·
I maintainer di solito rispondono entro 1 giorno
-
? - Needs Triage bug CUTLASS C++
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 4 giorni