Client freezes with String Loading
available in future release
nuruwo
Summary: Client freezes when using String Loading under certain conditions.
Phenomenon:
When downloading a binary file using StringLoading, the VRChat client freezes for about 1 second immediately after the download (just before OnStringLoadSuccess is called).
The size of the binary file at this time is 44MB. The freeze time is proportional to the file size.
Comparison:
Unlike the binary file, the freeze does not occur when a text file is downloaded.
The size of the text file is 59 MB.
Terminology explained here:
Binary file: A file whose characters cannot be decoded as UTF8.
Text file: A file whose characters can be decoded as UTF8.
Test worlds:
You can test the failure in the following worlds.
The worlds have two buttons to download binary files and text files, and an image of the U# code (also attached this post).
(The left button does not cause the freeze. The right button does.)
Backgrounds:
The gimmick I create often handle about 50MB of data.
The gimmick downloads the data as text files currently. Binary data is processed by converting it to Base64 strings. However, if the binary data could be handled as is, it would be very useful because it would reduce the amount of space and remove Base64 processing.
Therefore, I tried downloading the binary file and changing it to read in ResultBytes, but this caused a freeze.
This freeze is not acceptable for world users, and until it is fixed, I cannot handle binary data processing directly.
Suggested fix:
My guess is that the problem is occurring because stringify the binary file is running just before OnStringLoadSuccess is called.
Therefore, I propose two ways to solve this problem.
- Do not stringify the binary data (Encoding.UTF8.GetString()) until calling result.Result.
In other words, if only result.ResultBytes is called, the stringify is not performed.
- Do the stringing process in a new thread, not in the main thread of VRChat.
Log In
This post was marked as
available in future release
miner28_3
yay
Prismic247
Have likewise run into this problem. I have a 66MB string that I've managed to reduce down to 37MB by utilizing bit-packing and LZW compression, which saves on both bandwidth as well as overall download time for users on slow connections. But as described above it completely freezes up the game for a few seconds when UTF8 invalid characters are included. This issue is the main bottleneck preventing me from going forward with the improvement.
This post was marked as
tracked
naqtn
I discussed with nuruwo-san, the reporter, so I would like to comment a bit.
* In this post, a "binary file" contains "invalid byte sequences cannot be translated into valid Unicode characters" (citing from https://learn.microsoft.com/en-us/dotnet/standard/base-types/character-encoding ). So, maybe the issue means that when the fallback occurs, it takes too much time to relate to the main thread.
* Though nuruwo-san mentioned the file size (44MB), the size is not essential for the issue to occur. It is just supplement information for the 1-second freeze. A small file may also cause the issue, though it may not be noticeable.
* The feature name is "String Loading" ( https://creators.vrchat.com/worlds/udon/string-loading/ ), and some think it implies using text files. But the API description of
Get ResultBytes (byte[])
says, The raw data that was downloaded as a byte array. You can use System.Text.Encoding on this to decode a string in a custom format.
So, this use case with binary files is also an intended way to use it.