Skip to content

[C+ Checklist Needs Completion] [$500] Android - Scan - Second tap on capture button causes error to show up #36520

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!


Version Number: 1.4.41-3
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:

Precondition: Camera access is allowed

  1. Launch New Expensify app
  2. Tap + > Request money
  3. Go to Scan
  4. Tap on the capture button twice

Expected Result:

The second tap on the capture button should be disabled and no error will show up

Actual Result:

The second tap on the capture button is enabled, causing error to show up

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

Bug6379529_1707925292817.Screen_Recording_20240214_215216_New_Expensify.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~017ba8b79a30323bee
  • Upwork Job ID: 1757796267721375744
  • Last Price Increase: 2024-02-14
  • Automatic offers:
    • hoangzinh | Reviewer | 0

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Feb 14, 2024
  2. changed the title [-]Android - Scan - Second tap on capture button causes error to show up[/-] [+][$500] Android - Scan - Second tap on capture button causes error to show up[/+] on Feb 14, 2024
  3. melvin-bot commented on Feb 14, 2024

    @melvin-bot
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Feb 14, 2024
  5. melvin-bot commented on Feb 14, 2024

    @melvin-bot

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

  6. melvin-bot commented on Feb 14, 2024

    @melvin-bot

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

  7. lanitochka17 commented on Feb 14, 2024

    @lanitochka17
    Author

    We think that this bug might be related to #wave5
    CC @quinthar

  8. agent3bood commented on Feb 14, 2024

    @agent3bood
    Contributor

    Proposal

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

    Android - Scan - Second tap on capture button causes error to show up

    What is the root cause of that problem?

    This is multiple levels of issues causing the problem.

    • In src/pages/iou/request/step/IOURequestStepScan/index.native.js the capturePhoto has an async operation, we need to return a Promise to make it work with the native implementation of singleExecution.
    • The native implementation expects a promise to be returned for it to work, if we don't return a promise then the singleExecution will exit before the async operation has completed which means the function can be called again before the async function is completed.
    • Current code execution flow is like this
    // 1. `singleExecution` will make sure this is called just once 
    capturePhoto() {
      // ... code
      
      // 2. this async callback function is added to the event loop to be executed in future tick/time.
      camera.current.takePhoto().then() => {
        // 4. some time later, the event loop will execute this code, it has nothing to do with `singleExecution`, and if the camera is busy it will throw.
      } 
    
      //
      // ... code
     // 3. function code is completed, `singleExecution` job is done here.
    }
    
    • We need to fix all components that wrap capturePhoto to return a Promise, and not ignore it, for example in here the promise is not returned properly.
    • As for web, this is not an issue because the capturePhoto function is completely sync.

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

    • Make capturePhoto return a Promise.
    • Fix all components that wrap capturePhoto to return a Promise, and not ignore it.
    • Make sure I am not introducing new async operation when the callback is just a sync operation (i.e. do not do return new Promise(/* some sync result */))
    // bad
    return new Promise((resolve) => {
      const results = onPress(event);
      if(results instanceof Promise) {
        return results.finally(() => {resolve();});
      } 
    });
    
    // good
    const results = onPress(event);
    ... other code might live here
    return results;
    

    What alternative solutions did you explore? (Optional)

    See previous proposal.

    original proposal

    Proposal

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

    Android - Scan - Second tap on capture button causes error to show up

    What is the root cause of that problem?

    In IOURequestStepScan.capturePhoto there is an async operation to capture the photo camera.current.takePhoto().then(), only after the async operation we do the navigation/error handling.
    Between the time of requesting the first photo and getting the results if the user calls the capture button again, the camera is already busy and we get an error.

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

    Add a new flag capturePhotoInProgress and return early from capturePhoto if it is true. Set the variable to true when we start the function and reset it when it is done.

    What alternative solutions did you explore? (Optional)

  9. Krishna2323 commented on Feb 14, 2024

    @Krishna2323
    Contributor

    Proposal

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

    Android - Scan - Second tap on capture button causes error to show up

    What is the root cause of that problem?

    When we call capturePhoto is called we call camera.current.takePhoto which is a async operation and if we immediately call capturePhoto again the camera is busy and !camera.current is true.

    if (!camera.current) {
    showCameraAlert();
    return;
    }

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

    We need to use useSingleExecution to solve this bug.

    Result

  10. EnderKilledYou commented on Feb 14, 2024

    @EnderKilledYou

    So I see these on upwork. Are they taken or finished since they have a proposal? If I apply there am I wasting connects? I can update this one for sure. You can also disable the button or remove the click handler and add it back later.

  11. melvin-bot commented on Feb 14, 2024

    @melvin-bot

    📣 @EnderKilledYou! 📣
    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. Make sure you've read and understood the contributing guidelines.
    2. 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.
    3. 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.
    4. 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>
    
  12. 62 remaining items

  13. changed the title [-][$500] Android - Scan - Second tap on capture button causes error to show up[/-] [+][HOLD for payment 2024-04-15] [$500] Android - Scan - Second tap on capture button causes error to show up[/+] on Apr 8, 2024
  14. melvin-bot commented on Apr 8, 2024

    @melvin-bot

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

  15. melvin-bot commented on Apr 8, 2024

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.60-13 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-04-15. 🎊

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

  16. melvin-bot commented on Apr 8, 2024

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

    • [@hoangzinh] The PR that introduced the bug has been identified. Link to the PR:
    • [@hoangzinh] 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:
    • [@hoangzinh] 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:
    • [@hoangzinh] Determine if we should create a regression test for this bug.
    • [@hoangzinh] 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.
    • [@greg-schroeder] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  17. greg-schroeder commented on Apr 15, 2024

    @greg-schroeder
    Contributor

    Payment summary:

    @agent3bood - $500 - C
    @hoangzinh - $500 - C+

  18. greg-schroeder commented on Apr 15, 2024

    @greg-schroeder
    Contributor

    The upwork issue closed for inactivity, creating a new one via #40222

    Offers sent manually - please accept them and I can pay them out tomorrow.

    Last up is @hoangzinh to take care of the checklist :)

  19. changed the title [-][HOLD for payment 2024-04-15] [$500] Android - Scan - Second tap on capture button causes error to show up[/-] [+][C+ Checklist Needs Completion] [$500] Android - Scan - Second tap on capture button causes error to show up[/+] on Apr 15, 2024
  20. hoangzinh commented on Apr 16, 2024

    @hoangzinh
    Contributor

    Accepeted. Thanks @greg-schroeder. I will complete the checklist today

  21. hoangzinh commented on Apr 16, 2024

    @hoangzinh
    Contributor

    Regression Test Proposal

    On Native Apps/mWeb:

    1. Open Expensify app
    2. Tap + > Request money
    3. Go to Scan
    4. Tap on the capture button multiple times
    5. Verify that the App captures successfully and no errors popup

    Do we agree 👍 or 👎

  22. hoangzinh commented on Apr 16, 2024

    @hoangzinh
    Contributor

    BugZero Checklist:

  23. techievivek commented on Apr 18, 2024

    @techievivek
    Contributor

    Regression test looks good to me. @greg-schroeder Can we get this added? Thanks.

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.DailyKSv2InternalRequires API changes or must be handled by Expensify staff

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions