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 2024-06-03] [$500] mWeb - Attachment - "Failed to load PDF file" message only appears if I swipe the chat #32109

Closed
1 of 6 tasks
kbecciv opened this issue Nov 28, 2023 · 78 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 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@kbecciv
Copy link

kbecciv commented Nov 28, 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!


Version Number: 1.4.4.0
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
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Navigate to https://staging.new.expensify.com/
  2. Log in
  3. Upload a corrupted PDF to any conversation
  4. Swipe up

PDF file
Corrupted PDF.pdf

Expected Result:

"Failed to load PDF file" should be visible without taking any actions.

Actual Result:

"Failed to load PDF file" message only appears if I swipe the chat. An empty space blocks the view.

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6293097_1701173560223.Tbxn2307.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~016eebac1c88fbedc0
  • Upwork Job ID: 1729483719196209152
  • Last Price Increase: 2023-12-19
  • Automatic offers:
    • ishpaul777 | Contributor | 28089228
Issue OwnerCurrent Issue Owner: @johncschuster
@kbecciv kbecciv added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Nov 28, 2023
@melvin-bot melvin-bot bot changed the title mWeb - Attachment - "Failed to load PDF file" message only appears if I swipe the chat [$500] mWeb - Attachment - "Failed to load PDF file" message only appears if I swipe the chat Nov 28, 2023
Copy link

melvin-bot bot commented Nov 28, 2023

Job added to Upwork: https://www.upwork.com/jobs/~016eebac1c88fbedc0

Copy link

melvin-bot bot commented Nov 28, 2023

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

Copy link

melvin-bot bot commented Nov 28, 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

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

melvin-bot bot commented Nov 28, 2023

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

@ishpaul777
Copy link
Contributor

@kbecciv can you please add the pdf file with which this is reproducable ?

@kbecciv
Copy link
Author

kbecciv commented Nov 28, 2023

@ishpaul777 Sure, added under action performed.

image

@ishpaul777
Copy link
Contributor

Thanks! @kbecciv

@shreyfirst
Copy link

Proposal

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

When uploading a corrupted PDF, the chat view will render an empty view (which takes up the entire screen), until an action/re-render is done such as scrolling up or clicking the text). This issue arises in the native iOS and Android platform (the provided video in OP was also in the native app also).

What is the root cause of that problem?

There is a state management issue in the native PDFView component. The state variables shouldAttemptPDFLoad and failedToLoadPDF handle what to show to the user in this scenario, but they are not working as intended.

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

I will first attempt to debug which state variables are changing when, then make the appropriate changes to ensure that it shows "Failed to load PDF file" without you having to do any actions. This implementation of state variables for PDF load (excluding PDFs with passwords) relies on 3 conditions, whether it is OK to load, already failed, and if it's loading. I will see if simplifying these solves the problem.

@tienifr
Copy link
Contributor

tienifr commented Nov 29, 2023

Proposal

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

"Failed to load PDF file" message only appears if I swipe the chat. An empty space blocks the view.

What is the root cause of that problem?

Why doesn't this issue occur with correctPDF or PDF with password?

  • For correct PDF/PDF with password, BE will return the message.html as <img/> -> ImageRender is used to render thumbnail without loading indicator

  • For the failed PDF, BE return the message.html as <a/> -> AnchorForAttachmentsOnly is used, and in AnchorForAttachmentsOnly we use PDFView to render the pdf attachment

In here, we'll be showing the PDF loading state while we're trying to load the corrupted PDF. This PDF loading is supposed to be for the Attachment modal, which uses full screen height here. This causes the large blank space with activity indicator to appear when the corrupted PDF is being loaded, and after the loading failure, it will show the Failed to load PDF file, leaving the blank space behind.

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

Solution 1: Invisible loading

The blank space loading with indicator should not be there, because it's inconsistent with other PDF types (correct PDF, PDF with password) which doesn't have any loading

We should disable it by passing a flag shouldLoadAttachmentInBackground to AnchorForAttachmentsOnly

shouldLoadAttachmentInBackground = {true}

AttachmentView > AttachmentViewPdf > PDFView

If the flag is true, we set the height of the PDF to 0 so it will load in the background and not affecting other report action items. Once it's failed to load due to corruption, it will just show the Failed to load PDF file message as currently.

Update this line to

        const pdfStyles = [this.props.themeStyles.imageModalPDF, StyleUtils.getWidthAndHeightStyle(this.props.windowWidth, shouldLoadAttachmentInBackground? 0: this.props.windowHeight)];
Result
Screen.Recording.2023-11-29.at.16.42.20.mov

Solution 2: Visible loading

Because the current height of loading is set to screenHeight > AUTOSCROLL_TO_TOP_THRESHOLD (128px), so the list is not scrolled to bottom when the PDF is failed.

So we need to adjust the height here to be less than AUTOSCROLL_TO_TOP_THRESHOLD, we just do it if it is report action, otherwise we need to show the full screen loading (view full pdf document). For example, we can set 100px, if we want to increase the loading height, we have to increase AUTOSCROLL_TO_TOP_THRESHOLD as well

Result
Screen.Recording.2023-12-25.at.13.48.29.mov

What alternative solutions did you explore? (Optional)

@ishpaul777
Copy link
Contributor

ishpaul777 commented Nov 29, 2023

Proposal

Problem

Failed to load PDF file" message only appears if I swipe the chat

Root Cause

This happens because we set the width and height to equal to window height for Pdf View and when the Pdf view unmounte on error in Pdf loading the inverted flatlist fails to scroll down for the bottom most item(the pdf attachment) size change (this doesn't happen when we quicky sends a message when uploading of pdf is in progress)

Changes Suggested

At present, the loading indicator takes full window height when pdf is loading and is not consistent with the image loading style, also when we click the "failed to load" it downloads the pdf but user has no idea why attachment is downloaded (there is no indication that clicking the message download the file) for better UX we will use the loading indicatior in a box like image loading, and when the pdf failed to load we set message to be in same height as of the loading box so there is no resizing. (exact design details should be discussed with design team)

Summary of Solution:

  • We have the loading indicator outside the Pdfview and when loading in progress set pdf view invisible so no extra space is visible
  • incase the pdf fails to load, we have a fallbackcomponent either inbuild in component or passed as prop from upstream

Code Changes Details:

  1. Drill the isUsedInAttachmentModal and isUsedInCarousel props all the way to PdfView from AttachmentView
  • Drill a prop renderFallBack prop which have the fallback preview component from AttachmentView

Apply below changes only !(`isUsedInAttachmentModal` &&`isUsedInCarousel`) (assuming the changes are specific to pdf preview for message)

  1. We need to show the loading indicator outside the PdfView component like below code:
    (styles to be confirmed with design team)
{this.state.shouldShowLoadingIndicator && isUsedInAsMessageAttachment && (
  <View style={[this.props.themeStyles.flex0, this.props.themeStyles.justifyContentCenter, this.props.themeStyles.alignItemsCenter, this.props.themeStyles.chatItemAttachmentPlaceholder]}>
     <ActivityIndicator />
  </View>
)}
  1. Apply this.props.themeStyles.invisible style to PdfView when (isUsedInAttachmentModal &&isUsedInCarousel && this.state.shouldShowLoadingIndicator) so there is no large space after the pdf fails to load component unmount.

To render Fallback Icon-

  • For Native src/components/PDFView/index.js)
    Change this text component with {this.props.renderFallback()}

<View style={[this.props.themeStyles.flex1, this.props.themeStyles.justifyContentCenter]}>
<Text style={this.props.errorLabelStyles}>{this.props.translate('attachmentView.failedToLoadPDF')}</Text>
</View>

  • For Web Component (src/components/PDFView/index.js)-
    change the error component to error={this.props.renderFallback()}

<Document
error={<Text style={this.props.errorLabelStyles}>{this.props.translate('attachmentView.failedToLoadPDF')}</Text>}

POC -

Screen.Recording.2023-12-01.at.4.24.36.AM.mov

@parasharrajat
Copy link
Member

Reviewing...

@parasharrajat
Copy link
Member

So We do want the loader to stay. There is also a loader for correct PDFs/images.

So the issue should be fixed via styles. @tienifr Can you please update your proposal to mention what styles and where?

@ishpaul777 Good find. But Can you please do an impact analysis on your proposal and provide results on various involved UI parts?

  1. What will happen when we resize?
  2. How will this affect other platforms?
  3. How does changing the styles for the virtualized list container solve this issue?

Good plan in the alternative idea but we don't want to show the error in the box equal to the normal image attachment height. let's just show this as a normal file.

for better UX we will use the loading indicator in a box like image loading,

How?

@ishpaul777
Copy link
Contributor

ishpaul777 commented Nov 30, 2023

I am withdrawing my initial proposal as i am unable to dig for the why adding flewGrow0 to a inverted flatlist does solves the issue, also as I double checked the solution I found it to be not working for some chats (admins room chat to be specific not sure why?) and in general i beleive it is risky play with inverted list style (too many things that can go wrong...)

Still standing with alternative solution (updated)

test brach may help to review changes better

@tienifr
Copy link
Contributor

tienifr commented Dec 1, 2023

So the issue should be fixed via styles. @tienifr Can you please update your proposal to mention what styles and where?

@parasharrajat I just added the implementation detail to my proposal

@melvin-bot melvin-bot bot added the Overdue label Dec 2, 2023
@johncschuster
Copy link
Contributor

@parasharrajat, can you review @tienifr's proposal when you get a moment? Thank you!

@melvin-bot melvin-bot bot removed the Overdue label Dec 4, 2023
Copy link

melvin-bot bot commented Dec 5, 2023

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

@parasharrajat
Copy link
Member

I will review the changes in 12hours. Gotta go somewhere.

@melvin-bot melvin-bot bot added the Overdue label Dec 8, 2023
@johncschuster
Copy link
Contributor

@parasharrajat bump! Can you review the changes when you get a moment?

@melvin-bot melvin-bot bot removed the Overdue label Dec 8, 2023
@ishpaul777
Copy link
Contributor

@shawnborton @dannymcclain Which one is decided 🤔

@shawnborton
Copy link
Contributor

We earlier decided that we treat failed PDFs as files and allow the user to download via the normal file preview we use.

^^ That sounds good, let's do it.

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Mar 15, 2024
@parasharrajat
Copy link
Member

@yuwenmemon Could you please help review Expensify/react-fast-pdf#17 PR on react-fast-pdf repo?

@parasharrajat
Copy link
Member

Bump @yuwenmemon for Expensify/react-fast-pdf#17

@yuwenmemon
Copy link
Contributor

Merged!

@melvin-bot melvin-bot bot added Monthly KSv2 and removed Weekly KSv2 labels Apr 29, 2024
Copy link

melvin-bot bot commented Apr 29, 2024

This issue has not been updated in over 15 days. @yuwenmemon, @johncschuster, @parasharrajat, @ishpaul777 eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@parasharrajat
Copy link
Member

Waiting on version bump for react-fast-pdf to be able to continue with the review.

@parasharrajat
Copy link
Member

PR is merged.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Monthly KSv2 labels May 27, 2024
@melvin-bot melvin-bot bot changed the title [$500] mWeb - Attachment - "Failed to load PDF file" message only appears if I swipe the chat [HOLD for payment 2024-06-03] [$500] mWeb - Attachment - "Failed to load PDF file" message only appears if I swipe the chat May 27, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label May 27, 2024
Copy link

melvin-bot bot commented May 27, 2024

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

Copy link

melvin-bot bot commented May 27, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.75-1 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 2024-06-03. 🎊

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

Copy link

melvin-bot bot commented May 27, 2024

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:

  • [@parasharrajat / @ishpaul777] The PR that introduced the bug has been identified. Link to the PR:
  • [@parasharrajat / @ishpaul777] 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:
  • [@parasharrajat / @ishpaul777] 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:
  • [@parasharrajat / @ishpaul777] Determine if we should create a regression test for this bug.
  • [@parasharrajat / @ishpaul777] 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.
  • [@johncschuster] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@johncschuster
Copy link
Contributor

Payment Summary

C+ Reviewer: @parasharrajat - $500 - paid via Manual Requests
Contributor: @ishpaul777 - $500 - Paid via Upwork (on June 3)

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jun 2, 2024
@johncschuster
Copy link
Contributor

johncschuster commented Jun 3, 2024

I have issued payment to @ishpaul777 via Upwork 🎉

@parasharrajat / @ishpaul777 can you complete the BZ Checklist above?

@parasharrajat
Copy link
Member

parasharrajat commented Jun 3, 2024

I couldn't figure out the PR responsible for the issue. I would love some help here. In the meantime, I am adding the checklist as I don't think that we should block this for the root cause PR.

@parasharrajat
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:

  • [@parasharrajat] The PR that introduced the bug has been identified. Link to the PR: Not Found
  • [@parasharrajat] 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: Not found
  • [@parasharrajat] 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: Not required
  • [@parasharrajat] Determine if we should create a regression test for this bug. yes
  • [@parasharrajat] 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.

Regression Test Steps

  1. Log in to the new dot
  2. Upload a corrupted PDF to any conversation
  3. Verify No blank space in the chat area while loading the pdf file. UI does not break on any platform.
  4. Verify if the pdf fails to load it falls back to the default attachment view like below.

image

Do you agree 👍 or 👎 ?

@johncschuster
Copy link
Contributor

Thanks for the regression test steps, @parasharrajat! Please send your Manual Request for payment (summary above)

@parasharrajat
Copy link
Member

Payment requested as per #32109 (comment)

@JmillsExpensify
Copy link

$500 approved for @parasharrajat

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 Engineering External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests