You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[C+ Checklist Needs Completion] [$500] Android - Scan - Second tap on capture button causes error to show up #36520
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
Launch New Expensify app
Tap + > Request money
Go to Scan
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?
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
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)
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.
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.
📣 @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:
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.
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.
Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
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
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:
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:
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
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: N/A
Determine if we should create a regression test for this bug: Yes
Activity
[-]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[/+]melvin-bot commentedon Feb 14, 2024
Job added to Upwork: https://www.upwork.com/jobs/~017ba8b79a30323bee
melvin-bot commentedon Feb 14, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @hoangzinh (
External)melvin-bot commentedon Feb 14, 2024
Triggered auto assignment to @greg-schroeder (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.lanitochka17 commentedon Feb 14, 2024
We think that this bug might be related to #wave5
CC @quinthar
agent3bood commentedon Feb 14, 2024
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.
src/pages/iou/request/step/IOURequestStepScan/index.native.jsthecapturePhotohas an async operation, we need to return aPromiseto make it work with the native implementation ofsingleExecution.singleExecutionwill exit before the async operation has completed which means the function can be called again before the async function is completed.capturePhototo return aPromise, and not ignore it, for example in here the promise is not returned properly.capturePhotofunction is completely sync.What changes do you think we should make in order to solve the problem?
capturePhotoreturn aPromise.capturePhototo return aPromise, and not ignore it.return new Promise(/* some sync result */))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.capturePhotothere is an async operation to capture the photocamera.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
capturePhotoInProgressand return early fromcapturePhotoif 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)
Krishna2323 commentedon Feb 14, 2024
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
capturePhotois called we callcamera.current.takePhotowhich is a async operation and if we immediately callcapturePhotoagain the camera is busy and!camera.currentis true.App/src/pages/iou/request/step/IOURequestStepScan/index.native.js
Lines 234 to 237 in 04d7efd
What changes do you think we should make in order to solve the problem?
We need to use
useSingleExecutionto solve this bug.Result
EnderKilledYou commentedon Feb 14, 2024
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.
melvin-bot commentedon Feb 14, 2024
📣 @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:
Format:
62 remaining items
[-][$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[/+]melvin-bot commentedon Apr 8, 2024
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Apr 8, 2024
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:
melvin-bot commentedon Apr 8, 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:
greg-schroeder commentedon Apr 15, 2024
Payment summary:
@agent3bood - $500 - C
@hoangzinh - $500 - C+
greg-schroeder commentedon Apr 15, 2024
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 :)
[-][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[/+]hoangzinh commentedon Apr 16, 2024
Accepeted. Thanks @greg-schroeder. I will complete the checklist today
hoangzinh commentedon Apr 16, 2024
Regression Test Proposal
On Native Apps/mWeb:
Do we agree 👍 or 👎
hoangzinh commentedon Apr 16, 2024
BugZero Checklist:
techievivek commentedon Apr 18, 2024
Regression test looks good to me. @greg-schroeder Can we get this added? Thanks.