Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Android crash so much, crash free user 90%, at libunity.so jni::NewGlobalRef(_jobject*)

Discussion in 'Android' started by unity_2bv3PxgjqcPIrw, Jul 5, 2022.

  1. unity_2bv3PxgjqcPIrw

    unity_2bv3PxgjqcPIrw

    Joined:
    Sep 30, 2020
    Posts:
    11
    Hello every body, I have a android game build with unity 2021.3.4f1 for android, build with il2cpp, strip enginecode enable and symbols on.
    The firebase crashlytics for unity version 9.0.0
    My size after build is 90mb, the texture size about 90% size build, and i think this size is well and no problem with this build.

    But in 2 versions I have build, the crash free user is 90%, about 10 player then 1 player send crash,
    And my android game have about 150k users, but about 20k crashes record in my firebase crashlytics
    Here is some crash log in crashlytics.

    My log is upload_2022-7-5_18-31-13.png upload_2022-7-5_18-31-37.png

    upload_2022-7-5_18-33-41.png

    I have found more topic, docs to resolve this but it seem i can not find a solution to resolve this, could anyone help me resolve this?
    Thank you very much.
     

    Attached Files:

  2. unity_2bv3PxgjqcPIrw

    unity_2bv3PxgjqcPIrw

    Joined:
    Sep 30, 2020
    Posts:
    11
    here is my build settings: upload_2022-7-5_18-39-16.png
    upload_2022-7-5_18-39-30.png

    upload_2022-7-5_18-39-48.png
    upload_2022-7-5_18-40-3.png
    upload_2022-7-5_18-40-34.png
     
  3. unity_2bv3PxgjqcPIrw

    unity_2bv3PxgjqcPIrw

    Joined:
    Sep 30, 2020
    Posts:
    11
  4. unity_2bv3PxgjqcPIrw

    unity_2bv3PxgjqcPIrw

    Joined:
    Sep 30, 2020
    Posts:
    11
    upload_2022-7-5_18-52-59.png
    Here is crash in last 7 day
     
  5. unity_2bv3PxgjqcPIrw

    unity_2bv3PxgjqcPIrw

    Joined:
    Sep 30, 2020
    Posts:
    11
    The crash report in any android version: 9, 10, 11, 12
     
  6. unity_2bv3PxgjqcPIrw

    unity_2bv3PxgjqcPIrw

    Joined:
    Sep 30, 2020
    Posts:
    11
    please help me :'(
     
  7. Iq51

    Iq51

    Joined:
    Feb 16, 2015
    Posts:
    5
  8. ci_unity306

    ci_unity306

    Joined:
    Mar 21, 2020
    Posts:
    1
    It seems this problem doesn't related to mentioned issue as it appears also on unity 2021.3.2f1 and 2021.3.6f1
     
    unity_2bv3PxgjqcPIrw likes this.
  9. unity_2bv3PxgjqcPIrw

    unity_2bv3PxgjqcPIrw

    Joined:
    Sep 30, 2020
    Posts:
    11
    Thank for your answer,
    You mean you has meet this issues on 2021.3.2f1 and 2021.3.6f1, right?
     
  10. solinvictus1313

    solinvictus1313

    Joined:
    Mar 31, 2020
    Posts:
    7
    I have the same issue with 2020.3.36f1, thinking about a downgrade now.
    @unity_2bv3PxgjqcPIrw did you upgrade Unity to a new version recently? Was there another version of Unity that didn't show this issue?
     
  11. starstablesimon

    starstablesimon

    Joined:
    Nov 24, 2016
    Posts:
    18
    Happens for us too, same build settings.
    Tried 2021.3.4 - .5 - .6.
    Can't repro it locally unfortunately so I only have the Crashlytics logs.
     
  12. unity_2jxHNVY36zr2mg

    unity_2jxHNVY36zr2mg

    Joined:
    Jan 17, 2020
    Posts:
    86
    got this one

    backtrace:
    #00 pc 0000000000051b7c /apex/com.android.runtime/lib64/bionic/libc.so (abort+168)
    #00 pc 00000000006d157c /apex/com.android.art/lib64/libart.so (art::Runtime::Abort(char const*)+668)
    #00 pc 000000000001695c /apex/com.android.art/lib64/libbase.so (android::base::SetAborter(std::__1::function<void (char const*)>&&)::$_3::__invoke(char const*)+76)
    #00 pc 0000000000015f8c /apex/com.android.art/lib64/libbase.so (android::base::LogMessage::~LogMessage()+364)
    #00 pc 00000000002857ec /apex/com.android.art/lib64/libart.so (art::JavaVMExt::AddGlobalRef(art::Thread*, art::ObjPtr<art::mirror::Object>)+1924)
    #00 pc 000000000059add0 /apex/com.android.art/lib64/libart.so (art::JNI<false>::NewGlobalRef(_JNIEnv*, _jobject*)+272)
    #00 pc 00000000041b24b4 /data/app/~~UkTkLlfuu8UMQJOIcA88pA==/com.google.android.trichromelibrary_506007134-8MeReYJWBimkXTC3EUPvWg==/base.apk!libmonochrome_64.so
    #00 pc 00000000041b216c /data/app/~~UkTkLlfuu8UMQJOIcA88pA==/com.google.android.trichromelibrary_506007134-8MeReYJWBimkXTC3EUPvWg==/base.apk!libmonochrome_64.so
    #00 pc 00000000020beccc /data/app/~~UkTkLlfuu8UMQJOIcA88pA==/com.google.android.trichromelibrary_506007134-8MeReYJWBimkXTC3EUPvWg==/base.apk!libmonochrome_64.so
    #00 pc 0000000003298898 /data/app/~~UkTkLlfuu8UMQJOIcA88pA==/com.google.android.trichromelibrary_506007134-8MeReYJWBimkXTC3EUPvWg==/base.apk!libmonochrome_64.so
    #00 pc 0000000003298830 /data/app/~~UkTkLlfuu8UMQJOIcA88pA==/com.google.android.trichromelibrary_506007134-8MeReYJWBimkXTC3EUPvWg==/base.apk!libmonochrome_64.so (Java_J_N_MLlibBXh+28)
    #00 pc 000000000018a334 /data/app/~~FhXBhPaqs5ocynpLuBItwA==/com.google.android.webview-EoqPA2IGmPH8wUaryk_wig==/oat/arm64/base.odex (art_jni_trampoline+116)
    #00 pc 00000000002fae90 /data/app/~~FhXBhPaqs5ocynpLuBItwA==/com.google.android.webview-EoqPA2IGmPH8wUaryk_wig==/oat/arm64/base.odex (org.chromium.base.JavaExceptionReporter.uncaughtException+80)
    #00 pc 000000000020aec4 /apex/com.android.art/lib64/libart.so (nterp_helper+7636)
    #00 pc 00000000000ec490 /apex/com.android.art/javalib/core-oj.jar (java.lang.ThreadGroup.uncaughtException+28)
    #00 pc 000000000020a044 /apex/com.android.art/lib64/libart.so (nterp_helper+3924)
    #00 pc 00000000000ec47c /apex/com.android.art/javalib/core-oj.jar (java.lang.ThreadGroup.uncaughtException+8)
    #00 pc 000000000020ae64 /apex/com.android.art/lib64/libart.so (nterp_helper+7540)
    #00 pc 00000000000ed702 /apex/com.android.art/javalib/core-oj.jar (java.lang.Thread.dispatchUncaughtException+30)
    #00 pc 00000000002ca764 /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548)
    #00 pc 0000000000430030 /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list)+880)
    #00 pc 00000000005ab80c /apex/com.android.art/lib64/libart.so (art::JNI<false>::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)+300)
    #00 pc 000000000045b87c /apex/com.android.art/lib64/libart.so (_JNIEnv::CallVoidMethod(_jobject*, _jmethodID*, ...)+120)
    #00 pc 000000000045b2e0 /apex/com.android.art/lib64/libart.so (art::Thread::HandleUncaughtExceptions(art::ScopedObjectAccessAlreadyRunnable&)+216)
    #00 pc 00000000004594cc /apex/com.android.art/lib64/libart.so (art::Thread::Destroy()+456)
    #00 pc 00000000004587a8 /apex/com.android.art/lib64/libart.so (art::ThreadList::Unregister(art::Thread*)+132)
    #00 pc 00000000003da814 /apex/com.android.art/lib64/libart.so (art::Runtime::DetachCurrentThread()+128)
    #00 pc 000000000058fccc /apex/com.android.art/lib64/libart.so (art::JII::DetachCurrentThread(_JavaVM*)+48)
    #00 pc 00000000000c0268 /system/lib64/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&, bool)+984)
    #00 pc 00000000000025a8 /system/bin/app_process64 (main+1360)
    #00 pc 000000000004a070 /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+100)
     
    unity_2bv3PxgjqcPIrw likes this.
  13. unity_2bv3PxgjqcPIrw

    unity_2bv3PxgjqcPIrw

    Joined:
    Sep 30, 2020
    Posts:
    11
    No pro, i use this first release is 2021.3.4f1
     
  14. unity_2bv3PxgjqcPIrw

    unity_2bv3PxgjqcPIrw

    Joined:
    Sep 30, 2020
    Posts:
    11
    I have use 2021.3.4 and .5 too, but it just report some new fresh crash, the big crash with 10% user does not resolve
     
  15. solinvictus1313

    solinvictus1313

    Joined:
    Mar 31, 2020
    Posts:
    7
    After running into this issue with 2020.3.36f1, I decided to roll back to 2020.3.34f1, and so far it's looking like this issue is gone. Not sure what (if any) version this would be in the 2021.3 cycle, but it may be worth experimenting.
     
  16. unity_2bv3PxgjqcPIrw

    unity_2bv3PxgjqcPIrw

    Joined:
    Sep 30, 2020
    Posts:
    11
    Thank for your reply, could you send me some crash log of 2020.3.36f1? I check to make sure this crash on 2020.3.36f1 is same my app crash
     
  17. unity_2bv3PxgjqcPIrw

    unity_2bv3PxgjqcPIrw

    Joined:
    Sep 30, 2020
    Posts:
    11
    @solinvictus1313, when you use 2020.3.36f1, how much ratio crash free user?
     
  18. solinvictus1313

    solinvictus1313

    Joined:
    Mar 31, 2020
    Posts:
    7
    The crash log is virtually the same, no need to paste the same thing again.

    Crashlytics tell me that with 2020.3.36f1, around 4% of users encountered theses crashes. For unrelated reasons, I was cautious with this particular app update and did a very small percentage rollout on Google Play, so the absolute numbers are relatively small and the percentage may be misleading.
     
  19. makcimbx

    makcimbx

    Joined:
    Aug 29, 2017
    Posts:
    12
    2021.3.5f1, Same issue
     
  20. RaventurnPatrick

    RaventurnPatrick

    Joined:
    Aug 9, 2011
    Posts:
    167
    Same here (2020.3.36f1, 34f1 worked without crashes)
     
  21. Daryl_1

    Daryl_1

    Joined:
    Feb 13, 2014
    Posts:
    22
    Does anyone know if this now fixed in 2020.3.37f1?
     
  22. RaventurnPatrick

    RaventurnPatrick

    Joined:
    Aug 9, 2011
    Posts:
    167
    Google Play Login is also broken since this bug was introduced, so there must be some other adverse effects.
    Can someone from Unity tell us how this bug was introduced in the first place? E.g. was there some kind of change to how Android/JNI is handled that now breaks other Android Plugins (such as Google Play Core) as well?
     
  23. domonyiv

    domonyiv

    Joined:
    Oct 1, 2016
    Posts:
    75
    I have the same problem with 2020.3.37f1. @Tomas1856 , can you help us?

    Crashlytics examples:
    Code (CSharp):
    1.  
    2. libunity.so jni::NewGlobalRef(_jobject*)
    3. libunity.so nativeInjectEvent(_JNIEnv*, _jobject*, _jobject*)
    4.  
    Code (CSharp):
    1.  
    2. libunity.so jni::NewGlobalRef(_jobject*)
    3. libunity.so android::view::Choreographer_FrameCallback::__Proxy::__TryInvoke(_jclass*, _jmethodID*, _jobjectArray*, bool*, _jobject**)
    4. libunity.so jni::ProxyGenerator<jni::GlobalRefAllocator, android::os::Handler_Callback, android::view::Choreographer_FrameCallback>::__InvokeInternal(_jclass*, _jmethodID*, _jobjectArray*, _jobject**)
    5.  
    Code (CSharp):
    1.  
    2. libunity.so jni::NewGlobalRef(_jobject*)
    3. libunity.so ProcessJoystickEvent(android::view::InputEvent const&, int)
    4. libunity.so __emutls_register_common
    5.  
     
    Last edited: Jul 26, 2022
  24. unity_2jxHNVY36zr2mg

    unity_2jxHNVY36zr2mg

    Joined:
    Jan 17, 2020
    Posts:
    86
    This appears to have been fixed in 2021.3.6f1.
     
  25. domonyiv

    domonyiv

    Joined:
    Oct 1, 2016
    Posts:
    75
    Thanks, unfortunately I can't upgrade to 2021.3.6f1 because it has a serious UI problem. I hope the fix will be backported to 2020 LTS.
     
  26. T2GGames

    T2GGames

    Joined:
    Nov 8, 2016
    Posts:
    16
    Hi, is that true? I plan to upgrade the unity to 2021.3.61fc1
     
  27. unity_E4937178697E8128E414

    unity_E4937178697E8128E414

    Joined:
    Feb 8, 2022
    Posts:
    1
    2021.3.6f1 same issue
     
    Last edited: Jul 26, 2022
  28. T2GGames

    T2GGames

    Joined:
    Nov 8, 2016
    Posts:
    16
    Got the same crashes & ANR, I just use the AdMob plugin, what should I do?
     

    Attached Files:

    Last edited: Jul 27, 2022
  29. LBCstudios

    LBCstudios

    Joined:
    Mar 8, 2017
    Posts:
    8
    I have been battling this crash (and a few other very similar ones) for 3 weeks since I foolishly updated to 2021.3.4 from what had been a perfectly stable 2020.3.25f1. Just like you 2021.3.6 has horrendous UI issues, but I was able to get 2021.3.5 working without any issues - and while it has helped reduce crashes slightly it's not near enough. Oddly, my crashes swapped from being overwhelmingly Android 12 to overwhelmingly non-android 12. I went from being below the bad behavior thresholds across the board without effort, to being consistently way above them (~3% crash rates). And it seems to be no matter what I do it had almost no effect on this issue.

    What I've tried:
    - Update Unity Ads to most recent.
    - Update Singular SDK.
    - Completely disable Facebook SDK

    I've been told that reverting is dangerous but I am at my wits end at this point.
     
  30. Yuafa

    Yuafa

    Joined:
    Oct 17, 2016
    Posts:
    5
    2021.3.6f1c1 same issue
    upload_2022-7-28_19-32-43.png
     
  31. unity_1965530BB176256921A7

    unity_1965530BB176256921A7

    Joined:
    Apr 12, 2022
    Posts:
    1
    Same on 2021.3.6f1c1
     
    noptanakhon11 likes this.
  32. domonyiv

    domonyiv

    Joined:
    Oct 1, 2016
    Posts:
    75
    Anyone tried 2021.3.7f1 yet? Unfortunately I don't see anything in the changelog related to this issue.
     
  33. Yuafa

    Yuafa

    Joined:
    Oct 17, 2016
    Posts:
    5
  34. IgorBoyko

    IgorBoyko

    Joined:
    Sep 28, 2020
    Posts:
    90
    Same here with 2021.3.5f1
     
  35. LBCstudios

    LBCstudios

    Joined:
    Mar 8, 2017
    Posts:
    8
    Other's have reported that 2021.3.2 is stable. But if you want to be really safe, lots of people have gone back to 2020.3.34. We went back to 2020.3.25 which was our last stable unity version. Reverting appears to be the best fix for these crashes.
     
  36. IgorBoyko

    IgorBoyko

    Joined:
    Sep 28, 2020
    Posts:
    90
    Yup might as well work for this specific issue.

    Problem is, there are several other bugs which have been fixed in current version. As I remember, 2021.3.2f1 has a bug with Addressables on Android which makes all asset loading at least 2 times slower at best. And there's lots of those as you go down the version.

    I am not sure it's the best idea to just downgrade and accept it as it is. I am bumping the post specifically to point out the problem once again and make it more noticeable as I can.
     
  37. LBCstudios

    LBCstudios

    Joined:
    Mar 8, 2017
    Posts:
    8
    Just to update, we reverted to 2020.3.25f (last stable version) from (2021.3.4) and our crashes dropped to essentially zero.
     
    IgorBoyko likes this.
  38. IgorBoyko

    IgorBoyko

    Joined:
    Sep 28, 2020
    Posts:
    90
    Has anyone tried 2021.3.8f1 regarding this issue? Thanks
     
  39. l_racher

    l_racher

    Joined:
    Sep 1, 2018
    Posts:
    12
    I downgraded to 2020.3.34 and the issue went away entirely.
    Still curious when exactly this problem was introduced in newer major versions.
    There are conflicting reports in this thread about it.
    I expect that some of the people encountering these symptoms are simply suffering a memory leak in their code somewhere which a downgrade is obviously not going to fix.

    But just to point this out yet again, this is some sort of bug first introduced with 2020.3.35 and it crashes android 9 and up and it still persists. I have not a single report of older android versions suffering this problem even down to 4.4 KitKat.

    Edit:
    I am not 100% sure but I think this is the same issue as https://forum.unity.com/threads/fix...erences-for-android-view-motionevent.1297569/. It looks very similar.
    And according to this thread, the problem should be fixed in 2021.3.8f1 and 2020.3.38f1.
     
    Last edited: Aug 13, 2022
    adbourdages and IgorBoyko like this.
  40. manugil

    manugil

    Unity Technologies

    Joined:
    Jan 13, 2020
    Posts:
    40
  41. hzn403

    hzn403

    Joined:
    Apr 23, 2013
    Posts:
    6
    I am encountering the same problem with 2020.3.30f1
    There are several responses in this forum that it is related to MotionEvent, but there are no messages in my crash report related to MotionEvent.
    On what basis are you saying it is related to MotionEvent?
     
  42. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,637
    It was visible from the logs. If you can't see it in your logs, then your problem is different.
     
  43. l_racher

    l_racher

    Joined:
    Sep 1, 2018
    Posts:
    12
    From my testing, the bug was introduced in 2020.3.35 so your issue is almost certainly not related to this bug. But when I was researching the bug myself I found various sources of people with very similar symptoms and error messages that simply had a memory leak that typically only leaked very small objects and eventually overflowed some internal limit of the il2cpp runtime. I am not positive about any of this of course because it turned out, in my case, this bug was at fault but maybe this will help you find other results which are closer to your problem.
     
  44. ageana

    ageana

    Joined:
    Nov 6, 2013
    Posts:
    48
    This still happens for me in 2022.3.6f1.

    mxL5jzEyRUvLcw9J8Yk0OwF2UA8w7gW8GovSi2AN.jpeg
     
  45. unity_awUpacKcgHt1UA

    unity_awUpacKcgHt1UA

    Joined:
    Mar 9, 2023
    Posts:
    2
  46. zhengnh

    zhengnh

    Joined:
    Feb 23, 2018
    Posts:
    1
    2021.3.6f1c1 Have you solved the same problem now
     
  47. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,444
    I recently investigated a crash involving
    jni::NewGlobalRef(_jobject*)
    in our game.

    It turned out that the game was frequently generating
    AndroidJavaClass
    and
    AndroidJavaObject
    instances without ever releasing them. The constructors of AndroidJavaClass/AndroidJavaObject include a call to
    NewGlobalRef
    (github).

    The issue was that the global reference table in Java would eventually reach its limit and result in a crash. Making sure instances get released, fixed the jni::NewGlobalRef(_jobject*) crash.

    Search your code-base (including plugins) for any code that creates AndroidJavaClass and AndroidJavaObject instances or uses the AndroidJNI.NewGlobalRef function and doesn't release them.

    Hope it helps!