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-09-06] [$250] Navigated back to the home screen after granting for Camera permission #46422

Closed
1 of 6 tasks
m-natarajan opened this issue Jul 29, 2024 · 38 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 External Added to denote the issue can be worked on by a contributor

Comments

@m-natarajan
Copy link

m-natarajan commented Jul 29, 2024

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:

  1. Start Submit Expense flow from Global Create
  2. Tap on the Scan tab
  3. Go to the Phone settings from the system prompt asking for Camera permission
  4. Go back to the App by tapping on <- NewExpensify on the top left corner of the iPhone

Expected 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?

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

Screenshots/Videos

Add any screenshot/video evidence

Recording.3144.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01a4e1ed614d93976d
  • Upwork Job ID: 1818030342834766613
  • Last Price Increase: 2024-08-05
  • Automatic offers:
    • DylanDylann | Reviewer | 103467157
    • ravindra-encoresky | Contributor | 103467159
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 29, 2024
Copy link

melvin-bot bot commented Jul 29, 2024

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.

@sakluger
Copy link
Contributor

Let's make sure to test this for other SmartScan flows where the user grants camera permission (i.e. track expense).

@sakluger sakluger added the External Added to denote the issue can be worked on by a contributor label Jul 29, 2024
@melvin-bot melvin-bot bot changed the title Navigated back to the home screen after granting for Camera permission [$250] Navigated back to the home screen after granting for Camera permission Jul 29, 2024
Copy link

melvin-bot bot commented Jul 29, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 29, 2024
Copy link

melvin-bot bot commented Jul 29, 2024

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

@DylanDylann
Copy link
Contributor

I can't reproduce this bug on IOS

@ravindra-encoresky
Copy link
Contributor

Proposal

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

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

What is the root cause of that problem?

if we change any app permission in iOS from System Setting, it reloads the app to apply it. As its iOS's default behaviour.

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

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.

  1. We will create a action to save permission asked status
function handlePermissionAfterRestart(status: boolean) {
    Onyx.merge(ONYXKEYS.HANDLE_PERMISSION_AFTER_APP_RESTART, status);
}
  1. Set value to true below Linking.openSettings();
    {
    text: Localize.translateLocal('common.settings'),
    onPress: () => {
    Linking.openSettings();
    },
    },
handlePermissionAfterRestart(true);
  1. Check this value after app reload and navigate to scan screen if value is true. Also reset value back to false in Onyx database
    useEffect(() => {
    Performance.markStart(CONST.TIMING.SIDEBAR_LOADED);
    Timing.start(CONST.TIMING.SIDEBAR_LOADED, 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(),
                ),
            );
        }

What alternative solutions did you explore? (Optional)

This comment was marked as resolved.

@ravindra-encoresky

This comment was marked as resolved.

This comment was marked as resolved.

@sakluger
Copy link
Contributor

sakluger commented Aug 1, 2024

@DylanDylann just to make sure, when you tried reproducing, did you remove camera permissions first?

@melvin-bot melvin-bot bot added the Overdue label Aug 1, 2024
@sakluger
Copy link
Contributor

sakluger commented Aug 1, 2024

Commenting for melvin

@melvin-bot melvin-bot bot removed the Overdue label Aug 1, 2024
@DylanDylann
Copy link
Contributor

I can reproduce now. To reproduce we need to toggle on the permission before navigating back

Screen.Recording.2024-08-02.at.12.11.25.mov

@DylanDylann
Copy link
Contributor

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.

@ravindra-encoresky
Copy link
Contributor

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

@DylanDylann
Copy link
Contributor

@ravindra-encoresky Thanks for your proposal. Will review soon

@melvin-bot melvin-bot bot added the Overdue label Aug 5, 2024
@DylanDylann
Copy link
Contributor

DylanDylann commented Aug 5, 2024

@ravindra-encoresky Thanks for your idea. Could you please provide a testing branch for your solution?

@melvin-bot melvin-bot bot removed the Overdue label Aug 5, 2024
Copy link

melvin-bot bot commented Aug 5, 2024

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

@ravindra-encoresky
Copy link
Contributor

@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

@DylanDylann
Copy link
Contributor

Screen.Recording.2024-08-06.at.17.55.44.mov

@ravindra-encoresky After going back to scanning page, an error happens

@DylanDylann
Copy link
Contributor

@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

Copy link

melvin-bot bot commented Aug 7, 2024

Triggered auto assignment to @roryabraham, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@ravindra-encoresky
Copy link
Contributor

hi @roryabraham proposal submitted on upwork.

@roryabraham
Copy link
Contributor

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?

@DylanDylann
Copy link
Contributor

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

@DylanDylann
Copy link
Contributor

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

@ravindra-encoresky
Copy link
Contributor

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.

zoontek/react-native-permissions#307
https://stackoverflow.com/questions/31706447/how-can-i-prevent-ios-apps-from-resetting-after-changing-camera-permissions

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 9, 2024
Copy link

melvin-bot bot commented Aug 9, 2024

📣 @DylanDylann 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented Aug 9, 2024

📣 @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
Copy link
Contributor

📣 @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.

@ravindra-encoresky
Copy link
Contributor

ravindra-encoresky commented Aug 27, 2024

hi @m-natarajan @sakluger since the PR is done, could you please complete the job on Upwork ?

thanks.

@DylanDylann
Copy link
Contributor

@sakluger The PR was deployed to production on August 31st. The payment should be issued on September 6th

@ravindra-encoresky
Copy link
Contributor

@DylanDylann @sakluger thanks, waiting for the job to be completed on upwork.

@sakluger sakluger added Daily KSv2 and removed Weekly KSv2 labels Sep 10, 2024
@sakluger sakluger changed the title [$250] Navigated back to the home screen after granting for Camera permission [HOLD for Payment 2024-09-06] [$250] Navigated back to the home screen after granting for Camera permission Sep 10, 2024
@sakluger sakluger added Awaiting Payment Auto-added when associated PR is deployed to production and removed Reviewing Has a PR in review labels Sep 10, 2024
@sakluger
Copy link
Contributor

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?

@sakluger
Copy link
Contributor

Summarizing payment on this issue:

Contributor: @ravindra-encoresky $250, paid via Upwork
Contributor+: @DylanDylann $250, paid via Upwork

@DylanDylann
Copy link
Contributor

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

  1. Start Submit Expense flow from Global Create
  2. Tap on the Scan tab
  3. Go to the Phone settings from the system prompt asking for Camera permission
  4. Go back to the App by tapping on <- NewExpensify on the top left corner of the iPhone
  5. Verify that App navigate to scan screen

Do we agree 👍 or 👎

@sakluger
Copy link
Contributor

Looks good. Thanks!

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 External Added to denote the issue can be worked on by a contributor
Projects
No open projects
Development

No branches or pull requests

5 participants