Skip to content

[HOLD for payment 2023-10-09] [$500] Chat - Loader is shown on top of image even after image is loaded in attachment carousel #26046

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. Open a report
  2. Send 3-4 images/pdf's
  3. Scroll through carousel multiple times

Expected Result:

The loader should not appear on top of the image if the image is already loaded

Actual Result:

The loader appears on top of the image even if the image is already loaded

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.57-5

Reproducible in staging?: Yes

Reproducible in production?: Yes

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

WhatsApp.Video.2023-08-19.at.16.46.18.mp4
Record_2023-08-27-22-02-15_4f9154176b47c00da84e32064abf1c48.mp4

Expensify/Expensify Issue URL:

Issue reported by: @Krishna2323

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1692443921240289

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01e48d51a0940adaac
  • Upwork Job ID: 1699172582322225152
  • Last Price Increase: 2023-09-12
  • Automatic offers:
    • Krishna2323 | Contributor | 26743909
    • krishna2323 | Reporter | 26743910

Activity

  1. added
    Daily
    Bug
    on Aug 28, 2023
  2. melvin-bot commented on Aug 28, 2023

    @melvin-bot

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

  3. melvin-bot commented on Aug 28, 2023

    @melvin-bot

    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. pradeepmdk commented on Aug 28, 2023

    @pradeepmdk
    Contributor

    Proposal

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

    Chat - Loader is shown on top of image even after image is loaded in attachment carousel

    What is the root cause of that problem?

    from this PR https://github.com/Expensify/App/pull/20798/files#diff-d0e9c4b27eeb3cf558959584e3c3ea569b9a70c4fa1334846ac028a504cf035d introduced ImageTransformer so every time isActive image will transform

    onLoadStart={() => setIsImageLoading(true)}
    onLoadEnd={() => setIsImageLoading(false)}
    so that flickering will occur every time load an image and transform

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

    we should check image is already Transformed or not. This AttachmentCarouselPage is loaded from Flatlist so we need to declare one more state

        const [isImageTransformered, setIsImageTransformered] = useState(false);
    
    

    and here

    we need declare setIsImageTransformered(true);
    and on onLoadEnd as well.
    and
    onLoadStart={() => setIsImageLoading(true)}

    add onLoadEnd={() => setIsImageTransformered(true)}

    the loader should show if the image is not Transforming only isActive && !isImageTransformered

    Result

    Screen.Recording.2023-09-15.at.6.51.36.AM.mov
  5. Krishna2323 commented on Aug 28, 2023

    @Krishna2323
    Contributor

    Proposal

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

    Chat - Loader is shown on top of image even after image is loaded in attachment carousel

    What is the root cause of that problem?

    Our loader is configured to show as soon as the loading process began, without distinguishing between images loaded from the cache and those fetched from the internet. This meant that even if an image was instantly available in the cache and displayed immediately, our loader logic would still interpret this as a loading sequence. As a result, the isLoading state would momentarily set to true, only to revert back to false instantly, causing the loading indicator to flash or flicker briefly.

    I already fixed similar issue few weeks ago: PR

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

    To address the flickering loader issue, we should introduce a slight delay before showing the loader, allowing cached images to display without triggering the loading indicator. Simultaneously, we need to enhance our mechanism for tracking image load status, ensuring that once an image is loaded, its status is remembered, preventing unnecessary loader displays for cached images. Synchronizing the fallback display with the image's actual load status will further mitigate the flash of the loader. Lastly, optimizing the caching of image dimensions will expedite image rendering, contributing to a smoother user experience.

    Imports:

    • Imported useRef and _ from 'underscore' in the new code.

    State Variables:

    • Added a new state variable isImageCached which is used to determine if the image is being loaded from the cache or the internet.
    • Initialized isImageLoading state to false instead of true.
    • Initialized showFallback state to true instead of isImageLoading.
        const [isImageLoading, setIsImageLoading] = useState(false);
        const [showFallback, setShowFallback] = useState(true);
        const [isImageCached, setIsImageCached] = useState(true);
    

    Refs:

    • Introduced a new ref isLoadedRef which seems to act as a flag to track if the image has been loaded at least once.

    const isLoadedRef = useRef(null);

    Effects:

    • In the new code, there's an added effect that checks if the image is being loaded from cache or the internet. It introduces a delay using _.delay() from the underscore library to decide whether to update isImageCached.
        useEffect(() => {
            if (isLoadedRef.current || !isImageLoading) {
                return;
            }
            const timeout = _.delay(() => {
                if (!isImageLoading || isLoadedRef.current) {
                    return;
                }
                setIsImageCached(false);
            }, 200);
            return () => clearTimeout(timeout);
        }, [isImageLoading]);
    

    Image Component:

    • The callback for the onLoadStart event of the inside the ImageTransformer was removed in the new code.
    • The onLoadStart and onLoadEnd events of the inside the ImageWrapper were modified. The new onLoadStart checks the isLoadedRef and isImageLoading before setting isImageLoading to true. The onLoadEnd now sets both isImageLoading to false and isLoadedRef.current to true.
         onLoadStart={() => {
            if (isLoadedRef.current || isImageLoading) {
                  return;
            }
            setIsImageLoading(true);
          }}
    

    ActivityIndicator:

    • The condition to show the ActivityIndicator is now (isActive && isImageLoading && !isImageCached). This means the loading spinner will only be shown if the page is active, the image is still loading, and the image is not cached.
        {isActive && isImageLoading && !isImageCached && (
            <ActivityIndicator
                size="large"
                style={StyleSheet.absoluteFill}
            />
        )}
    

    Result

    fix_demo.mp4
  6. melvin-bot commented on Aug 31, 2023

    @melvin-bot

    @sakluger Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  7. sakluger commented on Aug 31, 2023

    @sakluger
  8. sakluger commented on Aug 31, 2023

    @sakluger
  9. Krishna2323 commented on Aug 31, 2023

    @Krishna2323
    Contributor

    @sakluger, that's what I was thinking 😂

  10. 63 remaining items

  11. melvin-bot commented on Oct 2, 2023

    @melvin-bot

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

  12. melvin-bot commented on Oct 2, 2023

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.75-12 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-10-09. 🎊

    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

    For reference, here are some details about the assignees on this issue:

    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
  13. melvin-bot commented on Oct 2, 2023

    @melvin-bot

    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:

    • [@eVoloshchak] The PR that introduced the bug has been identified. Link to the PR:
    • [@eVoloshchak] 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:
    • [@eVoloshchak] 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:
    • [@eVoloshchak] Determine if we should create a regression test for this bug.
    • [@eVoloshchak] 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.
    • [@sakluger] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  14. added
    Daily
    and removed
    Weekly
    Daily
    on Oct 9, 2023
  15. Krishna2323 commented on Oct 9, 2023

    @Krishna2323
    Contributor

    @sakluger, bump for payments here, just noting this issue was created on Aug 28.

  16. eVoloshchak commented on Oct 11, 2023

    @eVoloshchak
    Contributor
    • The PR that introduced the bug has been identified. Link to the PR: I'm unable to pinpoint the exact PR that caused this, the root cause for this was present in the initial implementation
    • 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: N/A
    • 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: I don't think an additional discussion is needed, the bug is specific to this particular component, there is no universal approach/checklist item we could implement
  17. eVoloshchak commented on Oct 11, 2023

    @eVoloshchak
    Contributor

    Regression Test Proposal

    1. Open any chat
    2. Send 3-4 images
    3. Scroll through the carousel multiple times
    4. Verify that the loader doesn't briefly appear on top of the image if the image is already loaded

    Do we agree 👍 or 👎

  18. sakluger commented on Oct 12, 2023

    @sakluger
    Contributor

    @Krishna2323 thanks for the reminder on the issue creation date. I updated the offers accordingly.

    @eVoloshchak does not require payment (Eligible for Manual Requests)
    @Krishna2323 requires payment offer (Contributor)
    @Krishna2323 requires payment offer (Contributor)

    Summarizing payouts for this issue:

    Reporter: @Krishna2323 $250 (paid via Upwork)
    Contributor: @Krishna2323 $1000 (paid via Upwork)
    Contributor+: @eVoloshchak $1000 (payable via Manual Request)

    Above payments include efficiency bonus 🎉
    Upwork job: https://www.upwork.com/jobs/~01e48d51a0940adaac

  19. sakluger commented on Oct 12, 2023

    @sakluger
    Contributor

    @eVoloshchak let me know once you've sent the manual request, I'll close the issue at that point. Thanks!

  20. eVoloshchak commented on Oct 12, 2023

    @eVoloshchak
    Contributor

    @sakluger, request has been sent, thank you!

  21. JmillsExpensify commented on Oct 12, 2023

    @JmillsExpensify
    Contributor

    $1,000 payment approved for @eVoloshchak based on BZ summary.

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyEngineeringExternal

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions