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

Background ANR at ScreenOffTrigger BroadcastReceiver [leakcanary on release] #2661

Open
FranAguilera opened this issue Apr 29, 2024 · 1 comment

Comments

@FranAguilera
Copy link

FranAguilera commented Apr 29, 2024

Description

[ANR] [Leakcanary-Release] ScreenOffTrigger BroadcastReceiver

Steps to Reproduce

Running leakcanary-release and have ScreenTrigger enabled

description: bg anr: Broadcast of Intent { act=android.intent.action.SCREEN_ON flg=0x50200010 cmp=x/leakcanary.ScreenOffTrigger$screenReceiver$1 (has extras) }

"main" sysTid=9748
    #00 pc 0000000000057880  /apex/com.android.runtime/lib64/bionic/libc.so (syscall+32) (BuildId: 544bc6c8e3556e98efbc4406b97f6a3e)
    #01 pc 0000000000232858  /apex/com.android.art/lib64/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+140) (BuildId: 02bec5940be704b863f6514fc7d81c41)
    #02 pc 0000000000460bc0  /apex/com.android.art/lib64/libart.so (artJniMethodEnd+336) (BuildId: 02bec5940be704b863f6514fc7d81c41)
    #03 pc 00000000005c0dfc  /apex/com.android.art/lib64/libart.so (art_jni_method_end+12) (BuildId: 02bec5940be704b863f6514fc7d81c41)
    #04 pc 000000000033f590  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (art_jni_trampoline+240)
    #05 pc 0000000000a2e680  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (android.os.MessageQueue.next+304)
    #06 pc 0000000000a2b180  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (android.os.Looper.loopOnce+96)
    #07 pc 0000000000a2b078  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (android.os.Looper.loop+1112)
    #08 pc 000000000078b100  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (android.app.ActivityThread.main+2432)
    #09 pc 000000000033ee80  /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+640) (BuildId: 02bec5940be704b863f6514fc7d81c41)
    #10 pc 000000000037ff40  /apex/com.android.art/lib64/libart.so (_jobject* art::InvokeMethod<(art::PointerSize)8>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jobject*, _jobject*, unsigned long)+1556) (BuildId: 02bec5940be704b863f6514fc7d81c41)
    #11 pc 000000000037f91c  /apex/com.android.art/lib64/libart.so (art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*) (.__uniq.165753521025965369065708152063621506277)+32) (BuildId: 02bec5940be704b863f6514fc7d81c41)
    #12 pc 00000000003456a8  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (art_jni_trampoline+120)
    #13 pc 0000000000d99aa4  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run+132)
    #14 pc 0000000000da5054  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (com.android.internal.os.ZygoteInit.main+3604)
    #15 pc 000000000033ee80  /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+640) (BuildId: 02bec5940be704b863f6514fc7d81c41)
    #16 pc 00000000004e3504  /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)+728) (BuildId: 02bec5940be704b863f6514fc7d81c41)
    #17 pc 000000000057c8fc  /apex/com.android.art/lib64/libart.so (art::JNI<true>::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+156) (BuildId: 02bec5940be704b863f6514fc7d81c41)
    #18 pc 00000000000e3be8  /system/lib64/libandroid_runtime.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+108) (BuildId: 8f11c1e5b9cd42e20eff39198f365b18)
    #19 pc 00000000000f05bc  /system/lib64/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&, bool)+856) (BuildId: 8f11c1e5b9cd42e20eff39198f365b18)
    #20 pc 0000000000002558  /system/bin/app_process64 (main+1280) (BuildId: 63c2631b63b6085792801dff29427263)
    #21 pc 0000000000053e8c  /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+108) (BuildId: 544bc6c8e3556e98efbc4406b97f6a3e)

Expected behavior:

BroadcastReceivers by default run on the main thread, calling the onReceive logic on background thread would fix these ANR instances

Version Information

  • LeakCanary version: 2.14
  • Android OS version: 14
@pyricau
Copy link
Member

pyricau commented May 1, 2024

We should let the broadcast receiver return before triggering the heap dump, otherwise that'll trigger an ANR as a heap dump freezes the VM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants