Null characters are appended to the downloaded PlayerDataStorage file content
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:
- Add a breakpoint in
EOSPlayerDataStorageManager.FinishFileDownload - Open the PlayerDataStorage sample scene.
- Create a new Inventory file and select it.
- Press 'Refresh'.
- Inspect the data in the debugger, observe that there's a mismatch in the
byte[]length andTotalSizeproperty.
Expected behavior The downloaded string output should be identical to the last submitted string output.
Screenshots
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
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 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.
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.
As this issue's fix has now been merged into the stable branch, I am closing this issue.