flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

[firebase_auth]: Operation hangs/disappear if not directly returned from the sign in view

Open AlexV525 opened this issue 7 months ago • 4 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues.

Which plugins are affected?

Auth

Which platforms are affected?

Android

Description

When leaving the sign-in flow without completing it or dismissing it, the operation will never end or disappear, and unable to cancel.

Reproducing the issue

  1. Using the example: https://github.com/firebase/flutterfire/tree/main/packages/firebase_auth/firebase_auth/example
  2. Sign in with federated providers.
  3. When the web tab/page opens, return to the home screen directly without using the back button or any back gestures.
  4. Entering the recent tasks view
    1. If the auth is opening in a separate task, like in Chrome, enter Chrome, then press the back button.
    2. If the auth is opening as an in-app-webview, the task will disappear.
  5. Returning to the app, the auth call hangs, and no way to cancel the previous.

Firebase Core version

3.13.1

Flutter Version

3.32.0

Relevant Log Output

N/A

Flutter dependencies

dependencies:
- firebase_auth 5.5.4
- firebase_core 3.13.1

transitive dependencies:
- firebase_auth_platform_interface 7.6.3
- firebase_auth_web 5.14.3
- firebase_core_platform_interface 5.4.0
- firebase_core_web 2.23.0

Additional context and comments

The screen record for the example:

https://github.com/user-attachments/assets/b8255656-fb66-4134-985b-714eded0bcdf

The screen record for our production app:

https://github.com/user-attachments/assets/dcf6b46d-ca37-46b0-8fbd-5a65793c23c6

Also, I was wondering why the example has a different behavior when opening the auth page: the example launches the Chrome web page, while our app launches an in-app-browser view.

AlexV525 avatar May 29 '25 02:05 AlexV525

Hi @AlexV525, thanks for the report. I'm able to reproduce this issue. We'll investigate further.

SelaseKay avatar May 30 '25 09:05 SelaseKay

Can confirm I was also able to reproduce, it seems that it is still awaiting details being put in and submitted which is likely why it is hanging but it should not break the app like this.

MichaelVerdon avatar May 30 '25 15:05 MichaelVerdon

From what I understand, I do not think the underlying native SDKs expose a method to terminate web flows once you start awaiting them. I think this is something worth reporting here. As a workaround I can suggest resetting the UI once app is backgrounded/inactive when you change screens by monitoring application lifecycle. https://api.flutter.dev/flutter/widgets/AppLifecycleListener-class.html

MichaelVerdon avatar Jun 05 '25 06:06 MichaelVerdon

Reseting the interface is easy, but then you are still unable to launch another auth process as it will tells you there is an ongoing one, you'll never get back to it until the app was killed and reopened.

AlexV525 avatar Jun 05 '25 07:06 AlexV525

Reseting the interface is easy, but then you are still unable to launch another auth process as it will tells you there is an ongoing one, you'll never get back to it until the app was killed and reopened.

For something like this, it would need to be a supported feature of the native sdks before we can support it here and I was unable to find something like this and I think having a safe way to terminate the flow midway through would be nice to have as opposed to having to terminate the app.

MichaelVerdon avatar Jun 27 '25 14:06 MichaelVerdon

Combining "taskAffinity" + "launchMode" and other activity state settings might be helpful as I imagine, which is what I'm exploring recently.

AlexV525 avatar Jun 27 '25 15:06 AlexV525