Skip to content

Soft-fail Fabric addViewAt into a non-ViewGroup parent and backport upstream differ fix (APP-K0G) - #102901

Merged
mountiny merged 2 commits into
mainfrom
claude-fabricAddViewAtNonViewGroupParent
Oct 7, 2026
Merged

mountiny merged 2 commits into
mainfrom
claude-fabricAddViewAtNonViewGroupParent

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Sentry APP-K0G is a fatal Android Fabric crash: IllegalStateException: Unable to add a view into a view that is not a ViewGroup, thrown from SurfaceMountingManager.addViewAt. It still fires on 9.4.94-0, after #101057 shipped in 9.4.93-3. That PR removed one source of out-of-order mounts but not the others.

This PR adds two React Native patches:

  1. +045 – soft-fail addViewAt when the parent is not a ViewGroup. RN 0.86.0 throws when the parent tag has a ViewState whose view is null or not a ViewGroup. The usual cause is a placeholder ViewState with no view, which updateEventEmitter creates for a tag Java no longer has. IntBufferBatchMountItem is not retryable, so the throw crashes the app. The patch logs a ReactNoCrashSoftException (including the parent view class) and skips the insert. This matches upstream's change for the same condition in removeViewAt (3f553d7) and how addViewAt already handles a missing parent ViewState. Trade-off: the child view can be missing until the next render rebuilds that parent, instead of the app crashing.
  2. +046 – backport upstream differ fix 361bc24. In a nested flatten/unflatten, the differ could create a view that was still mounted, or delete one that only moved. It also stored a pointer to a loop-local copy in unvisitedRecursiveChildPairs. Wrong mutations like these leave the native tree out of sync with the shadow tree, which is one source of this crash family. The only change from upstream: 0.86.0's DiffMap has no contains, so the patch uses find(...) != end().

Both patches are documented in patches/react-native/details.md.

Note: App does not register a ReactSoftExceptionLogger listener, so the new soft exception goes to logcat, not Sentry. A drop in APP-K0G events on the release that includes this PR is the signal that it worked.

AI Tests:

  • ./scripts/validatePatches.sh – passed
  • npm run spell-changed – passed
  • Both patches apply cleanly on top of the existing +001–+044 patches (git apply against the patched node_modules/react-native@0.86.0)
  • Not run locally: native Android/iOS builds. The +046 C++ change also affects iOS, so CI's native build jobs are the compile check for both patches.

Fixed Issues

$ #102741
PROPOSAL: #102741 (comment)

Tests

There are no reliable steps to reproduce APP-K0G. The crash comes from a native mount race, not from a specific screen. These are smoke tests for the native mounting code that the patches change. Run them on Android and iOS native. +045 is Android-only. +046 is shared C++ and affects both platforms. Web and mWeb don't use this code, so for those just check that the app loads and works as usual.

  1. Sign in and stay on the Inbox. Scroll the chat list fast, up and down, a few times.
  2. Open 5–6 different chats in quick succession. Go back to the Inbox between each one.
  3. In a chat, send a few messages quickly. Long-press a message, add a reaction, then edit the message and save.
  4. Open and close the emoji picker and the keyboard a few times.
  5. Tap the green FAB > Create expense. Go one or two steps into the flow, then go back out.
  6. Open a chat's details page, then close it quickly. Repeat a few times.
  7. Go to Reports. Switch between the tabs, apply a filter, scroll the list, and long-press an item to enter selection mode, then exit it.
  8. Verify the app does not crash at any step and that no views are missing or blank.
  • Verify that no errors appear in the JS console

Offline tests

N/A. The change only affects how native views are mounted. It has no network behavior.

QA Steps

There are no reliable steps to reproduce APP-K0G. Smoke test on Android HybridApp and iOS HybridApp:

  1. Sign in and stay on the Inbox. Scroll the chat list fast, up and down, a few times.
  2. Open 5–6 different chats in quick succession. Go back to the Inbox between each one.
  3. In a chat, send a few messages quickly. Long-press a message, add a reaction, then edit the message and save.
  4. Tap the green FAB > Create expense. Go one or two steps into the flow, then go back out.
  5. Go to Reports. Switch between the tabs, apply a filter, and scroll the list.
  6. Verify the app does not crash at any step and that no views are missing or blank.
  • 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 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 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.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • 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
iOS: mWeb Safari
MacOS: Chrome / Safari

…pstream differ fix (APP-K0G)

Co-authored-by: Eugene Voloshchak <eVoloshchak@users.noreply.github.com>
@MelvinBot
MelvinBot requested a review from a team October 2, 2026 14:40
Co-authored-by: Eugene Voloshchak <eVoloshchak@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

I created this PR from an upstream branch since I don't have push access to your fork.

To take ownership of this branch and be able to push updates, run:

git remote add upstream https://github.com/Expensify/App.git
git fetch upstream claude-fabricAddViewAtNonViewGroupParent
git checkout -b claude-fabricAddViewAtNonViewGroupParent upstream/claude-fabricAddViewAtNonViewGroupParent
git push -u origin claude-fabricAddViewAtNonViewGroupParent

Then you can close this PR and open a new one from your fork.

@eVoloshchak

Copy link
Copy Markdown
Contributor

@codex review

@eVoloshchak

eVoloshchak commented Oct 5, 2026 •

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 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
    • 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
    • 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 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.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • 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
screen-20261006-114534-1791279914321.mp4
Android: mWeb Chrome Screenshot_1791279167
iOS: HybridApp Simulator Screenshot - iPhone 17 - 2026-10-06 at 11 36 27
iOS: mWeb Safari Simulator Screenshot - iPhone 17 - 2026-10-06 at 11 34 47
MacOS: Chrome / Safari Screenshot 2026-10-06 at 11 31 19

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 8bb9793c2a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@eVoloshchak

Copy link
Copy Markdown
Contributor

Not sure if there are concrete steps to reproduce this (couldn't find them in the error trace), so just did some smoke testing to verify nothing is broken
@MelvinBot, please include the test steps (if any) in the autor checklist; if not - just a couple of tests to verify nothing is broken

@MelvinBot

Copy link
Copy Markdown
Contributor Author

I added smoke-test steps to the Tests and QA Steps sections. I also marked Offline tests as N/A. There are no reliable repro steps for APP-K0G, because the crash comes from a native mount race and not from one screen.

The steps cover the screens that re-render the most: fast scrolling in the Inbox, switching chats quickly, message actions, the create-expense flow, and Reports filters. Run them on Android and iOS native. +045 only affects Android. +046 is shared C++ code, so it affects both platforms. Web doesn't use this code, so I didn't run a web test.


view run

@eVoloshchak eVoloshchak 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.

LGTM
@MelvinBot, check off every checkbox in the PR author checklist and mark this ready for review

@melvin-bot
melvin-bot Bot requested a review from mountiny October 6, 2026 10:05
@MelvinBot

Copy link
Copy Markdown
Contributor Author

I checked off all 43 boxes in the PR Author Checklist.

I couldn't mark the PR ready for review. That action isn't allowed in my environment. Please click Ready for review yourself.


view run

@eVoloshchak

eVoloshchak commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

@MelvinBot, this is ready for review, mark it as ready

@MelvinBot
MelvinBot marked this pull request as ready for review October 7, 2026 17:22
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Done. This PR is now marked as ready for review.


view run

@melvin-bot
melvin-bot Bot requested review from eVoloshchak and removed request for a team October 7, 2026 17:22
@melvin-bot

melvin-bot Bot commented Oct 7, 2026

Copy link
Copy Markdown

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-07T17:28:07.960194Z 8bb9793 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

@MelvinBot is this the same patch that's required for this issue? #103369 cc @collectioneur

@MelvinBot

Copy link
Copy Markdown
Contributor Author

No, it's not the same patch. [Sentry: APP-H7A] Fabric removeViewAt crashes removing view from non-ViewGroup parent needs a separate patch, but it should follow the same approach.

  • +045 in this PR only changes addViewAt, which is the APP-K0G crash. It doesn't touch removeViewAt, so APP-H7A still throws (patch).
  • APP-H7A needs a new patch that backports react-native@3f553d7. It swaps the removeViewAt throw for a soft exception, the same way +045 handles addViewAt. No patch on main does this yet.
  • +046 in this PR (the differ backport) may help both crashes because it removes one way the native tree drifts out of sync. It won't stop the removeViewAt throw by itself (patch).

You can add the removeViewAt patch to this PR as +047 or open a separate PR for it.


view run

@mountiny
mountiny merged commit 479b3e8 into main Oct 7, 2026
41 of 43 checks passed
@mountiny
mountiny deleted the claude-fabricAddViewAtNonViewGroupParent branch October 7, 2026 19:23
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

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

@OSBotify

OSBotify commented Oct 7, 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.

@OSBotify OSBotify mentioned this pull request Oct 7, 2026
68 tasks done
@OSBotify

OSBotify commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

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

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

@OSBotify

OSBotify commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/puneetlath in version: 9.5.5-2 🚀

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

Bundle Size Analysis (Sentry):

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