question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[regression/8.0] Android app crashes with an ANR on .NET 8 preview 6

See original GitHub issue

Description

We are experiencing an issue with a cross-platform app we are developing that is being killed by Android due to an Application Not Responding (ANR). So far we haven’t been able to pinpoint what is causing this, but we figured we’d report this anyway since it appears not to happen with .NET 7, only with .NET 8. That being said, we do have a workaround which is removing the <GoogleServicesJson> element from the project file, but that then means we are unable to receive push notifications in our app which we obviously do actually need.

So it seems that there is some combination of factors that are contributing to this issue but we don’t think it is something that is actually happening in our code. We can however consistently reproduce the issue. What is further complicating things is that it only seems to happen when the app is running on a device and has been compiled in Release mode.

We do have an ANR report from a device but it is too big to post here. What would be the best way to provide this information?

Steps to Reproduce

  1. Create a .NET MAUI Android app targeting .NET 8
  2. Add push notification support to the app through Firebase
  3. See the app crash with an ANR
  4. Notice that this does not happen when targeting .NET 7

Please note that our provided repro doesn’t actually crash with an ANR, that only happens in our actual app, but we can’t figure out what the difference is. Our working assumption is that in our actual app some process that is running in the background is taking up a lot of time and that causes the app to crash.

Link to public reproduction project repository

https://github.com/tristanhollman/MauiApp_FirebaseMessagingNet8

Version with bug

8.0.0-preview.5.8529

Last version that worked well

7.0.86

Affected platforms

Android

Affected platform versions

At least Android 13, might occur on older versions as well but haven’t tested

Did you find any workaround?

A workaround is to remove the <GoogleServiceJson> element from the project file, but then push notifications no longer work.

Relevant log output

We do have an ANR report from a device, but it is too big to place here. Please let us know how we can provide this information.

Issue Analytics

  • State:open
  • Created 2 months ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jmezachcommented, Aug 1, 2023

We’ve done some more investigation into this issue by using the profiling instructions provided here. Unfortunately it seems that this is making matters worse, because the app is now killed by the OS even sooner resulting in a broken trace. We’ve tried this with almost every .NET 8 preview (except for preview 1 since the app immediately crashes at startup with that version) and what we’re seeing in the output of dotnet-trace is that the trace is being collected up to about 1,5 MB and then it stops. A few minutes later the app is killed by the OS and dotnet-trace reports Detected a potentially broken trace. Continuing with best-efforts to convert the trace, but resulting speedscope file may contain broken stacks as a result..

If we do the same with .NET 7 we see that the trace keeps on collecting up to 4 MB after which I pressed Enter, but the app just keeps working and is not being killed by the OS at all. So it seems there is definitely an issue with .NET 8.

0reactions
jonathanpepperscommented, Aug 21, 2023

Here are some more detailed instructions for debug.mono.trace: https://github.com/dotnet/maui/issues/15829#issuecomment-1687065105

Read more comments on GitHub >

github_iconTop Results From Across the Web

Announcing .NET 8 Preview 6
The app would fail when executed but now it works. No source code changes are needed to use the generator. It's enabled by...
Read more >
RuntimeException causes ANR instead of crash in android
The app seems to be blocked for some seconds but finally exception is thrown and reported without ANR. Share.
Read more >
View crashes and application not responding (ANR) errors
Open Play Console. Select an app. On the left menu, select Quality > Android vitals > Crashes and ANRs. Near the center of...
Read more >
.NET MAUI android application crashes immediately after ...
But when i share the APK/Signed APK file and install through that it starts and crashes immediately after the SplashScreen.
Read more >
What's On Tap for .NET 8 (Preview 1 Coming this Month)
NET MAUI had only five), ranging from "Blazorwasm : deployment with aot compilation and with out aot compilation" to "Blazor WebAssembly crashes ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found