Skip to content

[HOLD for payment 2023-05-22] [$1000] Loading spinner is cut off on long images when reopening the chat #18040

Closed

Description

@kavimuru

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. Sent a long image in a chat.
  2. Closed the chat window.
  3. Reopened the chat window containing the sent long image.
  4. Observed the loading spinner that appears while the image is still loading.

Expected Result:

The loading spinner should be fully visible and centered on the screen while the long image is still loading after reopening the chat window. The thumbnail should be capped at a maximum height and minimum width so that the loading spinner is displayed properly.

Actual Result:

The loading spinner is cut off on both the left and right sides, with only a small portion of the spinner visible.

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

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.5.4
Reproducible in staging?: Needs reproduction
Reproducible in production?: Needs reproduction
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

2023-04-25.21-56-41.online-video-cutter.com.mp4

Expensify/Expensify Issue URL:
Issue reported by: @Harshdeepjoshi
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1682442117599109

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0105084e7856349f53
  • Upwork Job ID: 1651749591472959488
  • Last Price Increase: 2023-04-28

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Apr 26, 2023
  2. MelvinBot commented on Apr 26, 2023

    @MelvinBot
    Contributor

    Triggered auto assignment to @NicMendonca (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

  3. MelvinBot commented on Apr 26, 2023

    @MelvinBot
    Contributor

    Bug0 Triage Checklist (Main S/O)

    • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
    • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
      • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
    • This bug is reproducible using the reproduction steps in the OP. S/O
      • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
      • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
    • This issue is filled out as thoroughly and clearly as possible
      • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
    • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync
  4. shawnborton commented on Apr 27, 2023

    @shawnborton
    Contributor

    Let's first discuss in Slack

  5. Harshdeepjoshi commented on Apr 27, 2023

    @Harshdeepjoshi
    Contributor

    Proposal

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

    Loading spinner is cut off on long images when reopening the chat

    What is the root cause of that problem?

    The problem arises due to the aspect ratio of long images, which is causing the thumbnailScreenWidth to become narrower than the width of the spinner.

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

    Solution A

    We can cap the max-height and limit the min-width of the thumbnail by updating this function

    calculateThumbnailImageSize(width, height) {
    if (!width || !height) {
    return {};
    }
    // Width of the thumbnail works better as a constant than it does
    // a percentage of the screen width since it is relative to each screen
    // Note: Clamp minimum width 40px to support touch device
    let thumbnailScreenWidth = lodashClamp(width, 40, 250);
    const imageHeight = height / (width / thumbnailScreenWidth);
    let thumbnailScreenHeight = lodashClamp(imageHeight, 40, this.props.windowHeight * 0.40);
    const aspectRatio = height / width;
    // If thumbnail height is greater than its width, then the image is portrait otherwise landscape.
    // For portrait images, we need to adjust the width of the image to keep the aspect ratio and vice-versa.
    if (thumbnailScreenHeight > thumbnailScreenWidth) {
    thumbnailScreenWidth = Math.round(thumbnailScreenHeight * (1 / aspectRatio));
    } else {
    thumbnailScreenHeight = Math.round(thumbnailScreenWidth * aspectRatio);
    }
    return {thumbnailWidth: thumbnailScreenWidth, thumbnailHeight: Math.max(40, thumbnailScreenHeight)};
    }

    Which is responsible to calculate Thumbnail ImageSize ,thumbnailScreenWidth and thumbnailScreenHeight to this

        calculateThumbnailImageSize(width, height) {
            if (!width || !height) {
                return {};
            }
            // Width of the thumbnail works better as a constant than it does
            // a percentage of the screen width since it is relative to each screen
            // Note: Clamp minimum width 40px to support touch device
            let thumbnailScreenWidth = lodashClamp(width, 40, 250);
            // alert(thumbnailScreenWidth);
            let imageHeight = height / (width / thumbnailScreenWidth);
            let thumbnailScreenHeight = lodashClamp(imageHeight, 40, this.props.windowHeight * 0.40);
            let aspectRatio = height / width;
    
            // If thumbnail height is greater than its width, then the image is portrait otherwise landscape.
            // For portrait images, we need to adjust the width of the image to keep the aspect ratio and vice-versa.
            
            
            if (thumbnailScreenHeight > thumbnailScreenWidth) {
            //Checking if the aspect ratio of image does not cause the value of thumbnailScreenWidth to fall below the minimum width.
                if(Math.round(thumbnailScreenHeight * (1 / aspectRatio))<80){
                    thumbnailScreenWidth = 80;
                    thumbnailScreenHeight = 80*aspectRatio;
                    // Capping the maximum height of the thumbnail 
                    if (thumbnailScreenHeight>500){
                        thumbnailScreenHeight = 500;
                    }
                }
                else{
                thumbnailScreenWidth = Math.round(thumbnailScreenHeight * (1 / aspectRatio));
               }
            } else {
                
                thumbnailScreenHeight = Math.round(thumbnailScreenWidth * aspectRatio);
            }
            return {thumbnailWidth: thumbnailScreenWidth, thumbnailHeight: Math.max(40, thumbnailScreenHeight)};
        }

    and then we can change resize mode from contain to cover here

    resizeMode={Image.resizeMode.contain}

     resizeMode={Image.resizeMode.cover}

    Solution B

    We can cap the max height here

    <View style={[this.props.style, styles.overflowHidden]}>

    by adding a new style maxHeight like this

     <View style={[this.props.style, styles.overflowHidden , {maxHeight:400}]}> //we can add a new style in stylesheet for this 
    

    and since the aspect ratio of long images causes the width of the thumbnail to fall below the width of spinner, we can simply check if thumbnailScreenWidth is less than the desired min with (or width of spinner) and if so we can change it in the function
    calculateThumbnailImageSize to our desired min with

    and then to make the image fill the entire area of the thumbnail and be centered, we can simply set image resize mode to cover. To do this we can change this line

    resizeMode={Image.resizeMode.contain}

    to this

     resizeMode={Image.resizeMode.cover}
    

    Result

    Both solutions will give us same result
    image (1)

    I think we should also check and set cap on min-height and Max width of the thumbnail when it is in landscape mode

  6. added
    ExternalAdded to denote the issue can be worked on by a contributor
    and removed on Apr 28, 2023
  7. changed the title [-] Loading spinner is cut off on long images when reopening the chat[/-] [+][$1000] Loading spinner is cut off on long images when reopening the chat[/+] on Apr 28, 2023
  8. MelvinBot commented on Apr 28, 2023

    @MelvinBot
    Contributor
  9. MelvinBot commented on Apr 28, 2023

    @MelvinBot
    Contributor

    Current assignee @NicMendonca is eligible for the External assigner, not assigning anyone new.

  10. MelvinBot commented on Apr 28, 2023

    @MelvinBot
    Contributor

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @sobitneupane (External)

  11. 38 remaining items

  12. NicMendonca commented on May 23, 2023

    @NicMendonca
    Contributor

    Going OOO until June 5th so assigning a buddy to this GH to issue payment once everyone has applied ^^

  13. removed
    BugSomething is broken. Auto assigns a BugZero manager.
    on May 23, 2023
  14. removed their assignment
    on May 23, 2023
  15. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on May 23, 2023
  16. melvin-bot commented on May 23, 2023

    @melvin-bot

    Triggered auto assignment to @slafortune (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

  17. melvin-bot commented on May 23, 2023

    @melvin-bot
  18. sobitneupane commented on May 24, 2023

    @sobitneupane
    Contributor

    BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

    • [@sobitneupane] The PR that introduced the bug has been identified. Link to the PR:

    #8238

    • [@sobitneupane] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:

    #8238 (comment)

    • [@sobitneupane] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:

    https://expensify.slack.com/archives/C049HHMV9SM/p1684922451095849

  19. sobitneupane commented on May 24, 2023

    @sobitneupane
    Contributor

    Regression Test Proposal

    1. Go to any chat
    2. Send a picture with very large height and comparatively small width.
    3. Verify the loading spinner can display well and is not cut off.

    Do we agree 👍 or 👎

  20. slafortune commented on May 24, 2023

    @slafortune
    Contributor
  21. melvin-bot commented on May 29, 2023

    @melvin-bot

    @Beamanator, @slafortune, @hellohublot, @sobitneupane Huh... This is 4 days overdue. Who can take care of this?

  22. slafortune commented on May 30, 2023

    @slafortune
    Contributor

    @Harshdeepjoshi looks like two offers got sent and accepted - I paid one and close the other 👍

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions