Hello, when building for webgl in 2023.2.20 or in unity 6 I am getting this error. There does not seem to be a way to resolve it
C:\Program Files\2023.2.20f1\Editor\Data\il2cpp\build\deploy\il2cpp.exe @Library\Bee\artifacts\rsp\16175507190455084649.rsp
Error: IL2CPP error for method 'System.Void System.Threading.<>_GenericWrapper::.ctor(System.Action`1<T>)' in assembly 'C:\Users\TJ\wkspaces\far_3_metaverse\Library\Bee\artifacts\WebGL\ManagedStripped\mscorlib.dll'
System.InvalidOperationException: Attempting to return from void method 'System.Void System.Threading.<>_GenericWrapper::.ctor(System.Action`1<T>)' when there are values on the stack. Is this invalid IL code?
at Unity.IL2CPP.MethodBodyWriter.WriteReturnStatement() + 0x4ea
at Unity.IL2CPP.MethodBodyWriter.ProcessInstruction(Node, InstructionBlock, ResolvedInstruction) + 0x85e
at Unity.IL2CPP.MethodBodyWriter.GenerateCodeRecursive(Node, ReadOnlyDictionary`2) + 0x827
at Unity.IL2CPP.MethodBodyWriter.Generate() + 0x72f
at Unity.IL2CPP.CodeWriters.CodeWriterExtensions.WriteMethodWithMetadataInitialization(IGeneratedMethodCodeWriter, String, Action`2, String, MethodReference, WritingMethodFor) + 0x2ef
at Unity.IL2CPP.MethodWriter.WriteMethodDefinition(AssemblyWriteContext, IGeneratedMethodCodeWriter, MethodReference) + 0x40a
at Unity.IL2CPP.SourceWriter.WriteTypesMethods(SourceWritingContext, IGeneratedMethodCodeWriter, TypeWritingInformation&, NPath, Boolean) + 0x560
at Unity.IL2CPP.SourceWriters.SourceWriterBase`2.WriteItem(StreamWorkItemData`2) + 0x1fc
at Unity.IL2CPP.Contexts.Scheduling.Streams.FileLevelParallelStreamManager`3.WorkerWriteItemsToFile(WorkItemData`2 data) + 0x1ed
at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.WorkerLoop(Object data) + 0x60e
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
I have attempted the steps recommended, and have ensured that
Your machine meets the minimum system requirements: Unity - Manual: System requirements for Unity 2023.1
You have admin permissions on your device.
You are using the latest version of the Unity Hub: Start Your Creative Projects and Download the Unity Hub | Unity
You have downloaded and installed the Unity Hub and Editors to your default C drive, rather than an external hard drive.
I have also uninstalled all unity versions and unity hub, then restarted my pc and reinstalled. The issue persists though
There are currently no community posts on the specific error. Is there a way I can reach out to someone on the team to resolve this?
This makes me cautious because System.Threading is off-limits for WebGL. I believe that goes for async/await too or at least there are some restrictions about that.
Do you have scripts that use System.Threading or async/await?
If you import assets or external libraries that are not expressly supporting Unity WebGL builds these may also cause issues.
The error looks somewhat like an async/avoid method signature, ie “public void Task Something()”
Which is okay to use as long as you don’t use multithreading or Task.Delay
See: Async/await and webgl builds
so thats a good sign, cos ive had hella problems if you enable the multithreading…
but it does sound like there are some awaits or task.delays or something in the code, it may of course not be in your code, it could be something you bought… and those are the issue because they use threading
Sounds good, Ill double check to remove any. Is it possible that there were always some in the code and in the older version of unity it would compile fine, but with the newer versions they are more strict and will throw this error
Yes, I have a game on my website built in an older version of unity which uses awaits, and frankly works a charm… however, the preview seems to be sensitive to it
Hmm, even building including only an empty scene still gives the build error, would I have to remove all async logic from the project entirely in order to be able to build it?