Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[$1000] Attachments- App crashes when user navigate attachments #24337

Closed
1 of 6 tasks
lanitochka17 opened this issue Aug 9, 2023 · 46 comments
Closed
1 of 6 tasks

[$1000] Attachments- App crashes when user navigate attachments #24337

lanitochka17 opened this issue Aug 9, 2023 · 46 comments
Assignees
Labels
Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Aug 9, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Launch app
  2. Tap on any report
  3. Tap plus button to add few image/attachments
  4. Tap on a image
  5. Use side arrow to navigate and view attachments

Expected Result:

When user navigate attachments using side arrows, he must be able to view all attachments without problem

Actual Result:

When user navigate attachments using side arrows, the app crashes while trying to view below attached images

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.52.1

Reproducible in staging?: Yes

Reproducible in production?: No

If this was caught during regression testing, add the test name, ID and link from TestRail:

Email or phone of affected tester (no customers):

Logs: https://stackoverflow.com/c/expensify/questions/4856

Notes/Photos/Videos: Any additional supporting documentation

Bug6159108_deploy.mp4

Expensify/Expensify Issue URL:

Issue reported by: Applause - Internal Team

Slack conversation:

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01938fb39d08874250
  • Upwork Job ID: 1712662082191142912
  • Last Price Increase: 2023-11-27
@lanitochka17 lanitochka17 added the DeployBlockerCash This issue or pull request should block deployment label Aug 9, 2023
@OSBotify
Copy link
Contributor

OSBotify commented Aug 9, 2023

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open StagingDeployCash deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

@melvin-bot
Copy link

melvin-bot bot commented Aug 9, 2023

Triggered auto assignment to @Li357 (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

@puneetlath
Copy link
Contributor

@lanitochka17 is this an android-only issue? I'm not able to reproduce it on iOS.

@akinwale
Copy link
Contributor

I am also unable to reproduce this issue. Can we get more specifics on the environment like the version of Android being tested on? Also, if we could get the exact same set of images used to test, that may prove to be helpful. Thanks.

@kosmydel
Copy link
Contributor

Hey, it might be related to this issue.

Your workspace name contains HTML characters (&), which is also the cause of the mentioned issue. More details in my proposal.

Can you try to reproduce it on a new workspace, with a name without any special characters?

@aimane-chnaif
Copy link
Contributor

Hey, it might be related to this issue.

Your workspace name contains HTML characters (&), which is also the cause of the mentioned issue. More details in my proposal.

Can you try to reproduce it on a new workspace, with a name without any special characters?

If so, it should be reproducible on production as well and not deploy blocker.

@kosmydel
Copy link
Contributor

kosmydel commented Aug 10, 2023

Hey, it might be related to this issue.
Your workspace name contains HTML characters (&), which is also the cause of the mentioned issue. More details in my proposal.
Can you try to reproduce it on a new workspace, with a name without any special characters?

If so, it should be reproducible on production as well and not deploy blocker.

You are right. It was just a guess. I'm sorry for the confusion.

@Li357
Copy link
Contributor

Li357 commented Aug 10, 2023

Can't reproduce on iOS and Android either. I'm going to close this out for now, if you can provide extra details that would be great!

@Li357 Li357 closed this as completed Aug 10, 2023
@puneetlath puneetlath removed the DeployBlockerCash This issue or pull request should block deployment label Aug 10, 2023
@lanitochka17
Copy link
Author

@Li357 Issue is still reproducible on Android
I have added an attachment that is causing the app to crash and there is one attachment that needs to be added that is larger than 10MB

Screen_Recording_20230921_135617_New.Expensify.mp4

Bug6159108_Profile_image

@lanitochka17 lanitochka17 reopened this Sep 21, 2023
@melvin-bot melvin-bot bot added the Overdue label Sep 21, 2023
@GabiHExpensify
Copy link

This issue hasn't been commented on in two weeks, should it still be labeled an hourly? If it's something that can go two weeks without progress without many consequences, then hourly seems like overkill. And if it's something that needs to be fixed within the next hour, then could you comment on progress @Li357? thanks!

@GabiHExpensify GabiHExpensify added Daily KSv2 and removed Hourly KSv2 labels Oct 5, 2023
@melvin-bot melvin-bot bot removed the Overdue label Oct 5, 2023
@GabiHExpensify
Copy link

Sounds like this is no longer a deploy blocker, so I'm updating it to a daily.

@Li357
Copy link
Contributor

Li357 commented Oct 6, 2023

Going to look into this tomorrow. I hadn't gotten to this because I had some wave 8 things to prioritize and hadn't been able to build Android for the past few days. Will reprioritize!

@melvin-bot melvin-bot bot added the Overdue label Oct 9, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 9, 2023

@Li357 Whoops! This issue is 2 days overdue. Let's get this updated quick!

@Li357
Copy link
Contributor

Li357 commented Oct 9, 2023

Fighting android emulator issues, but testing this now.

@melvin-bot melvin-bot bot removed the Overdue label Oct 9, 2023
@akinwale
Copy link
Contributor

akinwale commented Oct 9, 2023

I spent some time trying to figure this out and was finally able to reproduce (you have to test with the attached image in #24337 (comment)). The crash is due to an out of memory error due to the number of pixels in the image, I think it's some insanely huge number (9000x9000, iirc but it may be higher). The solution would probably be to try to scale the image down before displaying it.

@melvin-bot
Copy link

melvin-bot bot commented Oct 27, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot melvin-bot bot added the Overdue label Oct 30, 2023
@Li357
Copy link
Contributor

Li357 commented Oct 30, 2023

Adjusting the bounty

@melvin-bot melvin-bot bot removed the Overdue label Oct 30, 2023
@paultsimura
Copy link
Contributor

@Li357 please check this comment: #24337 (comment)

Copy link

melvin-bot bot commented Nov 3, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot melvin-bot bot added the Overdue label Nov 7, 2023
@Li357
Copy link
Contributor

Li357 commented Nov 8, 2023

@paultsimura Do you think this issue will get absorbed by those? This instability would require some extra code to show thumbnails instead of the full image

@melvin-bot melvin-bot bot removed the Overdue label Nov 8, 2023
@paultsimura
Copy link
Contributor

@Li357 my bad, I wasn't attentive enough to the discussion above. There just was a storm of "Attachments are crashing" dupe issues at the time I posted my initial comment. For this specific scenario, I don't think the linked issues will help.

Copy link

melvin-bot bot commented Nov 10, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@Li357 Li357 changed the title [$500] Attachments- App crashes when user navigate attachments [$1000] Attachments- App crashes when user navigate attachments Nov 13, 2023
Copy link

melvin-bot bot commented Nov 13, 2023

Upwork job price has been updated to $1000

@Li357
Copy link
Contributor

Li357 commented Nov 13, 2023

Bounty increased, I think this is valuable to work on because images get to this size pretty easily

@chrispader
Copy link
Contributor

I spent some time trying to figure this out and was finally able to reproduce (you have to test with the attached image in #24337 (comment)). The crash is due to an out of memory error due to the number of pixels in the image, I think it's some insanely huge number (9000x9000, iirc but it may be higher). The solution would probably be to try to scale the image down before displaying it.

@ArekChr was working on a PR in react-native-fast-image a few months ago, which should fix this problem by downsampling images.

@ArekChr do you fix your PR could fix this problem and what's the status on the PR? :)

@mvtglobally
Copy link

Issue not reproducible during KI retests. (First week)

Copy link

melvin-bot bot commented Nov 20, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@giltron
Copy link

giltron commented Nov 20, 2023

This was proposed as solution with 31204 that can fix crash with reproducible image attached

Proposal

Please re-state the problem that we are trying to solve in this issue.

App crashes after attempting to view a large uploaded image attachment that is beyond the size supported for the device.

What is the root cause of that problem?

The image size (below), which is 7724 x 5148, is too large for the rendering on the screen.
This causes the app to crash with the following in logcat on Android:

 Canvas: trying to draw too large(159052608bytes) bitmap.

This image is too large for the container it is being rendered on the device.

What changes do you think we should make in order to solve the problem?

Make sure the image height and size are not out of bounds (for the canvas size) what is supported by the device display within AttachmentCarouselPage

Within AttachmentCarouselPage, the components' onLoad should size dimensions similar to existing approach in ImageView. This component is used for the initial image preview during adding the attachment:

  // Resize the image to max dimensions possible on the Native platforms to prevent crashes on Android. To keep the same behavior, apply to IOS as well.
        const maxDimensionsScale = 11;
        imageZoomWidth = Math.min(imageZoomWidth, roundedContainerWidth * maxDimensionsScale);
        imageZoomHeight = Math.min(imageZoomHeight, roundedContainerHeight * maxDimensionsScale);

The solution is to adjust the imageHeight and imageWidth calculation within the onLoad events in [AttachmentCarouselPage](https://github.com/Expensify/App/blob/5e7022d8cc519ab8787aa0e0d70d5692c6c27945/src/components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPage.js( with similar approach as ImageView. AttachmentCarouselPage to ensure the maximum dimensions are not too large for the canvas:

imageWidth = Math.min(imageWidth, canvasWidth * maxDimensionsScale);
imageHeight = Math.min(imageHeight, canvasHeight * maxDimensionsScale);

What alternative solutions did you explore? (Optional)

Additionally, if there are an intended maximum dimensions for general image attachments this validation can be added before the image is uploaded. (personally don't like this solution unless there is a different need to scale down images)

In AttachmentPicker, we can add a function to check the size dimensions for an image (can check by height, width, and overall size):

isValidResolution(image) {
        return getImageResolution(image).then(
            (resolution) =>
                resolution.height >= CONST.ATTACHMENT_MIN_HEIGHT_PX &&
                resolution.width >= CONST.ATTACHMENT_WIDTH_PX &&
                resolution.height <= CONST.ATTACHMENT_MAX_HEIGHT_PX &&
                resolution.width <= CONST.ATTACHMENT_MAX_WIDTH_PX,
        );
    }

For native Android/iOS, we can also configure react-native-image-picker to automatically resize the image:

maxWidth
maxHeight

For informing the user, a similar message could be displayed (if it is not desirable to automatically resize) as with the Avatar image upload

282525660-d1d19d6d-e6dc-4bad-8829-e6bfafa3d0d5

@chrispader
Copy link
Contributor

@giltron There should be no need for this change anymore. We're completely overhauling the native ImageView component with a new MultiGestureCanvas/Lightbox component in this PR.

The crash with large images has also been fixed by a patch: #28159 (comment)


cc @akinwale @Li357 @mvtglobally

@melvin-bot melvin-bot bot added the Overdue label Nov 21, 2023
@mvtglobally
Copy link

Issue not reproducible during KI retests. (Second week)

Copy link

melvin-bot bot commented Nov 27, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@Li357
Copy link
Contributor

Li357 commented Nov 27, 2023

Awesome @chrispader! I'll close this out then!

@Li357 Li357 closed this as completed Nov 27, 2023
@melvin-bot melvin-bot bot removed Overdue labels Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Weekly KSv2
Projects
None yet
Development

No branches or pull requests