Closed m-natarajan closed 2 months ago
Triggered auto assignment to @sakluger (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.
Let's make sure to test this for other SmartScan flows where the user grants camera permission (i.e. track expense).
Job added to Upwork: https://www.upwork.com/jobs/~01a4e1ed614d93976d
Triggered auto assignment to Contributor-plus team member for initial proposal review - @DylanDylann (External
)
I can't reproduce this bug on IOS
On scan tab, alert for asking camera permission open System Setting app, coming back after grating camera permission reloads the app. It should resume from previous page
if we change any app permission in iOS from System Setting, it reloads the app to apply it. As its iOS's default behaviour.
Since it’s OS' natural behaviour to reload the app when permissions changes in System Settings, we can use the Onyx database to track the last screen accessed before the settings change. When the app returns from the settings, we’ll retrieve the last screen from Onyx and navigate back to it if available.
function handlePermissionAfterRestart(status: boolean) {
Onyx.merge(ONYXKEYS.HANDLE_PERMISSION_AFTER_APP_RESTART, status);
}
handlePermissionAfterRestart(true);
if (handlePermissions) {
handlePermissionAfterRestart(false);
interceptAnonymousUser(() =>
IOU.startMoneyRequest(
CONST.IOU.TYPE.SUBMIT,
// When starting to create an expense from the global FAB, there is not an existing report yet. A random optimistic reportID is generated and used
// for all of the routes in the creation flow.
ReportUtils.generateReportID(),
),
);
}
📣 @ravindra-encoresky! 📣 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:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
Contributor details Your Expensify account email: ravindra.singh@encoresky.com Upwork Profile Link: https://www.upwork.com/freelancers/~01f09435e9ae8b77c7
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
@DylanDylann just to make sure, when you tried reproducing, did you remove camera permissions first?
Commenting for melvin
I can reproduce now. To reproduce we need to toggle on the permission before navigating back
https://github.com/user-attachments/assets/2bc08858-5bcd-4a82-b96d-4ec40c7e1958
More information for contributors, When an iOS app requests camera access and the user grants permission, the app restarts due to changes in the app's permission settings. We need to handle this more smoothly and avoid the appearance of a reload.
@DylanDylann thanks for the more clarification, I've tried other solutions as well but somehow it had to take a little navigation before it re-opens the previous page like I added in proposal above.
thanks.
@ravindra-encoresky Thanks for your proposal. Will review soon
@ravindra-encoresky Thanks for your idea. Could you please provide a testing branch for your solution?
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
@ravindra-encoresky Thanks for your idea. Could you please provide a testing branch for your solution?
Here is the branch with working sample - https://github.com/ravindra-encoresky/expensify/tree/46422-Navigated-home-after-camera-permission
Branch contain the code with basic working sample, we can improve it as our requirements
https://github.com/user-attachments/assets/b71ab0d4-2198-4eaf-82e0-e0522ff2ae6b
@ravindra-encoresky After going back to scanning page, an error happens
https://github.com/user-attachments/assets/76950b43-82cc-444f-bd0f-99fa09ef6bdc
I am not facing this issue, please can you provide me more detail, on which ios version you are checking.
@DylanDylann I think you are testing in iOS simulator, camera is not available in iOS simulator thats why you are getting this issue. Also it has no relation to particular changes in this branch, this is existing behaviour
@ravindra-encoresky Thanks for your update. This is an edge case when the app restarts due to changes in the app's permission settings. Let's go with @ravindra-encoresky's proposal
🎀 👀 🎀 C+ reviewed
Triggered auto assignment to @roryabraham, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
hi @roryabraham proposal submitted on upwork.
Thanks for the proposal @ravindra-encoresky, and good job finding the root cause (that the iOS app reloads with changed permissions). However, the solution you've proposed simply isn't flexible or reusable enough. There could be other flows that trigger permissions changes, and we won't always want to navigate to the scan receipt page.
I think you're on the right track though - when triggering a permissions change modal, we want to stash the current navigation state (is the route enough?) and then restore it when the app reopens on permissions change.
I'd also be curious to see if this is discussed in the React Navigation docs and perhaps has a prescribed solution?
I think you're on the right track though - when triggering a permissions change modal, we want to stash the current navigation state (is the route enough?) and then restore it when the app reopens on permissions change.
Agree at this point, we already did that in the test branch by using a new Onyx key called lastScreen. In the PR phase, maybe we need to adjust to set the current route to lastScreen
field when the user opens the permission setting and then use lastScreen
to restore the old state
I'd also be curious to see if this is discussed in the React Navigation docs and perhaps has a prescribed solution?
It sounds great to me
cc @ravindra-encoresky
I'd also be curious to see if this is discussed in the React Navigation docs and perhaps has a prescribed solution?
I have not found anything specific in React Navigation Docs but on multiple places same solution is recommended.
https://github.com/zoontek/react-native-permissions/issues/307 https://stackoverflow.com/questions/31706447/how-can-i-prevent-ios-apps-from-resetting-after-changing-camera-permissions
📣 @DylanDylann 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!
📣 @ravindra-encoresky 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!
Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑💻 Keep in mind: Code of Conduct | Contributing 📖
📣 @ravindra-encoresky 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!
Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑💻 Keep in mind: Code of Conduct | Contributing 📖
Offer accepted. PR will be submitted by today 12 Aug 2024.
hi @m-natarajan @sakluger since the PR is done, could you please complete the job on Upwork ?
thanks.
@sakluger The PR was deployed to production on August 31st. The payment should be issued on September 6th
@DylanDylann @sakluger thanks, waiting for the job to be completed on upwork.
Thanks everyone and sorry for the delay - our usual automation failed, so I will handle the updates and payments manually now. @DylanDylann can you please let us know if you think we need regression test steps for this case?
Summarizing payment on this issue:
Contributor: @ravindra-encoresky $250, paid via Upwork Contributor+: @DylanDylann $250, paid via Upwork
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:
[@DylanDylann] The PR that introduced the bug has been identified. Link to the PR: NA [@DylanDylann] 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: NA [@DylanDylann] 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: NA [@DylanDylann] Determine if we should create a regression test for this bug. Yes [@DylanDylann] 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 Proposal: Only for IOS native App
Do we agree 👍 or 👎
Looks good. Thanks!
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: 9.0.13-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: @cristipaval Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1722253630425759
Action Performed:
<- NewExpensify
on the top left corner of the iPhoneExpected Result:
Should resume the Submit Expense flow from where I left
Actual Result:
Landed on the home screen and I had to start the Submit Expense flow again
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
https://github.com/user-attachments/assets/264bf230-249b-4786-bd29-69f93ecd840f
View all open jobs on GitHub
Upwork Automation - Do Not Edit