eos_plugin_for_unity icon indicating copy to clipboard operation
eos_plugin_for_unity copied to clipboard

Null characters are appended to the downloaded PlayerDataStorage file content

Open theo-rapidfire opened this issue 1 year ago • 3 comments

Describe the bug The PlayerDataStorage sample appends trailing null characters to the downloaded data. The Json library I'm using wasn't able to parse the string output as a result of this data.

To Reproduce Steps to reproduce the behavior:

  1. Add a breakpoint in EOSPlayerDataStorageManager.FinishFileDownload
  2. Open the PlayerDataStorage sample scene.
  3. Create a new Inventory file and select it.
  4. Press 'Refresh'.
  5. Inspect the data in the debugger, observe that there's a mismatch in the byte[] length and TotalSize property.

Expected behavior The downloaded string output should be identical to the last submitted string output.

Screenshots image image image

Desktop (please complete the following information):

  • OS: Windows x64
  • Editor
  • Unity Version: 2022.3.26f1
  • Plugin Version: 3.2.1

Additional context Workaround: Perform a .TrimEnd('\0') before using the file content.

I believe the issue could be caused by additional space in the transfer reserved for metadata, which is not written to this array image

theo-rapidfire avatar Jul 26 '24 15:07 theo-rapidfire

Hi @theo-rapidfire, thanks for the thoroughness with which you opened this issue. I'm glad that you've found a workaround that works for you. I'll get started on a fix today so we can make sure to include that in our next release - and I'll keep you posted on that here :)

paulhazen avatar Jul 26 '24 17:07 paulhazen

@paulhazen small thought on this. We should make sure that things put in to storage with null characters at the end are still allowed to do that, only trimming the ones that shouldn't be there.

WispyMouse avatar Jul 26 '24 17:07 WispyMouse

Brief update: this can be more properly resolved by changing the UTF8.GetString method call on line 490 to the following:

fileData = System.Text.Encoding.UTF8.GetString(transfer.Data, 0, (int)transfer.TotalSize);

I am in the process of confirming this - making sure the same thing isn't happening in the title storage sample as well. Once I confirm I'll open a PR to resolve the issue.

paulhazen avatar Jul 27 '24 00:07 paulhazen

As this issue's fix has now been merged into the stable branch, I am closing this issue.

paulhazen avatar Sep 02 '24 18:09 paulhazen