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

[HOLD for payment 2023-04-27] [$1000] The attachment viewer loads every image again when switching with arrows #15922

Closed
6 tasks done
kavimuru opened this issue Mar 13, 2023 · 57 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@kavimuru
Copy link

kavimuru commented Mar 13, 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. Open any report with more than one image sent
  2. Click on any one image
  3. Click on an arrow to switch image

Expected Result

The spinner should only display once when the image loads, after that, the image should not need to show the spinner and be shown instantly

Actual Result

The spinner is shown on every image when switching and images are loaded again every time.

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.2.83-1
Reproducible in staging?: y
Reproducible in production?: y
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:

test.mov
Recording.1689.mp4

Expensify/Expensify Issue URL:
Issue reported by: @esh-g
Slack conversation:
https://expensify.slack.com/archives/C049HHMV9SM/p1678613459293019
View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0136002576e7090b5b
  • Upwork Job ID: 1636029895829024768
  • Last Price Increase: 2023-03-15
@kavimuru kavimuru added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Mar 13, 2023
@MelvinBot
Copy link

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

@melvin-bot melvin-bot bot locked and limited conversation to collaborators Mar 13, 2023
@MelvinBot
Copy link

MelvinBot commented Mar 13, 2023

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

@isabelastisser isabelastisser added the External Added to denote the issue can be worked on by a contributor label Mar 15, 2023
@melvin-bot melvin-bot bot unlocked this conversation Mar 15, 2023
@melvin-bot melvin-bot bot changed the title The attachment viewer loads every image again when switching with arrows [$1000] The attachment viewer loads every image again when switching with arrows Mar 15, 2023
@MelvinBot
Copy link

Job added to Upwork: https://www.upwork.com/jobs/~0136002576e7090b5b

@MelvinBot
Copy link

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

@MelvinBot
Copy link

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 15, 2023
@MelvinBot
Copy link

Triggered auto assignment to @johnmlee101 (External), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@johnmlee101
Copy link
Contributor

Hey @isabelastisser do you mind completing the checklist #15922 (comment)

@isabelastisser
Copy link
Contributor

sorry, forgot to check the boxes before applying the external label!

@johnmlee101
Copy link
Contributor

I think this is a dupe of #6527 which was deferred for #12603 which ultimately deals with caching these images

@esh-g
Copy link
Contributor

esh-g commented Mar 15, 2023

@johnmlee101 Are you sure this is a dupe of #6527 ?
Because I think that issue was even before the carousel control was implemented and was about caching the images to the browser so they stay even after reload. But here, the images are already loaded and we can have them switch without caching them to the browser.

@hoangzinh
Copy link
Contributor

hoangzinh commented Mar 15, 2023

Proposal

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

The spinner keeps shown on every image when switching even it loaded before.

What is the root cause of that problem?

Because in the componentDidUpdate lifecycle of component ImageView, it call method to set isLoading=true everytime the url of is changed (it didn't care if the url is passed before or the image is already loaded in cache)

componentDidUpdate(prevProps) {
if (prevProps.url === this.props.url || this.state.isLoading) {
return;
}
this.imageLoadingStart();
}

when isLoading state equal true, it shows spinner

{this.state.isLoading && (
<FullscreenLoadingIndicator
style={[styles.opacity1, styles.bgTransparent]}
/>
)}

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

I think we should apply delayed spinner pattern in this case. According to some UX tips, we should only show spinner if something is loaded > 1s, otherwise it will distract user.

More details, I think about add an additional props delayTime to component FullScreenLoadingIndicator, and update current FullScreenLoadingIndicator to something like this:

import React, { useEffect, useState } from 'react';

const defaultProps = {
    ....
    delayTime: 0,
};

const FullScreenLoadingIndicator = (props) => {
  const [showable, setShowable] = useState(false);

  useEffect(() => {
    const timer = setTimeout(() => setShowable(true), props.delayTime);

    return () => clearTimeout(timer);
  });

  return showable && <..../>;
};

export default FullScreenLoadingIndicator;

so we can set delayTime in the loading part of component ImageView. The advantage of this pattern is we also improve UX for user when they load lightweight images or their network is very good

What alternative solutions did you explore? (Optional)

Maybe cache loaded images, but it will be a fancy work.

@nefedov-dm
Copy link

nefedov-dm commented Mar 15, 2023

Proposal

I think you need to render each AttachmentView for every attachment in AttachmentCarousel and use style display: none;. Because your AttachmentView will re-render every time when current slide will be change.

You can cache image content or make Set with loaded urls, but i think it more complicated and redundant for Image component.

Plus, if you will use style, you can use opacity and it is good for animation.

Contributor details
Your Expensify account email: nefyodov.du@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~01146d8467ba0b62e4

@MelvinBot
Copy link

📣 @nefedov-dm! 📣

Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  2. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  3. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.

Screen Shot 2022-11-16 at 4 42 54 PM

Format:

Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@usenbekov
Copy link

usenbekov commented Mar 16, 2023

Proposal

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

The attachment viewer loads every image again when switching with arrows

What is the root cause of that problem?

The Image component used debouncedConfigureImageSource with 220 ms:
https://github.com/Expensify/App/blob/main/src/components/Image/index.js#L14

this.debouncedConfigureImageSource = _.debounce(this.configureImageSource, 220);
...
this.debouncedConfigureImageSource();
...
this.debouncedConfigureImageSource.cancel();
this.debouncedConfigureImageSource();

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

It will be fixed if we use it with the immediate: true option:
this.debouncedConfigureImageSource = _.debounce(this.configureImageSource, 220, true);

Or if we use it without debounce.

It needs more investigation like why the debounce actually used to make sure that the fix won't break anything.

What alternative solutions did you explore? (Optional)

@usenbekov
Copy link

Proposal

Updated

Updated according to contributing guidelines.

@Santhosh-Sellavel
Copy link
Collaborator

This is expected behavior, debounce here is added to ensure there is no flickering of the image while switching images fast.

cc: @chiragsalian @luacmartins @trjExpensify @thesahindia

@isabelastisser
Copy link
Contributor

Not overdue, still discussing!

@johnmlee101 is this a dupe or expected behavior? Let me know if I should close it.

@melvin-bot melvin-bot bot removed the Overdue label Mar 17, 2023
@kidroca
Copy link
Contributor

kidroca commented Apr 4, 2023

Still working, should be ready tomorrow

A little teaser

Android.Emulator.-.Pixel_4_API_31_5554.2023-04-04.22-58-24.mp4

@Santhosh-Sellavel
Copy link
Collaborator

Looks much better @kidroca!

@melvin-bot melvin-bot bot added the Reviewing Has a PR in review label Apr 5, 2023
@kidroca
Copy link
Contributor

kidroca commented Apr 5, 2023

PR ready for review

@MelvinBot
Copy link

@johnmlee101, @kidroca, @isabelastisser, @thesahindia Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@kidroca
Copy link
Contributor

kidroca commented Apr 13, 2023

PR is ready for review

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Apr 20, 2023
@melvin-bot melvin-bot bot changed the title [$1000] The attachment viewer loads every image again when switching with arrows [HOLD for payment 2023-04-27] [$1000] The attachment viewer loads every image again when switching with arrows Apr 20, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Apr 20, 2023
@MelvinBot
Copy link

Reviewing label has been removed, please complete the "BugZero Checklist".

@MelvinBot
Copy link

MelvinBot commented Apr 20, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.2-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-04-27. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@MelvinBot
Copy link

MelvinBot commented Apr 20, 2023

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:

  • [@thesahindia] The PR that introduced the bug has been identified. Link to the PR:
  • [@thesahindia] 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:
  • [@thesahindia] 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:
  • [@isabelastisser] Determine if we should create a regression test for this bug.
  • [@thesahindia] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@isabelastisser] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@situchan
Copy link
Contributor

There seems regression from PR which fixes this issue

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Apr 27, 2023
@trjExpensify
Copy link
Contributor

@situchan can you clarify what you mean. Are you saying the PR for this issue caused a regression?

@situchan
Copy link
Contributor

@situchan can you clarify what you mean. Are you saying the PR for this issue caused a regression?

yes

@isabelastisser
Copy link
Contributor

isabelastisser commented Apr 28, 2023

To confirm:

@kidroca: approved proposal
@thesahindia - C+ review
@esh-g - reported the issue

  • Contributor assigned on March 29.
  • PR merged on April 19.
  • Deployed to production on April 20.

The issue amount is $1000, but does it mean that the payment processed will be $500 because: Merged PR more than 9 business days after assignment - 50% penalty

@johnmlee101, I got the info above here, is this correct?

@melvin-bot melvin-bot bot added the Overdue label May 1, 2023
@isabelastisser
Copy link
Contributor

Not overdue, still discussing this with @johnmlee101 !

@melvin-bot melvin-bot bot removed the Overdue label May 1, 2023
@johnmlee101
Copy link
Contributor

@isabelastisser This was a fairly complex issue that had a lot of edge cases that were being tested, so I think the 50% penalty might not apply in this case. I'd be fine keeping it as the original $1000 for this.

@isabelastisser
Copy link
Contributor

Update: Payments made in Upwork and contracts ended.

@thesahindia, please complete your tasks on the BugZero Checklist:, and I will review and complete mine so we can close the issue. Thanks!

@thesahindia
Copy link
Member

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:

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

#9279

  • [@thesahindia] 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:

#9279 (comment)

  • [@thesahindia] 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:

Will do it soon

  • [@isabelastisser] Determine if we should create a regression test for this bug.

Let's add tests

  • [@thesahindia] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.

Test steps -

  1. Go to a chat
  2. Send multiple attachments
  3. Open an attachment
  4. Navigate between attachments using the left and right
  5. Verify If we wait for a second before pressing "Next Arrow" - the attachment is preloaded when you navigate to it
  6. Verify going back to a previous attachment is instant
  7. Verify that on mobile devices you can navigate between attachments by swiping left/right

@isabelastisser
Copy link
Contributor

QA issue here.

All set!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests