[No QA] [APP-7B2] Fix iOS deadlock in ComponentDescriptorRegistry::add() during HybridApp transition#91736
Conversation
|
|
61bfc55 to
52860be
Compare
|
@jayeshmangwani Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
There was a problem hiding this comment.
Pull request overview
This PR adds a React Native 0.83.1 patch to prevent a fatal iOS HybridApp hang by avoiding a mutex deadlock in Fabric’s ComponentDescriptorRegistry::add() during legacy interop descriptor registration.
Changes:
- Patch
ComponentDescriptorRegistry::add()to construct component descriptors outside the registry mutex, only locking for final map insertions. - Document the new patch in
patches/react-native/details.mdwith rationale and links.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| patches/react-native/react-native+0.83.1+037+fix-deadlock-APP-7B2.patch | Moves descriptor construction outside the unique_lock to break a main-thread/background-thread deadlock scenario. |
| patches/react-native/details.md | Adds an entry describing the new patch, its motivation, and relevant upstream/E/App links. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid.movAndroid: mWeb ChromeiOS: HybridAppios.moviOS: mWeb SafariMacOS: Chrome / Safari |
|
@mountiny tested the iOS app on the simulator. I performed general testing by leaving it idle for 5 minutes, soft-killing it, and then reopening it from the background. Everything worked well, and I did not encounter any app initialization issues. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 @mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.3.84-0 🚀
Bundle Size Analysis (Sentry): |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.3.86-0 🚀
Bundle Size Analysis (Sentry): |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.3.88-0 🚀
Bundle Size Analysis (Sentry): |
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.3.88-2 🚀
|
Explanation of Change
Patches
ComponentDescriptorRegistry::add()in React Native 0.83.1 to move descriptor construction outside theunique_lock(mutex_). The lock is now only held for the two map insertions (_registryByHandle,_registryByName), breaking the deadlock where the background thread holdsunique_lockwhile waiting for the main queue (viaRCTUnsafeExecuteOnMainQueueSyncin legacy interop descriptor construction), while the main thread is blocked onshared_lockinfindComponentDescriptorByHandle_DO_NOT_USE_THIS_IS_BROKENduring an animation tick.A separate PR with a simulated reproduction exists to deterministically validate this $ #91607
Fixed Issues
$ #91292
PROPOSAL: N/A
Tests
This is a [No QA] fix - the deadlock requires a precise race condition between a native animation tick and lazy legacy interop component registration during OldDot→NewDot transition on iOS HybridApp. It cannot be reliably reproduced manually.
Probable reproduction steps (non-deterministic, narrow race window):
MigratedUserWelcomeModalGuardtriggers navigation)hasUrl: false,withBootsplash: true)Animated.timinganimation is actively ticking (SidePanelContextProviderruns on mount) and JS simultaneously creates a node for a not-yet-registered legacy interop component, the deadlock occursA deterministic reproduction is difficult because it requires precise timing, but it can be made more likely by adding artificial delay to
LegacyViewManagerInteropComponentDescriptorconstruction or adding more legacy interop components. A separate PR with a simulated local reproduction exists to validate the fix deterministically: #91607Offline tests
N/A - this is a native C++ mutex ordering fix, no network/Onyx involvement.
QA Steps
N/A, cannot be reliably reproduced without the simulated reproduction patch. The race window requires precise timing between a
CADisplayLinkanimation tick and lazy component descriptor registration during HybridApp transition.PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari