Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Official Introducing GameActivity for Android in 2023.1

Discussion in 'Android' started by Tomas1856, Mar 8, 2023.

  1. senkoi

    senkoi

    Joined:
    Mar 4, 2019
    Posts:
    4

    the attachment contains other threads's stack trace
     

    Attached Files:

  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,948
    This is the game loop thread:
    Code (CSharp):
    1. "Thread-7" tid=21 Native
    2.   #00  pc 0x0000000000085820  /apex/com.android.runtime/lib64/bionic/libc.so (syscall+32)
    3.   #01  pc 0x0000000001a87e1c  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: 3679d3236e6469b5ae6906d9ec48cea376d1d91f)
    4.   #02  pc 0x0000000001a33cd8  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: 3679d3236e6469b5ae6906d9ec48cea376d1d91f)
    5.   #03  pc 0x0000000001a33a8c  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: 3679d3236e6469b5ae6906d9ec48cea376d1d91f)
    6.   #04  pc 0x0000000001a338cc  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: 3679d3236e6469b5ae6906d9ec48cea376d1d91f)
    7.   #05  pc 0x0000000001a56984  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: 3679d3236e6469b5ae6906d9ec48cea376d1d91f)
    8.   #06  pc 0x000000000325dea4  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: 3679d3236e6469b5ae6906d9ec48cea376d1d91f)
    9.   #07  pc 0x000000000325e390  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: 3679d3236e6469b5ae6906d9ec48cea376d1d91f)
    10.   #08  pc 0x0000000001b93e94  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: 3679d3236e6469b5ae6906d9ec48cea376d1d91f)
    11.   #09  pc 0x0000000003ad3d68  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: 3679d3236e6469b5ae6906d9ec48cea376d1d91f)
    12.   #10  pc 0x0000000001de1360  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: 3679d3236e6469b5ae6906d9ec48cea376d1d91f)
    13.   #11  pc 0x0000000003dbcff4  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: 3679d3236e6469b5ae6906d9ec48cea376d1d91f)
    14.   #12  pc 0x0000000003dbc6a8  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: 3679d3236e6469b5ae6906d9ec48cea376d1d91f)
    15.   #13  pc 0x0000000003dbc408  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: 3679d3236e6469b5ae6906d9ec48cea376d1d91f)
    16.   #14  pc 0x0000000001a64e60  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: 3679d3236e6469b5ae6906d9ec48cea376d1d91f)
    17.   #15  pc 0x0000000001a64dac  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: 3679d3236e6469b5ae6906d9ec48cea376d1d91f)
    18.   #16  pc 0x0000000000643078  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: d78431a74ae2b093)
    19.   #17  pc 0x0000000000654e60  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: d78431a74ae2b093)
    20.   #18  pc 0x0000000000660b14  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: d78431a74ae2b093)
    21.   #19  pc 0x000000000047fa40  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: d78431a74ae2b093)
    22.   #20  pc 0x0000000000547578  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: d78431a74ae2b093)
    23.   #21  pc 0x00000000005475b8  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: d78431a74ae2b093)
    24.   #22  pc 0x0000000000547844  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: d78431a74ae2b093)
    25.   #23  pc 0x00000000006e9d58  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (BuildId: d78431a74ae2b093)
    26.   #24  pc 0x0000000000012934  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (Unity::UnityApplication::Loop+440) (BuildId: 14805c37ed50874fbf95c8045452800a20b75bbd)
    27.   #25  pc 0x0000000000014d14  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (MainLoop+60) (BuildId: 14805c37ed50874fbf95c8045452800a20b75bbd)
    28.   #26  pc 0x0000000000014de0  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (android_main+152) (BuildId: 14805c37ed50874fbf95c8045452800a20b75bbd)
    29.   #27  pc 0x000000000001b3a4  /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (android_app_entry+260) (BuildId: 14805c37ed50874fbf95c8045452800a20b75bbd)
    30.   #28  pc 0x00000000000eaec0  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start+204)
    31.   #29  pc 0x000000000008a82c  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)
    The stacktrace needs to be resolved to know where it's stopped, did you build with symbols?.

    By the way, what build output did you use - aab, apk, split apk ?
     
  3. senkoi

    senkoi

    Joined:
    Mar 4, 2019
    Posts:
    4

    after ndk-stack, just the 4 lines has meaningful outputs(other line just output ??), build output format is aab

    #24 pc 0x0000000000012934 /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (Unity::UnityApplication::Loop+440) (BuildId: 14805c37ed50874fbf95c8045452800a20b75bbd)
    #25 pc 0x0000000000014d14 /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (MainLoop+60) (BuildId: 14805c37ed50874fbf95c8045452800a20b75bbd)
    #26 pc 0x0000000000014de0 /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (android_main+152) (BuildId: 14805c37ed50874fbf95c8045452800a20b75bbd)
    #27 pc 0x000000000001b3a4 /data/app/~~TILNXUkUGG7uErFRApetMA==/app-mubK3VE2FBA3UjKKovGPWQ==/split_config.arm64_v8a.apk (android_app_entry+260) (BuildId: 14805c37ed50874fbf95c8045452800a20b75bbd)
    /Users/xxx/dev/unity/ddd/Library/Bee/Android/Prj/IL2CPP/Gradle/unityLibrary/src/main/cpp/GameActivity/UGAApplication.cpp:387
    /Users/xxx/dev/unity/ddd/Library/Bee/Android/Prj/IL2CPP/Gradle/unityLibrary/src/main/cpp/GameActivity/UGAEntry.cpp:77
    /Users/xxx/dev/unity/ddd/Library/Bee/Android/Prj/IL2CPP/Gradle/unityLibrary/src/main/cpp/GameActivity/UGAEntry.cpp:96
    /buildbot/src/android/android-games-sdk-game-activity-release/gamesdk/game-activity/.cxx/RelWithDebInfo/726h3ds5/arm64-v8a/../../../../prefab-src/modules/game-activity/include/game-activity/native_app_glue/android_native_app_glue.c:236
     
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,948
    That's not enough, the top frames need to be resolved also, but the problem is, those lines don't contain info from which native library the frame originates, it's probably libunity.so or libil2cpp.so
     
  5. senkoi

    senkoi

    Joined:
    Mar 4, 2019
    Posts:
    4
    Finally I figure out the issue. It's caused by a third party library (NativeGallery) which create a lock object and wait in unity main thread. Though only Android UI thread will raise ANR, even using gameactivity, the unity thread still need call some function which require sync with andriod ui thread. So in such case, if unity thread blocked, android ui thread will also blocked.
     
    pixelsprite_unity likes this.
  6. sk_unity56

    sk_unity56

    Joined:
    Apr 23, 2024
    Posts:
    1
    Have anyone faced the issue that "com.unity3d.player.UnityPlayer" cannot be found by jniEnv->FindClass call?
    Having such issue on the Unity 2023.2.18f1.
    Our plugin working fine if Activity selected as starting point, when GameActivity selected, UnityPlayer class cannot be found.

    Also unity shows that log by it own without our plugin installed. Was something changed recently? How can we get currentActivity field if UnityPlayer class not found.

    2024.04.23 13:11:48.758 14588 14611 Error Unity JNI:InitializeSustainedPerformance:java.lang.ClassNotFoundException: Didn't find class "com.unity3d.player.UnityPlayer" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/system/lib, /system/system_ext/lib, /system/lib, /system/system_ext/lib]]
     
  7. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,948
    GameActivity creates gameloop thread via pthread, while Activity creates gameloop thread from java thread. Because of that for GameActivity JNI uses different system class loader, which doesn't see all java classes. One way for you to workaround this - is to perform FindClass from UI thread.
     
    sk_unity56 likes this.
  8. Christopher412

    Christopher412

    Joined:
    May 26, 2023
    Posts:
    36
  9. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,948
    Check UIToolkit Input Field, it probably has Hide Mobile Input set to false by default, that means it will ask Mobile Keyboard to not Hide Mobile Input, and that's not supported with GameActivity.

    GameActivity uses Google's on screen keyboard implementation, thus there are slight differences - like Android native input field not being present.

    Could you please submit a bug with repro project attached, so we can investigate, thank you.
     
  10. Christopher412

    Christopher412

    Joined:
    May 26, 2023
    Posts:
    36
    I get the same "cropped" Mobile Keyboard with and without "Hide Mobile Input" toggled. No difference. In my use-case, I'd want it without Mobile Input. Using the non Game Activity version, I get the same Mobile Input as the first screenshot when I have "Hide Mobile Input" off. If it's on, there is an extra row on top showing the Mobile input.

    I'll try to find time to submit a bug in the CET morning.
     
  11. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    2,030
    It's unfortunate that AppCompatActivity which is base class of GameActivity was not back-ported for UnityPlayerActivity. Now as a plugin publisher we need to maintain two variations(to support from 2021.3+) for handling activity results as
    startActivityForResult was deprecated in favour of ActivityResultLauncher