WebAuthenticator crash with some browsers
See original GitHub issueDescription
Recently I released a new app with .NET MAUI (you can see here) and it behaves very different from device to device. With some browsers (for example Mi browser) app crashes when user is redirected back to the app with WebAuthenticator.
Here is the exception:
Exception android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
at Microsoft.Maui.Authentication.WebAuthenticatorIntermediateActivity.OnCreate(Bundle )
at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_(IntPtr , IntPtr , IntPtr )
at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V(_JniMarshal_PPL_V , IntPtr , IntPtr , IntPtr )
at crc6468b6408a11370c2f.WebAuthenticatorIntermediateActivity.n_onCreate
at crc6468b6408a11370c2f.WebAuthenticatorIntermediateActivity.onCreate (WebAuthenticatorIntermediateActivity.java:33)
at android.app.Activity.performCreate (Activity.java:8142)
at android.app.Activity.performCreate (Activity.java:8114)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3549)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3748)
at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2187)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:236)
at android.app.ActivityThread.main (ActivityThread.java:8057)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:620)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1011)
I was trying to turn off shrinks, aot and everything else, nothing helps.
Installed Workload Id Manifest Version Installation Source
--------------------------------------------------------------------------------
maui-android 7.0.59/7.0.100 SDK 7.0.100, VS 17.4.33213.308
maui-ios 7.0.59/7.0.100 SDK 7.0.100, VS 17.4.33213.308
maui-maccatalyst 7.0.59/7.0.100 SDK 7.0.100, VS 17.4.33213.308
maui-tizen 7.0.59/7.0.100 SDK 7.0.100
maui-windows 7.0.59/7.0.100 VS 17.4.33213.308
maccatalyst 16.2.1024/7.0.100 VS 17.4.33213.308
ios 16.2.1024/7.0.100 VS 17.4.33213.308
android 33.0.26/7.0.100 VS 17.4.33213.308
Steps to Reproduce
Select Mi browser as your default browser and try to sign in with Google
Link to public reproduction project repository
I can’t share my project
Version with bug
7.0 (current)
Last version that worked well
Affected platforms
Android
Affected platform versions
Android 11 (SDK 30), Android 10 (SDK 29)
Did you find any workaround?
No
Relevant log output
No response
Issue Analytics
- State:
- Created 7 months ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
WebAuthenticationBroker.AuthenticateAsync freeze in ...
Most of them occur in asynchronous method processing and UI rendering. If your app first freezes, and then crashes after some time, then...
Read more >Xamarin Android WebAuthenticator bug
Im having a problem using WebAuthenticator on Xamarin. ... I tryed removing the activity from the manifest, and now the browser wont open....
Read more >Add Authentication to .NET MAUI Apps with Auth0
After it returns browser result, browser gets opened with error and post closing the browser popup, app displays blank in black like crashed....
Read more >WebAuthn Passwordless Login
Only some uncommon browsers still lack support for WebAuthn. Authentication[edit]. To login you must enter your username in the login form ...
Read more >Sign users out
Sign users out of Okta by clearing the Okta browser session. ... An optional step is to revoke the tokens so they can't...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mattleibow Are you going to backport this to .net7?
1) MainAct is my referrence of MainActivity as a static field:
With this reference you can return to your actual activity with ease after sign in flow 😃
2) On resume activity I invoke an event to check on my sign in page if sign in string has appeared on preferences:
If string exists I parse it and continue sign in flow.
I’d repeat that this is working solution but I made it urgently to fix app crashes after intial release of my app. So if you have a bit more time to realize how intents and activities work then you probably can make and share with us a better workaround. For now I prefer msft team to fix WebAuthenticator to get it work as its best because I have not enough understanding how it works on Android, and where I can go wrong there. I already see too much crashes (I don’t want to make things even worse) on my Google Play Console and have no idea why, where and how I can fix them, seems like it’s some MAUI issues that going to be fixed in a future with upcoming releases of MAUI ❤️