Fix iOS scan crash with 30 HEIC images when creating expense - #99679
Fix iOS scan crash with 30 HEIC images when creating expense#99679nabi-ebrahimi wants to merge 6 commits into
Conversation
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@nabi-ebrahimi, when this pr will be ready for review? thanks. |
|
@ahmedGaber93 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] |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
| }; | ||
| }; | ||
|
|
||
| const getErrorMessage = (error: unknown): string => (error instanceof Error && error.message ? error.message : 'An unknown error occurred'); |
There was a problem hiding this comment.
❌ CONSISTENCY-7 (docs)
The fallback string 'An unknown error occurred' returned by getErrorMessage is user-facing: it flows through failureMessages.add(getErrorMessage(error)) and is displayed to the user via showGeneralAlert(message) → Alert.alert(...). Hardcoded English copy cannot be translated and breaks the localized experience for non-English users.
Route the fallback through the translation method instead of hardcoding it. For example, accept the existing translate and return a localized message when there is no error.message:
const getErrorMessage = (error: unknown, translate: (key: TranslationPaths) => string): string =>
error instanceof Error && error.message ? error.message : translate('attachmentPicker.errorWhileSelectingAttachment');(Reusing the existing attachmentPicker.errorWhileSelectingAttachment key, or adding a dedicated src/languages/* entry, keeps the alert copy localized.)
Reviewed at: 6621abc | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
Explanation of Change
Creating an expense with Scan and selecting a large batch of HEIC photos from the gallery crashed the app on iOS. Every selected photo was converted to JPEG at the same time, and because each conversion has to hold the full-size image in memory, a batch of
30pushed the app past what iOS allows and it was killed.The photos are now converted one after another, so the memory used stays the same whether one photo is selected or thirty, and each image is freed as soon as it has been converted.
If several photos fail to convert, the user now sees a single message instead of one for every photo.
Fixed Issues
$ #96404
PROPOSAL: #96404 (proposal)
Tests
Precondition:
Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, 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.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
Screen.Recording.2026-08-27.at.9.52.05.PM.mov
iOS: mWeb Safari
MacOS: Chrome / Safari