maui icon indicating copy to clipboard operation
maui copied to clipboard

Crash on Android when hold app over 2 minutes in background

Open ThinhKVT opened this issue 1 year ago • 8 comments

Description

Hi all,

Could you help to suggestion any solution for the crash issue on Android only ? We detected this after hold app over 2 minutes in background. Then re-open the app, it was crashed.

This is log: android.runtime.JavaProxyThrowable: [System.NullReferenceException]: Object reference not set to an instance of an object. 05-07 17:25:16.035 22354 22354 E AndroidRuntime: at SPMobile.MAUI.App+<<Initialize>b__2_0>d.MoveNext(Unknown Source:0) 05-07 17:25:16.035 22354 22354 E AndroidRuntime: at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Unknown Source:0) 05-07 17:25:16.035 22354 22354 E AndroidRuntime: at System.Threading.Tasks.Task+<>c.<ThrowAsync>b__128_0(Unknown Source:0) 05-07 17:25:16.035 22354 22354 E AndroidRuntime: at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0(Unknown Source:0) 05-07 17:25:16.035 22354 22354 E AndroidRuntime: at Java.Lang.Thread+RunnableImplementor.Run(Unknown Source:0) 05-07 17:25:16.035 22354 22354 E AndroidRuntime: at Java.Lang.IRunnableInvoker.n_Run(Unknown Source:0) 05-07 17:25:16.035 22354 22354 E AndroidRuntime: at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(Unknown Source:0) 05-07 17:25:16.035 22354 22354 E AndroidRuntime: at mono.java.lang.RunnableImplementor.n_run(Native Method) 05-07 17:25:16.035 22354 22354 E AndroidRuntime: at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:31) 05-07 17:25:16.035 22354 22354 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:942) 05-07 17:25:16.035 22354 22354 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99) 05-07 17:25:16.035 22354 22354 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:226) 05-07 17:25:16.035 22354 22354 E AndroidRuntime: at android.os.Looper.loop(Looper.java:313) 05-07 17:25:16.035 22354 22354 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8757) 05-07 17:25:16.035 22354 22354 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 05-07 17:25:16.035 22354 22354 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) 05-07 17:25:16.035 22354 22354 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.6 SR1

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

7.0.101

Affected platforms

Android

Affected platform versions

Android 13

Did you find any workaround?

Not yet.

Relevant log output

Attached on Description.

ThinhKVT avatar May 08 '24 07:05 ThinhKVT

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

github-actions[bot] avatar May 08 '24 07:05 github-actions[bot]

Verified this issue with Visual Studio 17.10 Preview 6.0 (8.0.21), I can repro this error using a physical Android device (Samsung Android 13.0), but on the Android emulator it works fine.

jaosnz-rep avatar May 08 '24 09:05 jaosnz-rep

Can you attach a logcat file with your crash? https://learn.microsoft.com/en-us/xamarin/android/deploy-test/debugging/android-debug-log?tabs=windows

PureWeen avatar May 08 '24 18:05 PureWeen

@jaosnz-rep can you attach your repro please?

PureWeen avatar May 08 '24 18:05 PureWeen

@jaosnz-rep can you attach your repro please?

I attached the Log and Output as follows DeviceCrashLog.txt DebugOutput.txt

I created a default .NET MAUI project to reproduce this error. The size is 96M and cannot be attached here. I can upload it to OneDrive if you need it.

jaosnz-rep avatar May 09 '24 02:05 jaosnz-rep

@jaosnz-rep You don't need to upload the bin/obj folders, you just need to upload the source code, preferably to a GitHub repo, as described in the note when making the issue.

drasticactions avatar May 10 '24 05:05 drasticactions

Also, if you could try doing what you're doing in a .NET Android app that doesn't implement that MAUI UI framework (You can create one using the CLI command dotnet new android) and try your code there, that would be great. My guess based on your description is that what you're doing would break any Android app, not just ones using the MAUI UI framework controls.

drasticactions avatar May 10 '24 05:05 drasticactions

Also, if you could try doing what you're doing in a .NET Android app that doesn't implement that MAUI UI framework (You can create one using the CLI command dotnet new android) and try your code there, that would be great. My guess based on your description is that what you're doing would break any Android app, not just ones using the MAUI UI framework controls.

I tried it on .NET Android project and it also reproduces on physical Android device. Below is my repo: https://github.com/jaosnz-rep/MauiApp72

jaosnz-rep avatar May 11 '24 09:05 jaosnz-rep

@jonathanpeppers thoughts?

Should we move this over to android?

PureWeen avatar May 31 '24 15:05 PureWeen

@ThinhKVT this looks like a NullReferenceException in your code:

[System.NullReferenceException]: Object reference not set to an instance of an object.
05-07 17:25:16.035 22354 22354 E AndroidRuntime: at SPMobile.MAUI.App+<b__2_0>d.MoveNext(Unknown Source:0)

What is your code inside SPMobile.MAUI.App? It probably has an await or yield return inside.

If you can share the .dll of your project, we could inspect with a tool like ILSpy to see what exactly the C# compiler emitted for <b__2_0>.

jonathanpeppers avatar Jun 04 '24 14:06 jonathanpeppers

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.