Hi Unity community,
I’ve encountered an issue with UgcService.Instance.CreateContentAsync when running my Unity project on WebGL. The code works perfectly in the editor but fails during execution on WebGL. Here’s the detailed description of the problem:
Problem Overview:
When executing the following coroutine:
Task<Content> content;
try
{
content = UgcService.Instance.CreateContentAsync(new CreateContentArgs(
name,
$"MicroGame: {selectedMicrogame} ModuleId: {selectedModuleId}",
contentStream
)
{
IsPublic = true,
Metadata = newMetadata.ToJson()
});
}
catch (Exception e)
{
Debug.LogError(e.Message);
yield break;
}
I get the following error on WebGL:
Invoking error handler due to
RuntimeError: null function or function signature mismatch
at il2cpp::icalls::mscorlib::System::Runtime::InteropServices::Marshal::PtrToStructure
The error appears after the coroutine logs some extra info, indicating that the upload process is partially initialized but fails before completion.
Observations:
- The issue is specific to WebGL; the same logic works without any problems in the Unity Editor.
- The coroutine halts after a few frames, not directly.
- It seems the error originates from UgcService.Instance.CreateContentAsync.
Questions:
- Are there known limitations with UgcService.Instance.CreateContentAsync on WebGL?
- Could this be related to threading or memory management on WebGL, considering the use of Task and MemoryStream?
- Are there any recommended workarounds or best practices to address this issue on WebGL?
Any insights or guidance would be greatly appreciated!
Thanks in advance for your help.