playgameservices / play-games-plugin-for-unity

Google Play Games plugin for Unity
Other
3.47k stars 966 forks source link

Ocassional crash when using GetStats() #1585

Open Zamaroht opened 7 years ago

Zamaroht commented 7 years ago

Hello! We have a few games released using this plugin and working fine. Recently, we started to make use of the PlayerStats API. The implementation is rather simple, this is pretty much the code we added after getting a successful login callback:

((PlayGamesLocalUser)Social.localUser).GetStats((rc, stats) => {
    if (rc <= 0)
    {
        playerStats = stats;
    }
});

And from then on, we make use of the playerStats object properties, always making a null check before.

We started getting some occassional cryptic crash logs in the Google Play Console, all very similar to this one:

java.lang.Error: FATAL EXCEPTION [UnityMain] Unity version : 5.5.0f3 Device model : motorola XT1021 Device fingerprint: motorola/condor_retgb/condor_umts:5.1/LPCS23.13-34.8-3/3:user/release-keys

Caused by: java.lang.Error: signal 6 (SIGABRT), code -6 (?), fault addr -------- Build fingerprint: 'motorola/condor_retgb/condor_umts:5.1/LPCS23.13-34.8-3/3:user/release-keys' Revision: 'p2b0' pid: 9195, tid: 9195, name: .ag.crystalrush >>> com.ag.crystalrush <<< r0 00000000 r1 000023eb r2 00000006 r3 00000000 r4 b6f79e38 r5 00000006 r6 0000000b r7 0000010c r8 00000000 r9 b783aba8 sl b78446d0 fp 00000001 ip 000023eb sp bec08040 lr b6e07049 pc b6e2d624 cpsr 504c2f31

at libc.tgkill(tgkill:12) at libc.pthread_kill(pthread_kill:52) at libc.raise(raise:10) at libc.libc_android_abort(libc_android_abort:36) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4) at libc.abort(abort:4)

We had no clue how it happened, until the game started to crash in one of our test devices, and we managed to grab a logcat from the crash. The crash itself looks like the previous log, but the additional data found in the logcat shows the following:

01-25 16:44:15.735: E/CRASH(12641):     #31  pc 000170e8  /system/lib/libc.so (abort+4)
01-25 16:44:15.735: E/CRASH(12641):     #32  il ........  at (wrapper managed-to-native) UnityEngine.AndroidJNI.INTERNAL_CALL_GetObjectClass (intptr,intptr&) <0xffffffff>
01-25 16:44:15.736: E/CRASH(12641):     #33  il 00000028  at UnityEngine.AndroidJNI.GetObjectClass (intptr) <0x00028>
01-25 16:44:15.736: E/CRASH(12641):     #34  il 0000002f  at Google.Developers.JavaObjWrapper.InvokeCall<single> (string,string,object[]) <0x0002f>
01-25 16:44:15.736: E/CRASH(12641):     #35  il 0000003f  at Com.Google.Android.Gms.Games.Stats.PlayerStatsObject.getAverageSessionLength () <0x0003f>
01-25 16:44:15.736: E/CRASH(12641):     #36  il 00000083  at GooglePlayGames.Android.AndroidClient/<GetPlayerStats>c__AnonStorey1.<>m__0 (int,Com.Google.Android.Gms.Games.Stats.PlayerStats) <0x00083>
01-25 16:44:15.736: E/CRASH(12641):     #37  il 00000063  at GooglePlayGames.Android.AndroidClient/StatsResultCallback.OnResult (Com.Google.Android.Gms.Games.Stats.Stats_LoadPlayerStatsResultObject) <0x00063>
01-25 16:44:15.736: E/CRASH(12641):     #38  il 000001c7  at Com.Google.Android.Gms.Common.Api.ResultCallbackProxy`1<object>.onResult (UnityEngine.AndroidJavaObject) <0x001c7>
01-25 16:44:15.736: E/CRASH(12641):     #39  il 00000073  at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object (object,intptr,intptr,intptr) <0x00073>
01-25 16:44:15.736: E/CRASH(12641):     #40  il ........  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (object,object[],System.Exception&) <0xffffffff>
01-25 16:44:15.736: E/CRASH(12641):     #41  il 00000184  at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) <0x00184>
01-25 16:44:15.736: E/CRASH(12641):     #42  il 0000004b  at System.Reflection.MethodBase.Invoke (object,object[]) <0x0004b>
01-25 16:44:15.736: E/CRASH(12641):     #43  il 00000167  at UnityEngine.AndroidJavaProxy.Invoke (string,object[]) <0x00167>
01-25 16:44:15.736: E/CRASH(12641):     #44  il 00000093  at UnityEngine.AndroidJavaProxy.Invoke (string,UnityEngine.AndroidJavaObject[]) <0x00093>
01-25 16:44:15.736: E/CRASH(12641):     #45  il 000000ff  at UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy,intptr,intptr) <0x000ff>
01-25 16:44:15.736: E/CRASH(12641):     #46  il 00000083  at (wrapper runtime-invoke) <Module>.runtime_invoke_intptr_object_intptr_intptr (object,intptr,intptr,intptr) <0x00083>
01-25 16:44:15.737: E/CRASH(12641):     #00  pc 00021d3b  /data/app/com.ag.crystalrush-1/lib/arm/libmono.so
01-25 16:44:15.737: E/CRASH(12641):     #01  pc 001f2d58  /data/app/com.ag.crystalrush-1/lib/arm/libmono.so (mono_runtime_invoke+136)
01-25 16:44:15.737: E/CRASH(12641):     #02  pc 004a85f4  /data/app/com.ag.crystalrush-1/lib/arm/libunity.so
01-25 16:44:15.737: E/CRASH(12641):     #03  pc 009011a4  /data/app/com.ag.crystalrush-1/lib/arm/libunity.so
01-25 16:44:15.737: E/CRASH(12641):     #04  pc 00086c99  /data/app/com.ag.crystalrush-1/oat/arm/base.odex

Right before the crash, there is an apparently debug print from GPGS:

01-25 16:44:15.476: I/Unity(12641): Result for getStats: 4

Some more context in how we reproduced the crash: The test device had a bad internet connection (it was connected to wifi, but the internet connection in the wifi router had just dropped). The game has been working fine for days. However, at a given moment, the game crashed on startup. Trying to open the game again resulted in a crash aswell. We tried about 10 times and it always crashed. However, after waiting about 10 minutes (and I think the internet connection was restored), the game started to open correctly again. Also, when the game crashed we could still hear the game background music, looks like it crashed in a different thread. I'm attaching the full logcat we could grab when it was crashing in our test device:

filtered_log.txt

Thanks!

Zamaroht commented 7 years ago

I´m attaching a second log we got that same day from the same device. Application opened and instant crash.

filtered_log_2.txt

After a few minutes the game started to work fine.

claywilkinson commented 7 years ago

Thanks for the information. We'll take a look. It looks like there is a callback to the JNI layer in Unity from a thread that is unexpected in the case of a network problem or something...

Slan1 commented 7 years ago

Hello, I keep receiving exact same crash. Can anybody help us? Thank you.