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

App crashes on re-launch #3356

Closed
2 of 14 tasks
PritamDutt opened this issue Jul 5, 2023 · 12 comments
Closed
2 of 14 tasks

App crashes on re-launch #3356

PritamDutt opened this issue Jul 5, 2023 · 12 comments
Assignees
Labels
auth Issues related to the Auth Category Investigating Issues that are assigned and are being looked into

Comments

@PritamDutt
Copy link

PritamDutt commented Jul 5, 2023

Description

Concurrency/CheckedContinuation.swift:164: Fatal error: SWIFT TASK CONTINUATION MISUSE: launchUrl(:callbackURLScheme:preferPrivateSession:) tried to resume its continuation more than once, returning ["nonce": "XXXX", "code": "XXX", "state": "XXX"]!

Concurrency/CheckedContinuation.swift:164: Fatal error: SWIFT TASK CONTINUATION MISUSE: launchUrl(:callbackURLScheme:preferPrivateSession:) tried to resume its continuation more than once, returning ["nonce": "XXXX", "code": "XXX", "state": "XXX"]!

  • thread Initial Commit #1, queue = 'com.apple.main-thread', stop reason = Fatal error: SWIFT TASK CONTINUATION MISUSE: launchUrl(_:callbackURLScheme:preferPrivateSession:) tried to resume its continuation more than once, returning ["nonce": "XXXX", "code": "XXX", "state": "XXX"]!

Categories

  • Analytics
  • API (REST)
  • API (GraphQL)
  • Auth
  • Authenticator
  • DataStore
  • Notifications (Push)
  • Storage

Steps to Reproduce

No response

Screenshots

No response

Platforms

  • iOS
  • Android
  • Web
  • macOS
  • Windows
  • Linux

Flutter Version

3.10.2

Amplify Flutter Version

1.1.1

Deployment Method

Amplify CLI

Schema

No response

@fjnoyp
Copy link
Contributor

fjnoyp commented Jul 5, 2023

Hi @PritamDutt can you please provide more details on your app and what you did to help us reproduce.

We haven't been encountering this issue so need more information to see what's going on.

  1. What Amplify Categories are you using?
  2. How do you trigger the crash? Are you backgrounding the app, or are you closing and reopening the app?
  3. Please confirm device used to replicate.
  4. Please summarize what you are doing in your app that triggers the crash.
  5. Please provide amplifyconfiguration.dart file with sensitive keys removed.

@fjnoyp fjnoyp self-assigned this Jul 5, 2023
@fjnoyp fjnoyp added pending-response Issue is pending response from the issue requestor pending-triage This issue is in the backlog of issues to triage labels Jul 5, 2023
@PritamDutt
Copy link
Author

Hi @fjnoyp,

Here is what I could to reproduce the error:

  1. Ensure we are using HostedUI based authentication, and app is configured using amplify to use it.
  2. Create an app client with 5 min ID and Access Token expiration, and 60 min for Refresh Token expiration

60 min time window is required to be able to reproduce the bug faster
If you want to reproduce it much faster, enable Opt-In remember device option in UserPool (I know it is not supported by Amplify-Flutter yet but it will give us faster token expiry simulation)

  1. Let the token expire, and re-lauch app, which should take you to HostedUI Authentication Portal, and as you sign-in again, and it comes back to app.. but app crashes.

When I debugged the app, I discovered that, code inside ASWebAuthenticationSession in HostedUIFlow.swift is executing multiple times

let session = ASWebAuthenticationSession(url: uri, callbackURLScheme: callbackURLScheme) {

raising error on following line:

continuation.resume(returning: queryParameters)

I have been successfully able to resolve this by modifying the code to:

  • Add a new var consumedCallbackURL:URL!;
  • Add check to ensure continuation is called only once:
if (consumedCallbackURL != callbackURL){
    consumedCallbackURL = callbackURL
    continuation.resume(returning: queryParameters)
}

I hope this will help!

@Jordan-Nelson
Copy link
Contributor

@PritamDutt - Prior to step 3, are you placing the app into the background or are force closing the app? I want to make sure we understand the repro steps.

@Jordan-Nelson
Copy link
Contributor

@PritamDutt - can you also please confirm that you are using version 1.1.1 by checking that this is the version on your pubspec.lock file? A similar issue was fixed in 1.1.1. I want to make sure you are not using an earlier version. Thanks.

@Jordan-Nelson Jordan-Nelson added auth Issues related to the Auth Category Investigating Issues that are assigned and are being looked into and removed pending-triage This issue is in the backlog of issues to triage labels Jul 6, 2023
@fjnoyp
Copy link
Contributor

fjnoyp commented Jul 7, 2023

To add to the above comments, I believe your error here is related to your other issue. It appears your refreshToken is not working correctly, which might mean that Amplify Auth is expecting you to still be signed in when you aren't.

I am unable to replicate any crash on my side.

@PritamDutt
Copy link
Author

similar issue

@Jordan-Nelson I can confirm that this issue is existing with following versions:

  amplify_analytics_pinpoint:
    dependency: transitive
    description:
      name: amplify_analytics_pinpoint
      sha256: "3566be5087890881129b99d53e71cfdd2ef198bb5f78658d24e50786afc1c5a8"
      url: "https://pub.dev"
    source: hosted
    version: "1.2.0"
  amplify_analytics_pinpoint_dart:
    dependency: transitive
    description:
      name: amplify_analytics_pinpoint_dart
      sha256: d231186250f9936b8ba8b4370a7a46219ed4202ab660b07b8982ad00a0f0dee0
      url: "https://pub.dev"
    source: hosted
    version: "0.3.0+1"
  amplify_api:
    dependency: "direct main"
    description:
      name: amplify_api
      sha256: "39b7a94d53cbfb51e630838079dd08582c7f1ff483248b20d2124177b35fd34b"
      url: "https://pub.dev"
    source: hosted
    version: "1.2.0"
  amplify_api_dart:
    dependency: transitive
    description:
      name: amplify_api_dart
      sha256: "0cb295fa2805215b0e63cdc8d112bfb7638e4264dd5a1a4e857cdb36c9464846"
      url: "https://pub.dev"
    source: hosted
    version: "0.3.0+1"
  amplify_auth_cognito:
    dependency: "direct main"
    description:
      name: amplify_auth_cognito
      sha256: a5590ec67b70974a64d43d231457fe35178ae4076fbb23e9dd39d93a4636f22b
      url: "https://pub.dev"
    source: hosted
    version: "1.2.0"
  amplify_auth_cognito_dart:
    dependency: transitive
    description:
      name: amplify_auth_cognito_dart
      sha256: ebf6b681716c53dda8208a22f9f0d0756a4e4367450b7284a4a4d1c1ae5c726e
      url: "https://pub.dev"
    source: hosted
    version: "0.10.1"
  amplify_authenticator:
    dependency: "direct main"
    description:
      name: amplify_authenticator
      sha256: "98c718157a745be20de16e806fd1d2c0051bdb0ba8418a531be11f97e7225577"
      url: "https://pub.dev"
    source: hosted
    version: "1.2.1"
  amplify_core:
    dependency: transitive
    description:
      name: amplify_core
      sha256: dd620befd0a966e576a0212e03e4f11ac428b4c5b7ba936210ee5307bc009d6a
      url: "https://pub.dev"
    source: hosted
    version: "1.2.0"
  amplify_db_common:
    dependency: transitive
    description:
      name: amplify_db_common
      sha256: "696a379e5afcbc1479893a7051b08bb6746df25907554daa362d6ae811ac3831"
      url: "https://pub.dev"
    source: hosted
    version: "0.3.0+1"
  amplify_db_common_dart:
    dependency: transitive
    description:
      name: amplify_db_common_dart
      sha256: ae16475ebba2c2491ed3c0ea718253ee1b7ce906be73b1f31601006cb219b21f
      url: "https://pub.dev"
    source: hosted
    version: "0.3.0+1"
  amplify_flutter:
    dependency: "direct main"
    description:
      name: amplify_flutter
      sha256: "617460f82293525fe1df8c3cb7839c06a90224f7e574755a5965252af2e72d0f"
      url: "https://pub.dev"
    source: hosted
    version: "1.2.0"
  amplify_secure_storage:
    dependency: transitive
    description:
      name: amplify_secure_storage
      sha256: "7ad6524d74e823a1569b96f442de0c6f32d4add37fa6248fc241dd76df412838"
      url: "https://pub.dev"
    source: hosted
    version: "0.4.0+1"
  amplify_secure_storage_dart:
    dependency: transitive
    description:
      name: amplify_secure_storage_dart
      sha256: "66df9e1e52aef0c6e81cdb108559969755daaade52e2811735ffcea257a2d80d"
      url: "https://pub.dev"
    source: hosted
    version: "0.4.0+2"

@PritamDutt
Copy link
Author

To add to the above comments, I believe your error here is related to your other issue. It appears your refreshToken is not working correctly, which might mean that Amplify Auth is expecting you to still be signed in when you aren't.

I am unable to replicate any crash on my side.

@PritamDutt - Prior to step 3, are you placing the app into the background or are force closing the app? I want to make sure we understand the repro steps.

It happens irrespective of app going into background or getting closed.. and I can confirm that my change in HostedUIFlow.swift has resolved this, and the app has stopped crashing

@fjnoyp
Copy link
Contributor

fjnoyp commented Jul 7, 2023

Thanks for the extra information @PritamDutt always helpful as usual. Good to hear you were able to fix this issue on your side.

This issue seems related to your other issue. Let's focus our conversation there for now as a fix there should hopefully resolve this one too.

#3355

@PritamDutt
Copy link
Author

@fjnoyp This issue is related to hosted ui flow, whereas the suggested TOTP work is being done in the native sign-in flow, which I suspect would solve the problem

@Jordan-Nelson Jordan-Nelson assigned dnys1 and unassigned fjnoyp Jul 20, 2023
@Jordan-Nelson Jordan-Nelson removed the pending-response Issue is pending response from the issue requestor label Jul 20, 2023
@dnys1
Copy link
Contributor

dnys1 commented Jul 20, 2023

Please confirm you have followed all steps in the iOS setup instructions here.

In particular, it's important that you set the minimum SDK version to iOS 13.0 in the Xcode project itself in the two locations.

@dnys1
Copy link
Contributor

dnys1 commented Jul 31, 2023

Please let us know if you are still facing this issue, @PritamDutt. I will be closing this out if I don't hear back from you.

@dnys1
Copy link
Contributor

dnys1 commented Aug 7, 2023

Closing as we have not heard from you. Please feel free to reopen if you are still facing this issue.

@dnys1 dnys1 closed this as completed Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Issues related to the Auth Category Investigating Issues that are assigned and are being looked into
Projects
None yet
Development

No branches or pull requests

4 participants