Skip to content

Remove iOSCoreAnimationBorderRendering RN patch causing HybridApp iOS AppHang (APP-8K6)#95447

Merged
mountiny merged 2 commits into
Expensify:mainfrom
KJ21-ENG:KJ21-ENG/95194-ios-apphang-mounting-manager
Jul 9, 2026
Merged

Remove iOSCoreAnimationBorderRendering RN patch causing HybridApp iOS AppHang (APP-8K6)#95447
mountiny merged 2 commits into
Expensify:mainfrom
KJ21-ENG:KJ21-ENG/95194-ios-apphang-mounting-manager

Conversation

@KJ21-ENG

@KJ21-ENG KJ21-ENG commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

This fixes the HybridApp iOS fatal App Hang reported in Sentry APP-8K6, where the main thread was blocked for 2000ms+ inside RCTMountingManager performTransaction with Core Animation deep in CA::Layer::collect_animations_.

The hang is caused by an App-owned React Native patch, react-native+0.83.1+008+iOSCoreAnimationBorderRendering.patch. That patch wraps every Fabric mount transaction in RCTMountingManager.mm inside an explicit [CATransaction begin] / setDisableActions / [CATransaction commit] block:

[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
mountingCoordinator.getTelemetryController().pullTransaction(...);
[CATransaction commit];

performTransaction is dispatched onto the main queue. When no implicit CATransaction is already open on that run-loop turn, the patch's begin becomes the outermost transaction, so its commit flushes the layer tree to the render server synchronously on the main thread instead of coalescing into Core Animation's normal end-of-run-loop flush. In HybridApp that layer tree is the combined OldDot UIKit + NewDot Fabric hierarchy, so the synchronous collect_animations_ walk can exceed the 2s AppHang threshold — which is exactly the RCTMountingManager → performTransaction → collect_animations_ stack Sentry captures.

The patch was originally added in #40243 (taken from facebook/react-native#42604) to work around a border/background stretching issue during navigation transitions. As the C+ reviewer confirmed on the issue, that underlying issue was fixed upstream in React Native 0.73.6 by d9794916b (RN #42922"remove animation from borderLayer to stop unwanted animations"), which removes the implicit animation directly on the border layer in RCTViewComponentView.mm. This app is now on React Native 0.83.1, so that upstream fix is already present and the broad mount-time workaround is no longer needed.

This PR therefore removes the patch entirely (and its entry in patches/react-native/details.md), which eliminates the outermost synchronous CATransaction commit during Fabric mounts while relying on the upstream border-rendering fix already shipped in RN 0.83.1. The removal is validated by the #40243 border/background regression check in the Tests section below.

No automated test fixture is added: the patch is removed outright, so there is no narrowed patch left in the repo to assert against, and per the C+ reviewer's plan the fix is confirmed by monitoring Sentry APP-8K6 after release rather than by a unit test.

Fixed Issues

$ #95194
PROPOSAL: #95194 (comment)

Tests

This change removes a native iOS React Native patch, so it must be validated on an iOS HybridApp build. Removing the patch takes effect only after patches are re-applied, so start from a clean install.

  1. Check out this branch and run npm install (this re-runs scripts/applyPatches.sh, so the removed patch is no longer applied to node_modules/react-native). Verify it completes with no patch-package errors or Warning: lines — this confirms the remaining patches, in particular 035+fix-pressability-new-arch which also edits RCTMountingManager.mm, still apply cleanly after 008 is removed.
  2. Confirm the patch is gone: ls patches/react-native/ | grep 008 returns nothing, and node_modules/react-native/React/Fabric/Mounting/RCTMountingManager.mm no longer contains a [CATransaction begin] wrapper around the pullTransaction call in RCTPerformMountInstructions. (Patch 035's measureAsyncOnUI: addition near @end in the same file should still be present — that is expected.)
  3. Build and launch the HybridApp iOS app on a device/simulator.
  4. Regression check for the original [Fabric] iOS - Stretched border animations between screen transitions #40243 issue (stretched border animations between screen transitions), on the reimbursement account page (same flow [Fabric] iOS - Stretched border animations between screen transitions #40243 was verified with). Precondition: be logged in with a workspace that has Workflows enabled.
    1. Go to Workspace > Workflows and tap Connect bank account.
    2. Select Connect manually, enter the test routing and account numbers, and confirm.
    3. When the Personal info page appears, verify there is no random/inconsistent stretched border animation on the Legal first name field or on the step numbers at the top of the page.
    4. Fill the form and continue. When the Date of birth page appears, verify there is no stretched border animation on the calendar.
    5. Select a date and continue. When the SSN page appears, verify there is no stretched border animation on the SSN field.
    6. Tap the back arrow through the previous steps and verify no stretched border animation appears on the step numbers or form fields while navigating back.
  5. Exercise heavy screens from the OldDot → NewDot handoff (large LHN, Search results, long reports) and verify the app remains responsive during mounts (no visible main-thread stall / freeze).
  6. Spot-check third-party Fabric-rendered surfaces on iOS (e.g. maps, Lottie animations, FlashList scroll recycling, video, tab-view swipes) and verify newly mounted views do not show an unexpected first-frame implicit fade/animation.
  7. Verify that no errors appear in the JS console.

Note: APP-8K6 is a probabilistic, timing/scale-dependent AppHang that is not deterministically reproducible by user steps. Its resolution is confirmed by monitoring Sentry for new APP-8K6 events (stack under RCTMountingManager + CA::Layer::collect_animations_) after this ships, per the C+ reviewer's plan to remove the patch and monitor.

Offline tests

This change only removes a native iOS Core Animation transaction wrapper around Fabric mounts and does not modify any network, data, or offline logic. There is no offline-specific behavior affected by this PR.

  1. Verify that no errors appear in the JS console.

QA Steps

Requires a HybridApp iOS staging build. There is no user-facing UI change — this is a native-rendering regression check.

  1. Open the HybridApp iOS app on staging, logged in with a workspace that has Workflows enabled.
  2. Go to Workspace > Workflows and tap Connect bank account, then select Connect manually and enter the test routing and account numbers.
  3. Step through the flow (Personal info → Date of birth → SSN) and back again, and verify there is no random/inconsistent stretched border animation on the form fields, the calendar, or the step numbers at the top of the page (regression check for [Fabric] iOS - Stretched border animations between screen transitions #40243).
  4. Navigate between other screens with bordered / background-colored elements (reports, workspace lists, settings) and verify borders and backgrounds render correctly with no stretching, flicker, or transient animation.
  5. Verify the app remains responsive during these transitions on heavy screens (no freeze/hang).
  6. Verify that no errors appear in the JS console.

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
ezyZip.72.mp4
iOS: mWeb Safari
MacOS: Chrome / Safari

… AppHang (APP-8K6)

The patch wrapped every Fabric mount in RCTMountingManager.mm in an explicit
[CATransaction begin]/setDisableActions/[CATransaction commit] block. When no
implicit CATransaction was already open, its commit flushed the layer tree to
the render server synchronously on the main thread (CA::Layer::collect_animations_),
which on the large HybridApp combined UIKit+Fabric tree could exceed the 2s
AppHang threshold (Sentry APP-8K6).

The border/background-stretching issue this patch worked around (Expensify#40243, from
react/react-native#42604) was fixed upstream in RN 0.73.6 (d9794916b, RN
Expensify#42922) and is already present in RN 0.83.1, so the workaround is no longer
needed. Removes the patch and its details.md entry.
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

⚠️ This PR is possibly changing native code and/or updating libraries, it may cause problems with HybridApp. Please check if any patch updates are required in the HybridApp repo and run an AdHoc build to verify that HybridApp will not break. Ask Contributor Plus for help if you are not sure how to handle this. ⚠️

@KJ21-ENG KJ21-ENG marked this pull request as ready for review July 7, 2026 08:16
@KJ21-ENG KJ21-ENG requested a review from a team as a code owner July 7, 2026 08:16
@melvin-bot melvin-bot Bot requested review from bernhardoj and removed request for a team July 7, 2026 08:17
@melvin-bot

melvin-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown

@bernhardoj 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]

@bernhardoj

Copy link
Copy Markdown
Contributor

Navigate repeatedly between screens with bordered / background-colored elements

@KJ21-ENG Since we need to make sure we don't regress #40243, let's update it to be more specific by testing it on the reimbursement account page.

Also, complete the checklist and recordings.

@bernhardoj

Copy link
Copy Markdown
Contributor

Also, merge with main please

@KJ21-ENG

KJ21-ENG commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

@bernhardoj Done!

@bernhardoj

Copy link
Copy Markdown
Contributor

429: Too Many Requests
For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service).

1 similar comment
@bernhardoj

Copy link
Copy Markdown
Contributor

429: Too Many Requests
For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service).

@bernhardoj

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
ios.mp4
iOS: mWeb Safari
MacOS: Chrome / Safari

@melvin-bot melvin-bot Bot requested a review from mountiny July 9, 2026 05:52
@bernhardoj

Copy link
Copy Markdown
Contributor

This PR is possibly changing native code and/or updating libraries, it may cause problems with HybridApp. Please check if any patch updates are required in the HybridApp repo and run an AdHoc build to verify that HybridApp will not break.

No library update, so no need to update the Mobile-Expensify repo.

@mountiny mountiny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@mountiny mountiny merged commit df5bac9 into Expensify:main Jul 9, 2026
25 of 28 checks passed
@OSBotify

OSBotify commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
Built from App PR #95447.

Android 🤖 iOS 🍎
❌ FAILED ❌ https://ad-hoc-expensify-cash.s3.us-east-1.amazonaws.com/rock-artifacts/ad-hoc/rock-ios-device-AdHoc-df5bac9-3ded924-060e6da5d4ced56a2f15ac08a064d4f485845238/index.html
The QR code can't be generated, because the Android build failed iOS
Web 🕸️
https://95447.pr-testing.expensify.com
Web

👀 View the workflow run that generated this build 👀

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.4.33-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 cancelled 🔪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants