Search Unity

Question ANR in crashlytics console: android.os.MessageQueue.nativePollOnce

Discussion in 'Android' started by PedroDuran, Jun 27, 2022.

  1. PedroDuran

    PedroDuran

    Joined:
    Aug 19, 2014
    Posts:
    32
    Hello, i've been having some headcache with this ANR that seems pretty common in the project that i'm working for:

    Project setup:
    Unity 2020.3.34f1
    Google Admob 6.2 ( with Facebook Mediation and UnityAds Mediation )
    Facebook SDK v11
    Firebase 8.10.1

    In the past weeks i've been trying another set of versions for the plugins that i'm using and the issue is still happening, but i don't know how common is this, anyone here have experienced something similar?

    It happends at game lauch.

    Log from firebase crashlytics:
    Brand: Xiaomi
    Model: POCO X3 NFC

    Code (CSharp):
    1. main (native): tid=1 systid=27972
    2. #00 pc 0xd7a58 libc.so
    3. #01 pc 0x19acc libutils.so
    4. #02 pc 0x199ac libutils.so
    5. #03 pc 0x118270 libandroid_runtime.so
    6.        at android.os.MessageQueue.nativePollOnce(Native method)
    7.        at android.os.MessageQueue.next(MessageQueue.java:335)
    8.        at android.os.Looper.loop(Looper.java:193)
    9.        at android.app.ActivityThread.main(ActivityThread.java:7889)
    10.        at java.lang.reflect.Method.invoke(Native method)
    11.        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:600)
    12.        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
    13.  
    Another device:
    Brand: vivo
    Model: Y21A

    Code (CSharp):
    1. main (native): tid=1 systid=29061
    2. #00 pc 0x4c4ec libc.so
    3. #01 pc 0x389f2c libart.so
    4. #02 pc 0x47637c libart.so
    5. #03 pc 0x36ffbf8 base.apk!libmonochrome.so
    6. #04 pc 0x2b52178 base.apk!libmonochrome.so
    7. #05 pc 0x36ffecc base.apk!libmonochrome.so
    8. #06 pc 0x3eeed3c base.apk!libmonochrome.so
    9. #07 pc 0x3eeec74 base.apk!libmonochrome.so
    10. #08 pc 0x3eeebdc base.apk!libmonochrome.so
    11. #09 pc 0x37303a8 base.apk!libmonochrome.so
    12. #10 pc 0x372cfec base.apk!libmonochrome.so
    13. #11 pc 0x409e044 base.apk!libmonochrome.so
    14. #12 pc 0x409dff4 base.apk!libmonochrome.so
    15. #13 pc 0x409df70 base.apk!libmonochrome.so
    16. #14 pc 0x16bb0 libutils.so
    17. #15 pc 0x167b8 libutils.so
    18. #16 pc 0x14fca4 libandroid_runtime.so
    19.        at android.os.MessageQueue.nativePollOnce(Native method)
    20.        at android.os.MessageQueue.next(MessageQueue.java:339)
    21.        at android.os.Looper.loopOnce(Looper.java:186)
    22.        at android.os.Looper.loop(Looper.java:334)
    23.        at android.app.ActivityThread.main(ActivityThread.java:8442)
    24.        at java.lang.reflect.Method.invoke(Native method)
    25.        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582)
    26.        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1068)
     
    Petr777 and ageana like this.
  2. Le_Poulet

    Le_Poulet

    Joined:
    May 18, 2017
    Posts:
    24
    Hi, did you find some answer to this issue? I got similar ANR and no clue on how to solve it.
     
  3. D_Cergy

    D_Cergy

    Joined:
    Feb 18, 2015
    Posts:
    35
  4. StartStart

    StartStart

    Joined:
    Jan 2, 2013
    Posts:
    150
    From my experienced at work, I was reduced RAM and CPU usage. Then ANR goes down like crazy.

    RAM = Use Memory Profiler and try to reduce overall RAM usage to 1GB~2GB.
    CPU = Find a way to optimize scripts to have at least 20+ FPS on average mobile phone.
     
  5. ducloc96

    ducloc96

    Joined:
    Mar 18, 2018
    Posts:
    26
    Can you describe more clearly how you did it? Like using sprite atlas or something.
    What is the way to optimize scripts?
     
  6. StartStart

    StartStart

    Joined:
    Jan 2, 2013
    Posts:
    150
    CPU = Use Profiler to track, if any CPU spike pop you need to fix it.
    RAM = Same as I said on post # 4.
     
  7. kumade

    kumade

    Joined:
    Nov 3, 2016
    Posts:
    52
    Having the same ANRs. Unity 2020.1.17, I'm not using admob, my ad mediation is AppLovin. No FB SDK either. Firebase can't even detect those ANRs, I can only see them in Google Play console and there is empty stacktrace so I can't even understand when/where it happens. So disappointing ;(
     
  8. Ashar01

    Ashar01

    Joined:
    Aug 1, 2014
    Posts:
    6
    Avoid using Awake() too much use Start() instead. Doing this my ANR's dropped from 0.7% to 0.19%

    Use Awake() in just one script per scene.

    Me myself was facing the increasing ANR's issue and I got them reduced from 0.7% to 0.19% just by replacing Awake() by Start()
     
  9. giglersstudio

    giglersstudio

    Joined:
    Jul 13, 2020
    Posts:
    1
    Is there anyone find the solution of this anr?
     
  10. kumade

    kumade

    Joined:
    Nov 3, 2016
    Posts:
    52
    Still struggling :( We even updated Unity to 2022.1.22 (was 2020) but nothing changed.
     
  11. RandomUnityDev123

    RandomUnityDev123

    Joined:
    Oct 28, 2022
    Posts:
    16
    Our game is also seeing ANRs which we are trying to fix. Ours looks like this:


    Input dispatching timed out (7d9aadb com.####.###/com.###.Activity (server) is not responding. Waited 5002ms for FocusEvent(hasFocus=true))


    With a similar stack to yours:

    [URL='https://docs.bugsnag.com/build-integrations/']__kernel_rt_sigreturn
    <unknown>
    android::Looper::pollInner
    android::Looper::pollOnce
    <unknown>
    <unknown>
    com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run
    com.android.internal.os.ZygoteInit.main
    [/URL]


    Can anyone confirm that a FocusEvent being sent from Android will cause OnApplicationPause to be called in Unity? If so, I can at least bookend each OnApplicationPause call with a pair if Bugsnag breadcrumbs, and any call with a missing [End] breadcrumb would be a likely culprit
     
  12. unity_W0vhibUNEtZH1g

    unity_W0vhibUNEtZH1g

    Joined:
    Nov 2, 2022
    Posts:
    5
    is there a fix for this problem?
     
  13. logicpod13

    logicpod13

    Joined:
    Dec 5, 2022
    Posts:
    1
    upload_2023-7-19_11-5-43.png
    Any one have Solution this error or Any idea how to solve this ANR
     
  14. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    Look at other ANRs. This one means that app was unresponsive, but by the time it was killed by OS it had recovered, so any useful info has been lost. It's unlikely for app managed to recover all the time, so by fixing other ANRs you will reduce this one as well.
     
    pixelsprite_unity likes this.
  15. AdiiKhan222

    AdiiKhan222

    Joined:
    Sep 5, 2023
    Posts:
    1
    SIGSEGV

    Getting this error as crash in crashlytics. Can anyone help to solve this ?
     
  16. YousafGrewal

    YousafGrewal

    Joined:
    Jul 5, 2018
    Posts:
    30
    I am alos facing this issue any solution please??

    i am using latest
    Firebase: Version 11.6.0
    Unity Version : 2022.3.7f1
    =================================== Stack Trace ========================================
    main (native):tid=1 systid=23945
    #00 pc 0x9ac68 libc.so (__epoll_pwait + 20)
    #01 pc 0x6c27d libc.so (epoll_wait + 16)
    #02 pc 0x100a5 libutils.so (android::Looper::pollInner(int) + 124)
    #03 pc 0xffcf libutils.so (android::Looper::pollOnce(int, int*, int*, void**) + 62)
    #04 pc 0xe4997 libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long long, int) + 24)
    at android.os.MessageQueue.nativePollOnce(Native method)
    at android.os.MessageQueue.next(MessageQueue.java:339)
    at android.os.Looper.loopOnce(Looper.java:186)
    at android.os.Looper.loop(Looper.java:334)
    at android.app.ActivityThread.main(ActivityThread.java:8513)
    at java.lang.reflect.Method.invoke(Native method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1068)
     
  17. juan_homa

    juan_homa

    Joined:
    Aug 18, 2023
    Posts:
    25
    Is there any relation with the Unity version? we have 2 games practically with the same code but on unity 2021.3 we get half of the ANR's than with unityu 2022.3
     
  18. juan_homa

    juan_homa

    Joined:
    Aug 18, 2023
    Posts:
    25
    you mean latest 2022.3.16 version?, that one hasn't this issue ?
     
  19. moaazafzal

    moaazafzal

    Joined:
    Apr 15, 2016
    Posts:
    4
    @juan_homa Yes it is because of the Unity version. you can try the lastest version.
     
  20. moaazafzal

    moaazafzal

    Joined:
    Apr 15, 2016
    Posts:
    4
    @juan_homa Give Release2022.3.16f1 a try. It can help mitigate ANRs, although it might not eliminate them entirely.
     

    Attached Files:

    unity_51hx49VV5sK89w likes this.
  21. juan_homa

    juan_homa

    Joined:
    Aug 18, 2023
    Posts:
    25
    Thanks !!!
     
  22. ArmanEloyan

    ArmanEloyan

    Joined:
    Feb 4, 2017
    Posts:
    1
    did this help you?