[firebase_auth]: Operation hangs/disappear if not directly returned from the sign in view
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
- Using the example: https://github.com/firebase/flutterfire/tree/main/packages/firebase_auth/firebase_auth/example
- Sign in with federated providers.
- When the web tab/page opens, return to the home screen directly without using the back button or any back gestures.
- Entering the recent tasks view
- If the auth is opening in a separate task, like in Chrome, enter Chrome, then press the back button.
- If the auth is opening as an in-app-webview, the task will disappear.
- 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.
Hi @AlexV525, thanks for the report. I'm able to reproduce this issue. We'll investigate further.
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.
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
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.
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.
Combining "taskAffinity" + "launchMode" and other activity state settings might be helpful as I imagine, which is what I'm exploring recently.