firebase-android-sdk: startActivityForSignInWithProvider crash on windows subsystem for android

Describe your environment

  • Android Studio version: giraffe
  • Firebase Component: Authentication
  • Component version: 22.1.1

Describe the problem

startActivityForSignInWithProvider crash on windows subsystem for android in standard android device all works fine

just launch startActivityForSignInWithProvider to open external browser (outside WSA) and receive this, without waiting user action

14:58:55.220  W  com.google.firebase.auth.FirebaseAuthWebException: The web operation was canceled by the user.
14:58:55.220  W  	at com.google.android.gms.internal.firebase-auth-api.zzaas.zza(com.google.firebase:firebase-auth@@22.1.1:11)
14:58:55.220  W  	at com.google.firebase.auth.internal.zzav.onReceive(com.google.firebase:firebase-auth@@22.1.1:24)
14:58:55.220  W  	at androidx.localbroadcastmanager.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:313)
14:58:55.220  W  	at androidx.localbroadcastmanager.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:121)
14:58:55.220  W  	at android.os.Handler.dispatchMessage(Handler.java:106)
14:58:55.220  W  	at android.os.Looper.loopOnce(Looper.java:201)
14:58:55.220  W  	at android.os.Looper.loop(Looper.java:288)
14:58:55.220  W  	at android.app.ActivityThread.main(ActivityThread.java:7918)
14:58:55.220  W  	at java.lang.reflect.Method.invoke(Native Method)
14:58:55.220  W  	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
14:58:55.220  W  	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
14:58:55.261  W  Expecting binder but got null!

Relevant Code:

Firebase.auth.startActivityForSignInWithProvider(this, OAuthProvider.newBuilder("microsoft.com").build())

also opened on WSA https://github.com/microsoft/WSA/issues/432

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Comments: 18 (7 by maintainers)

Most upvoted comments

I’m an engineer on the WSA team, and we’re happy to update our browser redirection logic if appropriate. For context, WSA doesn’t include a full Android browser since we redirect http/https intents to the Windows default browser instead (a desktop browser running natively is generally preferrable to a mobile browser running in a VM). However, authentication scenarios run into many compatibility issues redirecting between OSes, so WSA opens authentication URLs in a stub Android browser (a WebView) as an exception to the usual policy of redirecting to the Windows default browser. We rely on heuristics, such as URLs with a query parameter value that is also a URL (likely a redirect URL), to identify authentication URLs. The heuristics work well across a wide range of apps, but heuristics aren’t perfect.

Based on the symptoms described, it sounds like this authentication URL is being redirected to the Windows default browser instead of opening in WSA’s stub Android browser. The operation was “canceled” because the Android activity finishes after redirecting to Windows and authentication libraries typically expect the activity to remain alive until authentication is complete. This means the authentication URL wasn’t correctly classified by WSA’s heuristics. Can you please share the authentication URL passed to the browser in this scenario? If there’s a distinctive query parameter, we can update our heuristics to check for that.