question

juergenoswald avatar image
juergenoswald asked

IndexOutOfRangeException when calling UpdateUserData via UnitySDK

Hello,

I'm using the Unity integration of playfab. I'm currently on Unity 2019.3.1f1 with PlayFab SDK 2.78.191121. Rarely I receive the following exception as error response from calling PlayFabClientAPI.UpdateUserData:

Unhandled error in PlayFabUnityHttp: System.IndexOutOfRangeException: Index was outside the bounds of the array.
  at PlayFab.Internal.PlayFabUnityHttp+<Post>d__12.MoveNext () [0x001c3] in C:\Users\x\Documents\y\z\Assets\PlayFabSdk\Shared\Internal\PlayFabHttp\PlayFabUnityHttp.cs:168 
UnityEngine.Debug:LogError(Object)
Rarebyte.Common.<>c__DisplayClass11_0:<Save>b__1(PlayFabError) (at Assets/Scripts/SaveGame/PlayFabPlayerDataManager.cs:113)
PlayFab.Internal.PlayFabUnityHttp:OnError(String, CallRequestContainer) (at Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:275)
PlayFab.Internal.<Post>d__12:MoveNext() (at Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:201)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

The call works fine most of the time, but every once in a while (haven't found a pattern yet) the exception is thrown. Any hint on why this can happen? Looking at the SDK release notes updating won't include any fixes which is why I'm staying on the old version so far.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Seth Du avatar image
Seth Du answered

Please understand that issues that cannot be reproduced consistently are hard to troubleshoot. How often does this issue occur? My suggestion is upgrading SDK to the latest version and try to do a Fiddler network capture to see if the packet is corrupted.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Tihan Seale avatar image
Tihan Seale answered

I can confirm that this is happening in the latest SDK release. My game saves every minute. From the console log output you can see that it errors every 5th time or so.

screen-shot-2020-07-21-at-82844-am.png

,

I can confirm this happens quite often. My game saves data every minute. You can see from my console log output that this happens every 5th attempt or so. No rhyme or reason that I can tell.


1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Seth Du avatar image Seth Du ♦ commented ·

I have checked the source code in SDK and had a further discussion with the team. The root cause is still the packet loss due to your network issue.

The error is reported on Line 170 of PlayFabUnityHttp.cs file, which is Boolean check of:

bool isGzipCompressed = responseBytes != null && responseBytes[0] == 31 && responseBytes[1] == 139;

This part of code verifies if the byte data is a valide Gzip file. according to the official documention:

 These have the fixed values ID1 = 31 (0x1f, \037), ID2 = 139
            (0x8b, \213), to identify the file as being in gzip format.

However, the SDK doesn't handle the condition when responseBytes doesn't have the second element in the array.

My suggestion here is to add few codes above this sentence where we can check if the responseBytes have a second element or directly output the details in responseBytes. Would you share the output data with us?

Looking forward to your feedback and after that, I will try to consult the SDK team to see if we can polish up the robustness of the current version of SDK.

0 Likes 0 ·
tomtominc1 avatar image
tomtominc1 answered

@SethDu Has this been resolved? I seem to be getting this error as well.

Failed to send session data. Error: /Event/WriteEvents: Unhandled error in PlayFabUnityHttp: System.IndexOutOfRangeException: Index was outside the bounds of the array. at PlayFab.Internal.PlayFabUnityHttp+<Post>d__12.MoveNext () [0x001c3] in /Users/thomasferrer/Documents/Development/CreaturesOfAether/Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:170 UnityEngine.Debug:LogWarning(Object) PlayFab.Public.ScreenTimeTracker:EventSentErrorCallback(PlayFabError) (at Assets/PlayFabSdk/Entity/ScreenTimeTracker.cs:203) PlayFab.Internal.PlayFabUnityHttp:OnError(String, CallRequestContainer) (at Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:277) PlayFab.Internal.<Post>d__12:MoveNext() (at Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:203) UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at /Users/builduser/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17)

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Seth Du avatar image Seth Du ♦ commented ·

Please understand that this issue is more like a feature request and the work around is to handle the HTTP error in your client, then try to resend the API call.

Please feel free to send a thread on the Feature Request forum.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.