#Improperly setup leaderboard causes iOS plugin exception and full crash

1 messages · Page 1 of 1 (latest)

vivid stream
#

I added a new leaderboard the Essential Kit's Game Services, but not to the AppStoreConnect GameCenter backend, and when I tried to submit a score to it, the iOS part of the plugin caused an exception, so the app fully crashed.
The issue is that the Unity part of the plugin passed a leaderboard ID to the iOS part, NPLeaderboardCreate(), but the NPGameKitLeaderboardBinding's getLeaderboard() returned nil, which was passed to NPRetainWithOwnershipTransfer(), with no nil check before trying to retain it, thus the exception/crash, which was not passed back to the Unity part of the plugin, so I could not handle it properly.

Additionally, I did fix the AppStoreConnect part, but I still got one more of these crashes; my best guess is that it was a caching issue, are the leaderboards in the iOS part cached to file?

lunar vigil
#

If you already added the required id's in the Essential Kit settings, it should work as expected.
Ideally, there should be a mapping with the id's you created in our settings and platform leaderboard ids.

We do cache leaderboards, but at runtime. So they won't survive after a restart.

Do you use leaderboard sets in any case?

vivid stream
#

Ideally is great, but in reality I had to do a lot of trial and error to figure out why the crash was happening because no exception was sent back to Unity saying that the ID I thought was set up was not.

I do not use sets, but I do use groups.

lunar vigil
#

Ok, I was supposed to ask for groups.

vivid stream
#

No, that is a related but separate issue in which I had set up the leaderboards correctly, but the existing plugin code did not properly handle group name.

lunar vigil
#

I'm missing something here. Let me try the setup once again.

faint reef
#

I also just experienced a crash today on NPLeaderboardCreate and NPRetainWithOwnershipTransfer. I'll check how my leaderboards are set up as well.

#
Exception Codes: 0x0000000000000001, 0x000000019c9f99a8
Triggered by Thread:  0


Thread 0 name:
Thread 0 Crashed:
0   CoreFoundation                    0x000000019c9f99a8 CFRetain.cold.1 + 16 (CFRuntime.c:1178)
1   CoreFoundation                    0x000000019c9065d8 CFEqual + 0 (CFRuntime.c:1370)
2   UnityFramework                    0x000000010b9ba018 NPRetainWithOwnershipTransfer(objc_object*) + 64 (NPBindingHelper.mm:557)
3   UnityFramework                    0x000000010b9becb4 NPLeaderboardCreate + 32 (NPGameKitLeaderboardBinding.mm:62)
4   UnityFramework                    0x0000000110170200 LeaderboardBinding_NPLeaderboardCreate_m3F03382FB9F798717C1A43CFAA08D8084E8F6811 + 16 (VoxelBusters.EssentialKit.iOSModule.cpp:23423)
5   UnityFramework                    0x0000000110170200 Leaderboard__ctor_mBEF76531BE6148BFECE8DC472412B08170F31302 + 136 (VoxelBusters.EssentialKit.iOSModule.cpp:21941)
6   UnityFramework                    0x0000000110170164 GameCenterInterface_CreateLeaderboard_m992985B333DD22BCBFF6E266723E694A66894C31 + 88 (VoxelBusters.EssentialKit.iOSModule.cpp:21314)
7   UnityFramework                    0x000000011013805c InterfaceFuncInvoker2<Il2CppObject*, String_t*, String_t*>::Invoke(unsigned short, Il2CppClass*, Il2CppObject*, String_t*, String_t*) + 96 (VoxelBusters.EssentialKit.cpp:102)
8   UnityFramework                    0x000000011013805c GameServices_CreateLeaderboard_m0ED2C34A7099CA751BDC7E03645CF72C8CB0862A + 312 (VoxelBusters.EssentialKit.cpp:18836)
9   UnityFramework                    0x000000011013925c GameServices_ReportScore_mF223314767B2F89665DD80B616F496D845AFC542 + 32 (VoxelBusters.EssentialKit.cpp:19465)
#

I will say the crash wasn't consistent, when I reported to the same leaderboard after restarting the app, the score went through fine.

lunar vigil
#

@faint reef This is definitely helpful.
Can you please share the device hardware model and os version?

vivid stream
#

I now got the crash (actually a beta tester did) for properly set up boards that usually work. My best bet is that GameCenter logged out for some reason, but GameServices did not catch it. This is on an iPad12,1 running iOS 18.5.

vivid stream
#

`void* NPRetainWithOwnershipTransfer(id object)
{
if (object == nil)
return nil;

void*   objectPtr;
bool    isNew;
AddObjectReference((__bridge void*)object, &isNew);
if (isNew)
{
    objectPtr   = (void*)CFBridgingRetain(object);
}
else
{
    objectPtr   = (void*)CFRetain((__bridge CFTypeRef)object);
}

#if NATIVE_PLUGINS_DEBUG_ENABLED
NSLog(@"[NativePlugins] Retaining ownership for pointer %@.", objectPtr);
#endif

return objectPtr;

}`

#

I added a nil check to the method in NPBindingHelper.mm which causes an exception in Unity, instead of a hard crash, which I can handle with a try/catch.