[firebase_auth]: A headful operation is already in progress. Please wait for that to finish.
Closed this issue ยท 12 comments
Description
This issue occurs in the Flutter version of Firebase Auth. According to SelaseKay's description, adjustments must be made in the Android SDK, so create a ticket here.
Reference: firebase/flutterfire#17659
If the user performs additional operations, such as navigating to other pages or closing the browser, the login function cannot be called again, is it possible to provide a function to terminate the previous login operation?
Environment
Android Studio version: Android Studio Narwhal Feature Drop | 2025.1.2 Patch 1
Flutter Firebase Core: 4.0.0
Flutter: 3.32.8
Steps to reproduce
- Click the Google Login button.
- Use Android overview to close Chrome App.
- Return to my App.
- Click the Google Login button again.
Expected results
Cancels the already running operation and creates a new one.
Actual results
Get exception: A headful operation is already in progress. Please wait for that to finish.
Screenshots or Video
2025-08-25.10.34.31.mov
Code sample
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
class SampleScreen extends StatelessWidget {
const SampleScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ElevatedButton(
child: const Text("Google Login"),
onPressed: () async {
final googleProvider = GoogleAuthProvider();
await FirebaseAuth.instance
.signInWithProvider(googleProvider)
.then((value) {
debugPrint("test Google Login value: $value");
debugPrint("test Google Login profile: ${value.additionalUserInfo?.profile}");
debugPrint("test Google Login accessToken: ${value.credential?.accessToken}");
})
.onError((error, stack) {
debugPrint("test Google Login error $error");
ScaffoldMessenger.of(context).removeCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(error.toString())));
});
},
),
),
);
}
}
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Hi @a1573595, thank you for reaching out. I tried reproducing the behavior using our Android quickstart app for Auth, however, I did not encounter the same issue. The app doesn't spawn separate a browser for login.
That said, it's not a native Firebase Android SDK issue. It's possible that this is an implementation/ configuration issue. I would suggest try raising it back to the Flutterfire team for further investigation.
I'll be closing this issue for now. Let me know is there's any concern or misunderstanding so we can re-open this issue. Thanks!
Hi @a1573595, thank you for reaching out. I tried reproducing the behavior using our Android quickstart app for Auth, however, I did not encounter the same issue. The app doesn't spawn separate a browser for login.
That said, it's not a native Firebase Android SDK issue. It's possible that this is an implementation/ configuration issue. I would suggest try raising it back to the Flutterfire team for further investigation.
I'll be closing this issue for now. Let me know is there's any concern or misunderstanding so we can re-open this issue. Thanks!
Hello, I tried the Android quickstart app for Auth. Its example uses Google Play Services, not a standalone browser. The scenarios are different. For example, the video demonstrates that after disabling Google Services, you can still call the browser for authentication, without relying on Google Play Services.
2025-08-29.6.59.43.-.Compressed.with.FlexClip.mp4
@lehcar09 In addition, SelaseKay, a staff member of Flutterfire, has also confirmed this issue. Can you communicate internally instead of going through me, an external user?
Reference: firebase/flutterfire#17659

I am running into the same issue but with Capacitor app.
I also tested the proposed solution without much luck. It does not throw the same error. But kind of just moves away, then back to the app, and then the app crashes (in singleTop mode).
Fixed by changing
android:launchMode="singleInstance"toandroid:launchMode="singleTop"
Originally posted by @stx in #16938
So far I was not able to find a proper solution.
I am running into the same issue but with Capacitor app.
I also tested the proposed solution without much luck. It does not throw the same error. But kind of just moves away, then back to the app, and then the app crashes (in singleTop mode).
Fixed by changing
android:launchMode="singleInstance"toandroid:launchMode="singleTop"Originally posted by @stx in #16938
So far I was not able to find a proper solution.
I have tested it at firebase/flutterfire#17659 and it doesn't work. The launchMode is set for the app itself, but this scenario is to open an additional browser.

Hi @a1573595, please note, we don't have direct communication to the FlutterFire team.
Firebase Auth use CustomTab to handle sign in.
if (isChromeCustomTabsAvailable()) {
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().build();
Log.i(TAG, "Opening IDP Sign In link in a custom chrome tab.");
customTabsIntent.launchUrl(this, uriTask.getResult());
} else {
Intent intent = new Intent(ACTION_VIEW, uriTask.getResult());
intent.putExtra(Browser.EXTRA_APPLICATION_ID, consumerPackageName);
Log.i(TAG, "Opening IDP Sign In link in a browser window.");
// Set the flags below so the browser activity closes after sign in is complete.
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
}
I manually/ force disabled the CustomTab to launch a browser for sign in, but, I still wasn't able to encounter the behavior you raised.
<queries>
<intent>
<action android:name=
"android.support.customtabs.action.CustomTabsService" />
</intent>
</queries>
When I close the browser and return to the app, I was able to open another sign in tab.
https://github.com/user-attachments/assets/4cf6189d-7858-4f7d-a58a-28f84942b5f0.
I'm not familiar with Flutter/ Dart, by any chance, have you tried using the sample code from this documentation?
Future<UserCredential> signInWithGoogle() async {
// Trigger the authentication flow
final GoogleSignInAccount? googleUser = await GoogleSignIn.instance.authenticate();
// Obtain the auth details from the request
final GoogleSignInAuthentication googleAuth = googleUser.authentication;
// Create a new credential
final credential = GoogleAuthProvider.credential(idToken: googleAuth.idToken);
// Once signed in, return the UserCredential
return await FirebaseAuth.instance.signInWithCredential(credential);
}
Hi @a1573595, please note, we don't have direct communication to the FlutterFire team.
Firebase Auth use CustomTab to handle sign in.
if (isChromeCustomTabsAvailable()) { CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().build(); Log.i(TAG, "Opening IDP Sign In link in a custom chrome tab."); customTabsIntent.launchUrl(this, uriTask.getResult()); } else { Intent intent = new Intent(ACTION_VIEW, uriTask.getResult()); intent.putExtra(Browser.EXTRA_APPLICATION_ID, consumerPackageName); Log.i(TAG, "Opening IDP Sign In link in a browser window."); // Set the flags below so the browser activity closes after sign in is complete. intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); this.startActivity(intent); }I manually/ force disabled the CustomTab to launch a browser for sign in, but, I still wasn't able to encounter the behavior you raised.
<queries> <intent> <action android:name= "android.support.customtabs.action.CustomTabsService" /> </intent> </queries>When I close the browser and return to the app, I was able to open another sign in tab.
https://github.com/user-attachments/assets/4cf6189d-7858-4f7d-a58a-28f84942b5f0.
I'm not familiar with Flutter/ Dart, by any chance, have you tried using the sample code from this documentation?
Future<UserCredential> signInWithGoogle() async { // Trigger the authentication flow final GoogleSignInAccount? googleUser = await GoogleSignIn.instance.authenticate(); // Obtain the auth details from the request final GoogleSignInAuthentication googleAuth = googleUser.authentication; // Create a new credential final credential = GoogleAuthProvider.credential(idToken: googleAuth.idToken); // Once signed in, return the UserCredential return await FirebaseAuth.instance.signInWithCredential(credential); }
Thank you very much for your reply.
I'm using signInWithProvider for login. Due to Google service restrictions, GoogleSignIn doesn't work with external browsers. I tested Twitter and encountered the same issue, as the example in the documentation is identical. I believe the problem stems from FlutterFire, perhaps missing a bug in its processing that causes the program to freeze.
import 'package:firebase_auth/firebase_auth.dart';
Future<void> _signInWithTwitter() async {
TwitterAuthProvider twitterProvider = TwitterAuthProvider();
if (kIsWeb) {
await FirebaseAuth.instance.signInWithPopup(twitterProvider);
} else {
await FirebaseAuth.instance.signInWithProvider(twitterProvider);
}
}
@chrisspiegl I've created a new ticket on flutterfire that you can track if you need it.
Hi @a1573595, I only see your report on the flutterfire repo? Is there another (upstream) ticket somewhere?
Hi @a1573595, I only see your report on the flutterfire repo? Is there another (upstream) ticket somewhere?
My oversight, the Flutter version of Firebase GitHub is centralized at flutterfire.
I have now created an issue on the Capacitor Firebase repository. Since it's happening there too (and a fix in Flutter isn't going to help there).
capawesome-team/capacitor-firebase#912
The android:taskAffinity had no effect on my project (since it is not defined at all).