Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application Not Responding (ANR) when collecting GC #9795

Open
qifu1177 opened this issue Feb 14, 2025 · 0 comments
Open

Application Not Responding (ANR) when collecting GC #9795

qifu1177 opened this issue Feb 14, 2025 · 0 comments
Assignees
Labels
Area: App Runtime Issues in `libmonodroid.so`.

Comments

@qifu1177
Copy link

qifu1177 commented Feb 14, 2025

Android framework version

net8.0-android

Affected platform version

  • VS 2022 17.12.5
  • Android version: 13
  • Device model: Galaxy Tab Active3

Expected Behavior:

_JNIEnv::CallVoidMethod(_jobject*, _jmethodID*, ...)
ANR triggered by slow operations in main thread

Description

An Application Not Responding (ANR) error on Android signifies that the application's main thread has been unresponsive for too long . The fact that the stack trace points to mono_gc_collect within libmonosgen-2.0.so strongly suggests the ANR is caused by a long-running garbage collection (GC) cycle within a Mono runtime environment.

Steps to Reproduce

  1. Run a Xamarin Android application .
  2. Run AppStartActivity(Sqlite is initialized in the actitvity)
protected override void OnResume()
{
    base.OnResume();

    var mvxApplication = Mvx.IoCProvider.Resolve<IMvxApplication>() as core.App;

    Task.Factory.StartNew(async () =>
    {
        await dbContext.Database.MigrateAsync().ConfigureAwait(false);

        RunOnUiThread(async () =>
        {
            await RunAppStartAsync(_bundle);//go to mainview
        });
    }, TaskCreationOptions.LongRunning);
}
  1. Run MainView (MainView is the main activity)

Relevant log output

0
libart.so
__aarch64_cas4_rel
1
libart.so
void art::mirror::Object::VisitReferences<true, (art::VerifyObjectFlags)0, (art::ReadBarrierOption)1, art::gc::collector::ConcurrentCopying::RefFieldsVisitor<false>, art::gc::collector::ConcurrentCopying::RefFieldsVisitor<false> >(art::gc::collector::ConcurrentCopying::RefFieldsVisitor<false> const&, art::gc::collector::ConcurrentCopying::RefFieldsVisitor<false> const&) + 952
2
libart.so
art::gc::collector::ConcurrentCopying::ProcessMarkStack() + 2156
3
libart.so
art::gc::collector::ConcurrentCopying::CopyingPhase() + 1836
4
libart.so
art::gc::collector::ConcurrentCopying::RunPhases() + 2608
5
libart.so
art::gc::collector::GarbageCollector::Run(art::gc::GcCause, bool) + 324
6
libart.so
art::gc::Heap::CollectGarbageInternal(art::gc::collector::GcType, art::gc::GcCause, bool, unsigned int) + 564
7
boot.oat
art_jni_trampoline + 112
8
boot.oat
java.lang.Runtime.gc + 168
9
libart.so
art_quick_invoke_stub + 612
10
libart.so
art::JValue art::InvokeVirtualOrInterfaceWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list) + 812
11
libart.so
art::JNI<false>::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list) + 192
12
libmonodroid.so
_JNIEnv::CallVoidMethod(_jobject*, _jmethodID*, ...) + 116
13
libmonodroid.so
xamarin::android::internal::OSBridge::gc_cross_references(int, MonoGCBridgeSCC**, int, MonoGCBridgeXRef*) + 224
14
libmonosgen-2.0.so
(Fehlt BuildId c7db5d00fcd3ecbca8fb4a5d7087a9c5b3c4f43f)
15
libmonosgen-2.0.so
(Fehlt BuildId c7db5d00fcd3ecbca8fb4a5d7087a9c5b3c4f43f)
16
libmonosgen-2.0.so
(Fehlt BuildId c7db5d00fcd3ecbca8fb4a5d7087a9c5b3c4f43f)
17
libmonosgen-2.0.so
(Fehlt BuildId c7db5d00fcd3ecbca8fb4a5d7087a9c5b3c4f43f)
18
libmonosgen-2.0.so
mono_gc_collect + 44
@qifu1177 qifu1177 added Area: App Runtime Issues in `libmonodroid.so`. needs-triage Issues that need to be assigned. labels Feb 14, 2025
@qifu1177 qifu1177 changed the title App ANR when collecting GC (_JNIEnv::CallVoidMethod(_jobject*, _jmethodID*, ...) ANR triggered by slow operations in main thread) App ANR when collecting GC Feb 14, 2025
@qifu1177 qifu1177 changed the title App ANR when collecting GC Application Not Responding (ANR) when collecting GC Feb 14, 2025
@jpobst jpobst removed the needs-triage Issues that need to be assigned. label Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: App Runtime Issues in `libmonodroid.so`.
Projects
None yet
Development

No branches or pull requests

3 participants