fix: Attachment - App closes unexpectedly while uploading an image larger than the 24 MB - #79835
Conversation
…rger than the 24 MB
|
Hey, I noticed you changed If you want to automatically generate translations for other locales, an Expensify employee will have to:
Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running: npx ts-node ./scripts/generateTranslations.ts --helpTypically, you'd want to translate only what you changed by running |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f92af5ade4
ℹ️ 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".
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c3ad99fcc1
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1f046686dc
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
…ent-App-closes-unexpectedly-while-uploading-an-image-larger-than-the-24-MB
…ent-App-closes-unexpectedly-while-uploading-an-image-larger-than-the-24-MB
…-uploading-an-image-larger-than-the-24-MB
| /** | ||
| * Handles errors during image processing (resize, dimension check, etc.) | ||
| */ | ||
| const handleImageProcessingError = useCallback( |
There was a problem hiding this comment.
This component is currently not react compilable so makes sense to use useCallback for now.
| if (result.status === 'fulfilled') { | ||
| processedFiles.push(result.value); | ||
| updateFileOrderMapping(convertedImages.at(index), result.value); | ||
| } else { |
There was a problem hiding this comment.
Can you please explain about these changes?
Why allSettled used?
What issue you faced without these changes?
There was a problem hiding this comment.
What issue you faced without these changes?
I didn't face any issues the reviewer bot recommended it and used it because it made sense to me
Please add unit tests. i.e. |
…NSIONS_TOO_LARGE validation
Done @situchan |
…ent-App-closes-unexpectedly-while-uploading-an-image-larger-than-the-24-MB
|
Lint still failing |
…edly-while-uploading-an-image-larger-than-the-24-MB
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid.movAndroid: mWeb ChromeiOS: HybridAppios.moviOS: mWeb Safarimsafari.mov |
|
Codex Review: Didn't find any major issues. 🎉 ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
|
@TaduJR test fails on android chrome (Why didn't you test on this platform? Screenshot is missing) mchrome.mov
|
Hmm Taking a look...
Oh my ngrok subscription was expired at that time. I was having difficulties with 127.0.0.1 on Android mWeb. |
…ent-App-closes-unexpectedly-while-uploading-an-image-larger-than-the-24-MB
…ent-App-closes-unexpectedly-while-uploading-an-image-larger-than-the-24-MB
Android Chrome's Image API automatically downsamples large images for memory protection, returning incorrect (smaller) dimensions. This caused images exceeding 50MP to bypass the pixel count check and crash during resize. The fix reads dimensions directly from JPEG SOF markers (0xC0, 0xC1, 0xC2) and PNG IHDR chunks, which report the true file dimensions regardless of browser memory optimizations. Added comprehensive tests for blob URL handling and file header parsing.
|
I discovered that Android Chrome automatically downsamples large images when loading them into Example with the same 26.7MB file:
This is documented browser behavior:
The ResultThe 228MP image passes our 50MP pixel check (reports as 14MP), then Solution OptionsWe need to read dimensions directly from the file header (JPEG SOF marker / PNG IHDR chunk) to get true dimensions. Here are the options:
Which approach would be preferable? |
…ent-App-closes-unexpectedly-while-uploading-an-image-larger-than-the-24-MB
|
🚀 Deployed to staging by https://github.com/arosiclair in version: 9.3.11-31 🚀
|
|
🚀 Deployed to production by https://github.com/Julesssss in version: 9.3.12-1 🚀
|


Explanation of Change
This PR prevents the app from crashing or hanging when users attempt to upload images with extremely large dimensions (e.g., 229 megapixels).
Fixed Issues
$ #71923
PROPOSAL: #71923 (comment)
Tests
Offline tests
Same as tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand 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-Native.mp4
Android: mWeb Chrome
iOS: Native
iOS-App.mp4
iOS: mWeb Safari
iOS-Safari.mp4
MacOS: Chrome / Safari
Macbook-Chrome.mp4