Skip to content

Android: NullPointerException at Microsoft.Maui.Authentication.WebAuthenticatorIntermediateActivity.OnResume() #30414

Open
@WhoeverReadsThisIsStupid

Description

Description

For now only seen on an Android Emulator: I get crashes of my relatively complex App If I put it in the background and put it back in the foreground. This happens inconsitently so I assume it's some race condition or something.

When searched I found the following stackoverflow entry: https://stackoverflow.com/questions/38041230/intent-migrateextrastreamtoclipdata-on-a-null-object-reference
This is the closest to my issue I found and according to this it seems an easy fix.

For more information this is the output of my terminal for dotnet workload list:

SDK-Version: 9.0.301

Installierte Workload-ID Manifestversion Installationsquelle

android 35.0.78/9.0.100 VS 17.14.36221.1
ios 18.5.9199/9.0.100 VS 17.14.36221.1
maccatalyst 18.5.9199/9.0.100 VS 17.14.36221.1
maui-windows 9.0.51/9.0.100 VS 17.14.36221.1

Although my app is still build with target framework .Net8 not sure if this is relevant for this particular issue.

Steps to Reproduce

Since this problem happens inconsitently I am not sure what exactly is the reason for it.
But I have an app with multiple pages and also a WebView I am not sure tho if this is required and here is one way I go the crash:

  1. Open App.
  2. Navigate to a page with a WebView.
  3. Put the app in the background and open any other app. (Chrome in my case.)
  4. Go back to own app.
  5. See crash.

Link to public reproduction project repository

No response

Version with bug

.NET 8 (Out of support, please specify exact version)

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 14 and up, testet on multiple different emulators.

Did you find any workaround?

This issue is inconsitent but for now I could only reproduce it on an emulator not actual phones.

Relevant log output

+Java.Lang.NullPointerException: Attempt to invoke virtual method 'boolean android.content.Intent.migrateExtraStreamToClipData(android.content.Context)' on a null object reference Java.Lang.NullPointerException: Attempt to invoke virtual method 'boolean android.content.Intent.migrateExtraStreamToClipData(android.content.Context)' on a null object reference
   at Java.Interop.JniEnvironment.InstanceMethods.CallNonvirtualVoidMethod(JniObjectReference instance, JniObjectReference type, JniMethodInfo method, JniArgumentValue* args)
   at Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualVoidMethod(String encodedMember, IJavaPeerable self, JniArgumentValue* parameters)
   at Android.Content.ContextWrapper.StartActivity(Intent intent)
   at Microsoft.Maui.Authentication.WebAuthenticatorIntermediateActivity.OnResume()
   at Android.App.Activity.n_OnResume(IntPtr jnienv, IntPtr native__this)
   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V callback, IntPtr jnienv, IntPtr klazz)
  --- End of managed Java.Lang.NullPointerException stack trace ---
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.content.Intent.migrateExtraStreamToClipData(android.content.Context)' on a null object reference
\tat android.app.Instrumentation.execStartActivity(Instrumentation.java:1832)
\tat android.app.Activity.startActivityForResult(Activity.java:5471)
\tat android.app.Activity.startActivityForResult(Activity.java:5429)
\tat android.app.Activity.startActivity(Activity.java:5927)
\tat android.app.Activity.startActivity(Activity.java:5894)
\tat crc6468b6408a11370c2f.WebAuthenticatorIntermediateActivity.n_onResume(Native Method)
\tat crc6468b6408a11370c2f.WebAuthenticatorIntermediateActivity.onResume(WebAuthenticatorIntermediateActivity.java:41)
\tat android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1564)
\tat android.app.Activity.performResume(Activity.java:8437)
\tat android.app.ActivityThread.performResumeActivity(ActivityThread.java:4763)
\tat android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4806)
\tat android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:54)
\tat android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
\tat android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
\tat android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
\tat android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307)
\tat android.os.Handler.dispatchMessage(Handler.java:106)
\tat android.os.Looper.loopOnce(Looper.java:201)
\tat android.os.Looper.loop(Looper.java:288)
\tat android.app.ActivityThread.main(ActivityThread.java:7872)
\tat java.lang.reflect.Method.invoke(Native Method)
\tat com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

  --- End of managed Java.Lang.NullPointerException stack trace ---
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.content.Intent.migrateExtraStreamToClipData(android.content.Context)' on a null object reference
\tat android.app.Instrumentation.execStartActivity(Instrumentation.java:1832)
\tat android.app.Activity.startActivityForResult(Activity.java:5471)
\tat android.app.Activity.startActivityForResult(Activity.java:5429)
\tat android.app.Activity.startActivity(Activity.java:5927)
\tat android.app.Activity.startActivity(Activity.java:5894)
\tat crc6468b6408a11370c2f.WebAuthenticatorIntermediateActivity.n_onResume(Native Method)
\tat crc6468b6408a11370c2f.WebAuthenticatorIntermediateActivity.onResume(WebAuthenticatorIntermediateActivity.java:41)
\tat android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1564)
\tat android.app.Activity.performResume(Activity.java:8437)
\tat android.app.ActivityThread.performResumeActivity(ActivityThread.java:4763)
\tat android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4806)
\tat android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:54)
\tat android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
\tat android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
\tat android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
\tat android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307)
\tat android.os.Handler.dispatchMessage(Handler.java:106)
\tat android.os.Looper.loopOnce(Looper.java:201)
\tat android.os.Looper.loop(Looper.java:288)
\tat android.app.ActivityThread.main(ActivityThread.java:7872)
\tat java.lang.reflect.Method.invoke(Native Method)
\tat com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

Metadata

Metadata

Assignees

No one assigned

    Labels

    s/needs-attentionIssue has more information and needs another lookt/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions