Skip to content

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

Closed

Description

@lanitochka17

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

Activity

  1. OSBotify commented on Aug 9, 2023

    @OSBotify
    Contributor

    👋 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.
  2. melvin-bot commented on Aug 9, 2023

    @melvin-bot

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

  3. puneetlath commented on Aug 9, 2023

    @puneetlath
    Contributor

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

  4. akinwale commented on Aug 10, 2023

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

  5. kosmydel commented on Aug 10, 2023

    @kosmydel
    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?

  6. aimane-chnaif commented on Aug 10, 2023

    @aimane-chnaif
    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.

  7. kosmydel commented on Aug 10, 2023

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

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

  8. Li357 commented on Aug 10, 2023

    @Li357
    Contributor

    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!

  9. lanitochka17 commented on Sep 21, 2023

    @lanitochka17
    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

  10. 56 remaining items

  11. changed the title [-][$500] Attachments- App crashes when user navigate attachments[/-] [+][$1000] Attachments- App crashes when user navigate attachments[/+] on Nov 13, 2023
  12. melvin-bot commented on Nov 13, 2023

    @melvin-bot

    Upwork job price has been updated to $1000

  13. Li357 commented on Nov 13, 2023

    @Li357
    Contributor

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

  14. chrispader commented on Nov 15, 2023

    @chrispader
    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? :)

  15. mvtglobally commented on Nov 18, 2023

    @mvtglobally

    Issue not reproducible during KI retests. (First week)

  16. melvin-bot commented on Nov 20, 2023

    @melvin-bot

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

  17. giltron commented on Nov 20, 2023

    @giltron

    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

  18. chrispader commented on Nov 21, 2023

    @chrispader
    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

  19. mvtglobally commented on Nov 23, 2023

    @mvtglobally

    Issue not reproducible during KI retests. (Second week)

  20. melvin-bot commented on Nov 27, 2023

    @melvin-bot

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

  21. Li357 commented on Nov 27, 2023

    @Li357
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

EngineeringExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributorsWeeklyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions