Skip to content

Fix iOS image picker unresponsive on iOS 18+#83997

Draft
MelvinBot wants to merge 5 commits intomainfrom
claude-fixIosImagePickerUnresponsive
Draft

Fix iOS image picker unresponsive on iOS 18+#83997
MelvinBot wants to merge 5 commits intomainfrom
claude-fixIosImagePickerUnresponsive

Conversation

@MelvinBot
Copy link
Copy Markdown
Contributor

Explanation of Change

This PR fixes the iOS image picker becoming unresponsive when navigating to Global Create > Create Expenses > Scan > Choose from Gallery.

There are two compounding issues causing this on iOS 18+:

  1. Modal dismiss race condition: The setTimeout(200ms) delay in AttachmentPicker.selectItem() is insufficient on iOS 18.x. The native UIViewController hierarchy needs more time to fully settle after the ReanimatedModal dismiss before PHPickerViewController can be presented. When presented too early, the picker's touch responder chain is broken. This is increased to 500ms.

  2. Touch interception by FullScreenLoadingIndicator: When the attachment picker opens, onOpenPicker sets isLoaderVisible(true), rendering a FullScreenLoadingIndicator with StyleSheet.absoluteFillObject and zIndex: 10 at the app root level. This overlay persists during the entire picker interaction and can intercept touches meant for the native picker. Wrapping it with pointerEvents="none" ensures it remains visible as a loading indicator but does not block touch events.

Fixed Issues

$ #83049
PROPOSAL: #83049 (comment)

Tests

  1. Open Global Create > Create Expenses > Scan
  2. Tap the gallery icon to open the image picker (Choose from Gallery)
  3. Verify the iOS image picker is responsive and allows photo selection
  4. Select a photo and verify the receipt is correctly attached
  5. Repeat the flow and cancel the picker — verify the app returns to the scan screen without a stuck loader
  • Verify that no errors appear in the JS console

Offline tests

  1. Enable airplane mode
  2. Open Global Create > Create Expenses > Scan > Choose from Gallery
  3. Verify the picker is still responsive and allows selection
  4. Verify the app handles the offline state gracefully after selection

QA Steps

  1. On an iOS device (preferably iOS 18+), open Global Create > Create Expenses > Scan
  2. Tap the gallery icon to open the image picker
  3. Verify the image picker is responsive — you can scroll, tap photos, and select them
  4. Select a photo and verify it attaches correctly as a receipt
  5. Repeat and cancel the picker — verify no stuck loader or broken state
  6. Verify the same flow works on Android with no regression
  • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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

N/A - Changes are iOS-specific (.native.tsx files). Android behavior unchanged.

Android: mWeb Chrome

N/A - Changes are in native-only files.

iOS: Native

This is where the fix applies. Testing required on iOS 18+ device/emulator.

iOS: mWeb Safari

N/A - Changes are in native-only files.

MacOS: Chrome / Safari

N/A - Changes are in native-only files.

…n and touch interception

Increase setTimeout delay from 200ms to 500ms in AttachmentPicker selectItem()
to ensure the native UIViewController hierarchy fully settles on iOS 18+ before
presenting PHPickerViewController. Also wrap FullScreenLoadingIndicator with
pointerEvents="none" so it doesn't intercept touches while the native picker is active.

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 3, 2026

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/components/AttachmentPicker/index.native.tsx 20.95% <ø> (ø)
src/components/FullScreenLoaderContext.tsx 87.50% <100.00%> (ø)
... and 7 files with indirect coverage changes

{isLoaderVisible && <FullScreenLoadingIndicator />}
{isLoaderVisible && (
<View
pointerEvents="none"
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 can you confirm there's no side effect of this on all platforms?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I investigated the cross-platform impact. The pointerEvents="none" change is safe across all platforms:

Cross-platform behavior:

  • iOS/Android (native): The RN View prop pointerEvents="none" prevents the view and all its descendants from being touch targets. Well-documented RN behavior.
  • Web (React Native Web): Translates to CSS pointer-events: none — same effect, well-supported in all modern browsers.

Why it's safe for all current usage:
All consumers of the full-screen loader (IOURequestStepScan, IOURequestStepOdometerImage, AttachmentPickerWithMenuItems, and useFilesValidation) use it purely as a visual indicator during transitions where no user interaction with the React Native layer is expected — either a native picker is open above the RN view hierarchy, or background file processing (HEIC conversion) is running.

One latent concern (not currently triggered):
FullScreenLoadingIndicator supports a shouldUseGoBackButton prop that renders a tappable "Go Back" button after a timeout. This prop is not passed in the context provider (defaults to false), so it's not an issue today. If someone were to add it in the future, the button would be unreachable due to pointerEvents="none". But that would require an intentional code change and would be caught in review.

No regressions expected on Android, web, or iOS.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

I reviewed both changes for cross-platform side effects. Here's a summary:

Change 1: setTimeout 200ms → 500ms (index.native.tsx)

Web / Desktop: No impact — the web AttachmentPicker (index.tsx) is a completely separate implementation using a hidden <input type="file"> with no modal or setTimeout.

iOS Native: This is the intended fix target — no concerns.

Android Native: ⚠️ Minor concern. Since index.native.tsx serves both iOS and Android, Android also gets the 300ms increase even though it doesn't have the iOS 18 UIViewController race condition. The user will wait 500ms instead of 200ms before the gallery/camera picker appears. This is noticeable but likely not a major issue since the FullScreenLoadingIndicator is shown during this gap. Worth noting though — a Platform.OS === 'ios' guard could keep Android at 200ms if the team prefers.


Change 2: pointerEvents="none" wrapper (FullScreenLoaderContext.tsx)

This file is not platform-specific, so the change applies to all platforms.

iOS / Android Native: Safe. The FullScreenLoadingIndicator rendered from this context has no interactive children (no shouldUseGoBackButton prop), so pointerEvents="none" simply makes a visual-only overlay pass through touches — which is the intended fix.

Web / Desktop: ⚠️ Worth noting two things:

  1. Behavioral change during file processing on web. The useFilesValidation hook (src/hooks/useFilesValidation.tsx) calls setIsLoaderVisible(true) on all platforms during HEIC conversion and large image resizing. Previously, the full-screen overlay (with zIndex: 10 and opacity: 0.8) blocked interactions during this processing. With pointerEvents="none", clicks now pass through the overlay, meaning users could potentially interact with elements behind it during file processing. This is a subtle behavioral change that may or may not be desirable.

  2. Future maintenance risk. If someone later passes shouldUseGoBackButton (or adds other interactive elements) to the FullScreenLoadingIndicator in this context, the "Go Back" button will be unclickable on all platforms because the parent View has pointerEvents="none", which cascades to children in both React Native and CSS.


Summary

Platform Change 1 (setTimeout) Change 2 (pointerEvents)
iOS Native ✅ Fix target ✅ Fix target
Android Native ⚠️ 300ms extra delay (no functional benefit) ✅ Safe
Web (Chrome/Safari) ✅ Not affected ⚠️ Overlay no longer blocks clicks during HEIC processing
Desktop (Electron) ✅ Not affected ⚠️ Same as web

Neither concern is a blocker, but the Android delay and the web behavioral change during file processing are worth being aware of.

delete onModalHide.current;
});
}, 200);
}, 500);
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.

This is magic value and I don't think this is needed anymore. onModalHide.current callback is called on onModalHide, which means modal is fully disappeared.
I have no issue found even after fully removing setTimeout.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call — removed the setTimeout entirely. Since onModalHide.current is invoked via the modal's onModalHide callback, the native view hierarchy should already be fully settled by that point. Pushed in 4b4ae4f.

The onModalHide callback already fires when the modal is fully
dismissed, so the setTimeout delay is unnecessary. This addresses
review feedback from aimane-chnaif.

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
onClosed.current();
delete onModalHide.current;
});
}, 200);
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 Let's keep original code (200ms timeout) for now, for the safety of regression.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Restored the original 200ms timeout with its comment. The PR now only contains the pointerEvents="none" fix on FullScreenLoaderContext.tsx — the AttachmentPicker file is unchanged from main. Pushed in 3cb456a.

…eout

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Reverted the setTimeout change in AttachmentPicker/index.native.tsx — the original 200ms timeout is preserved. The PR now only contains the pointerEvents="none" fix in FullScreenLoaderContext.tsx.

@aimane-chnaif
Copy link
Copy Markdown
Contributor

@bernhardoj as a reporter, do you mind testing this branch on your simulator?

MelvinBot and others added 2 commits March 3, 2026 08:14
Restores the original setTimeout(200ms) delay in selectItem per
reviewer feedback, keeping it for regression safety. The PR now
only contains the pointerEvents="none" fix on FullScreenLoaderContext.

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
…sive' into claude-fixIosImagePickerUnresponsive

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

The failing check (test job 8) is unrelated to this PR's changes.

Analysis: The failure is in tests/ui/SessionTest.tsx (deep linking tests), but this PR only modifies src/components/FullScreenLoaderContext.tsx — wrapping the loader indicator in a View with pointerEvents="none". The deep linking tests don't exercise or depend on this component behavior.

Evidence: The same SessionTest.tsx test is also failing on at least two other unrelated PRs right now:

  • fix/79312-better-existing-acc-detection (run 22614308207) — same timeout + unmounted renderer errors
  • JKobrynski/feat/80091-migrate-keys-to-ram-only-part-1 (run 22614270321) — same test file, different assertion failure

This is a known flaky test, not caused by this PR's changes.

@bernhardoj
Copy link
Copy Markdown
Contributor

This doesn't work. As you can see from my screenshot, the image picker looks different, it overlaps with the status and navbar.

image

@aimane-chnaif
Copy link
Copy Markdown
Contributor

@MelvinBot can you check #83997 (comment)? This should help finding the real root cause.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

I investigated bernhardoj's screenshot and the underlying issue. The screenshot shows the iOS image picker overlapping the status bar and navbar — this is a presentation/layout issue, not just a touch interception issue. The pointerEvents="none" fix alone cannot solve this because it only affects touch delivery, not how iOS presents the PHPickerViewController.

Root Cause Analysis

The issue is a view controller hierarchy problem caused by the interaction between ReanimatedModal's dismissal and PHPickerViewController presentation on iOS 18.

The chain of events:

  1. The AttachmentPicker's Popover is a fullscreen <Modal transparent> (ReanimatedModal/index.tsx:214-216), which creates a native RCTFabricModalHostViewController presented with UIModalPresentationOverFullScreen (RCTModalHostViewComponentView.mm:71-74).

  2. When the user taps "Choose from Gallery", selectItem() (index.native.tsx:450-477) starts a multi-phase dismissal:

    • Reanimated exit animation plays (~200ms slideOutDown)
    • Animation completes → onCloseCallBack sets state → React re-render
    • modalVisibility becomes false → native <Modal visible={false}> → iOS calls dismissViewControllerAnimated
    • Native dismiss completion fires onDismissonModalHide() propagates to AttachmentPicker
    • setTimeout(200ms)launchImageLibrary
  3. react-native-image-picker calls RCTPresentedViewController() (RCTUtils.mm:659-673) to find the topmost VC, then presents PHPickerViewController from it (ImagePickerManager.mm:121-127).

  4. The problem on iOS 18: After dismissing the UIModalPresentationOverFullScreen modal VC, the root view controller's safe area insets / presentation context may not be fully restored. When PHPickerViewController is presented from this root VC, it inherits a broken layout context, causing the status bar and navbar overlap.

  5. Additionally, getImagePickerOptions() (index.native.tsx:68-84) does not set a presentationStyle option. The native code defaults to UIModalPresentationFullScreen via RCTConvert (RCTConvert.mm:514-523), but PHPickerViewController on iOS 18 internally uses UISheetPresentationController which may interact poorly with the stale layout state of the presenting VC.

Why pointerEvents="none" alone isn't enough

The pointerEvents="none" change addresses one symptom (the loading overlay intercepting touches) but doesn't address the core issue: the PHPickerViewController is being presented from a view controller whose layout context is in a bad state after the UIModalPresentationOverFullScreen modal dismissal.

Recommended approaches

  1. Explicitly set presentationStyle: 'formSheet' or 'pageSheet' in getImagePickerOptions() — this gives the picker its own self-contained presentation context, independent of the presenting VC's layout state. The react-native-image-picker TypeScript types support this option (presentationStyle?: 'currentContext' | 'fullScreen' | 'pageSheet' | 'formSheet' | 'popover' | 'overFullScreen' | 'overCurrentContext').

  2. Increase the setTimeout delay (the reverted 500ms change) — this gives iOS more time to settle the VC hierarchy after dismissal. Fragile but pragmatic.

  3. Use InteractionManager.runAfterInteractions() instead of a fixed setTimeout — waits for RN interactions to complete, though it doesn't guarantee the native VC hierarchy is fully settled.

  4. A combination: keep pointerEvents="none" for touch safety + set presentationStyle in picker options + potentially increase the delay.

The strongest signal from bernhardoj's screenshot is that this is a VC presentation issue on iOS 18, not purely a touch interception issue. The fix needs to address how/when PHPickerViewController is presented, not just how touches are delivered.

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.

3 participants