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-11-05] [$250] IOU - mWeb - User trying to upload receipt by quickly tapping capture button shows error #50083

Closed
2 of 6 tasks
IuliiaHerets opened this issue Oct 2, 2024 · 32 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

@IuliiaHerets
Copy link

IuliiaHerets commented Oct 2, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: v9.0.43-1
Reproducible in staging?: Y
Reproducible in production?: N
Issue reported by: Applause Internal Team

Action Performed:

  1. Go to https://staging.new.expensify.com/home
  2. Go to DM.
  3. Submit an expense.
  4. Go to transaction thread.
  5. Tap Add receipt modal.
  6. Quickly tap capture button many times before the camera is initiated.

Expected Result:

User trying to upload receipt by quickly tapping capture button must able to upload receipt.

Actual Result:

User trying to upload receipt by quickly tapping capture button shows error "The receipt didn't upload.Download the file or dismiss this error and lose it."

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6622046_1727886169840.Screenrecorder-2024-10-02-21-46-43-70_compress_1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021841557091803230884
  • Upwork Job ID: 1841557091803230884
  • Last Price Increase: 2024-10-02
  • Automatic offers:
    • QichenZhu | Contributor | 104415140
Issue OwnerCurrent Issue Owner: @Christinadobrzyn
@IuliiaHerets IuliiaHerets added DeployBlockerCash This issue or pull request should block deployment Bug Something is broken. Auto assigns a BugZero manager. labels Oct 2, 2024
Copy link

melvin-bot bot commented Oct 2, 2024

Triggered auto assignment to @marcochavezf (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

Copy link

melvin-bot bot commented Oct 2, 2024

Triggered auto assignment to @Christinadobrzyn (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@melvin-bot melvin-bot bot added the Daily KSv2 label Oct 2, 2024
@github-actions github-actions bot added Engineering Hourly KSv2 and removed Daily KSv2 labels Oct 2, 2024
Copy link
Contributor

github-actions bot commented Oct 2, 2024

👋 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.

@marcochavezf
Copy link
Contributor

This is a frontend issue, making it external to get more 👀

@marcochavezf marcochavezf added the External Added to denote the issue can be worked on by a contributor label Oct 2, 2024
Copy link

melvin-bot bot commented Oct 2, 2024

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

@melvin-bot melvin-bot bot changed the title IOU - mWeb - User trying to upload receipt by quickly tapping capture button shows error [$250] IOU - mWeb - User trying to upload receipt by quickly tapping capture button shows error Oct 2, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 2, 2024
Copy link

melvin-bot bot commented Oct 2, 2024

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

@marcochavezf
Copy link
Contributor

I cannot reproduce this error consistently in staging. Also, I don't think this specific behavior on mweb should be considered a blocker, but it still needs a fix

@marcochavezf marcochavezf added Daily KSv2 and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 labels Oct 2, 2024
@QichenZhu
Copy link
Contributor

QichenZhu commented Oct 3, 2024

Edited by proposal-police: This proposal was edited at 2024-10-03 09:00:50 UTC.

Proposal

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

Quickly tapping the shutter results in an error or crash.

What is the root cause of that problem?

The root causes for web and native platforms are different.

Android mWeb & iOS mWeb

  1. This line below calls getScreenshot.

const imageBase64 = cameraRef.current.getScreenshot();

  1. The method returns null when the camera is not ready.
    https://github.com/mozmorris/react-webcam/blob/7522284fd66f98ff2d846e73881f65d35e840dab/src/react-webcam.tsx#L195-L205
Screenshot 2024-10-03 at 9 28 28 PM

  1. The line below generates an empty file if the return value is null.

const file = FileUtils.base64ToFile(imageBase64 ?? '', filename);

  1. The server returns an error when the file is empty.

Screenshot 2024-10-03 at 9 18 25 PM

Android Native & iOS Native

  1. Quickly tapping the shutter starts multiple asynchronous operations.

After one operation completes, the page navigates back and the camera closes, so the remaining operations fail.

camera?.current
?.takePhoto({
flash: flash && hasFlash ? 'on' : 'off',
enableShutterSound: !user?.isMutedAllSounds,
})
.then((photo: PhotoFile) => {

  1. There is a didCapturePhoto state that can lock the camera to make sure only one operation runs at a time. But it only partially works for new money requests and doesn’t work when editing requests.

if (isEditing) {
updateScanAndNavigate(file, source);
return;
}
setDidCapturePhoto(true);
navigateToConfirmationStep(file, source);

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

Android mWeb & iOS mWeb

  1. Add an isReady state.
const [isReady, setIsReady] = useState(false);
  1. Set it to true in the onUserMedia handler.
    const setupCameraPermissionsAndCapabilities = (stream: MediaStream) => {
setIsReady(true);
  1. Disable and hide the shutter button when it is false.
    accessibilityLabel={translate('receipt.shutter')}
style={[styles.alignItemsCenter, !isReady && styles.opacity0]}
disabled={!isReady}
  1. There's one more issue to fix on the backend. If you upload an empty file to an expense, future uploads even with valid photos will always fail for that expense.

Android Native & iOS Native

  1. Move Line 469 before Line 454 to lock the camera immediately when the shutter is tapped, so following taps will be ignored.

camera?.current
?.takePhoto({

  1. Replace Line 471 with the code below to unlock the camera on error.
}, () => {
    setDidCapturePhoto(false);
    showCameraAlert();
    Log.warn('Error reading photo');
});

What alternative solutions did you explore? (Optional)

Android mWeb & iOS mWeb

On the frontend, we can add a null check after calling getScreenshot and return early to simply ignore clicks on the shutter button before the camera is ready.

const imageBase64 = cameraRef.current.getScreenshot();

if (imageBase64 === null) {
    return;
}

@Christinadobrzyn
Copy link
Contributor

hi @fedirjh can you review this proposal? TY!

@melvin-bot melvin-bot bot added the Overdue label Oct 7, 2024
@marcochavezf
Copy link
Contributor

Not overdue waiting for C+ review and/or more proposals

@melvin-bot melvin-bot bot removed the Overdue label Oct 7, 2024
@Christinadobrzyn
Copy link
Contributor

@fedirjh can you provide an update on this? Thanks!

@fedirjh
Copy link
Contributor

fedirjh commented Oct 9, 2024

@QichenZhu Proposal looks good to me. The root cause analysis and solution seem accurate. Let's move forward with the alternative solution. It is straightforward and does not require any design changes.

🎀 👀 🎀 C+ reviewed

@QichenZhu
Copy link
Contributor

QichenZhu commented Oct 15, 2024

@fedirjh This is marked as Android mWeb only, but I got an error pop-up when testing on Android Native, and the app crashed on iOS Native.

Android iOS
android.mp4
ios.mov

Do you think it should be handled in a separate issue?

cc @marcochavezf @Christinadobrzyn

@Christinadobrzyn
Copy link
Contributor

I think we can just include it in this issue if it's the same issue on a different device. Does that sound good, @fedirjh?

@QichenZhu
Copy link
Contributor

QichenZhu commented Oct 15, 2024

I think the issue on native platforms is not related to the web issue. Previously, we had an issue #36520, where double tapping the shutter caused an error. It was fixed by #38320 for the new money request workflow but not for the edit request workflow, so it appears here now. The root cause is explained here: #36520 (comment).

@QichenZhu
Copy link
Contributor

Proposal

Updated

Added the root cause and solution for the native platform issue.

@Christinadobrzyn
Copy link
Contributor

@fedirjh can you please review and let us know what you think is best, should these be fixed together or separate?

Copy link

melvin-bot bot commented Oct 16, 2024

@marcochavezf @fedirjh @Christinadobrzyn @QichenZhu this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

Copy link

melvin-bot bot commented Oct 18, 2024

@marcochavezf, @fedirjh, @Christinadobrzyn, @QichenZhu Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot added the Overdue label Oct 18, 2024
@marcochavezf
Copy link
Contributor

marcochavezf commented Oct 18, 2024

@QichenZhu thanks for bringing this up, the solution for native LGTM. We can address any other issue (if any) in the PR

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Overdue Daily KSv2 labels Oct 18, 2024
@Christinadobrzyn
Copy link
Contributor

Just checking in on this, I think we're working on a PR, is that right @QichenZhu?

@QichenZhu
Copy link
Contributor

@Christinadobrzyn The PR #50770 has been merged and deployed to staging.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 29, 2024
@melvin-bot melvin-bot bot changed the title [$250] IOU - mWeb - User trying to upload receipt by quickly tapping capture button shows error [HOLD for payment 2024-11-05] [$250] IOU - mWeb - User trying to upload receipt by quickly tapping capture button shows error Oct 29, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 29, 2024
Copy link

melvin-bot bot commented Oct 29, 2024

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

Copy link

melvin-bot bot commented Oct 29, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.54-11 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-11-05. 🎊

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

Copy link

melvin-bot bot commented Oct 29, 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:

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

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Nov 4, 2024
@Christinadobrzyn
Copy link
Contributor

Christinadobrzyn commented Nov 5, 2024

Payouts due:

@fedirjh do we need a regression test for this?

@fedirjh
Copy link
Contributor

fedirjh commented Nov 5, 2024

do we need a regression test for this?

Yes.

Regression Test Proposal

Precondition: Camera permission is granted.

1. Open New Dot on mobile web or native app
2. Go to DM
3. Submit a manual expense
4. Go to transaction thread
5. Tap the receipt placeholder
6. Once you see the shutter button quickly tap it several times before the camera initializes
7. Verify that there is no error message or crash
  • Do we agree 👍 or 👎

@Christinadobrzyn
Copy link
Contributor

Christinadobrzyn commented Nov 6, 2024

Awesome! payment day is today. Payment Summary.

Regression test https://github.com/Expensify/Expensify/issues/442076

@fedirjh can you please request payment through ND?

@Christinadobrzyn
Copy link
Contributor

DMd @fedirjh to request payment. Going to close this as complete since that's all that's outstanding.

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
Status: Done
Development

No branches or pull requests

5 participants