WebGLThreadingPatcher icon indicating copy to clipboard operation
WebGLThreadingPatcher copied to clipboard

WebGL build fails with this package installed

Open AgainJBC opened this issue 1 year ago • 9 comments

Hi, I have unity 2023.2.9f1 and when I install WebGLThreading Patcher my WebGL build fails with the following error:

IL2CPP error for method 'System.Void System.Threading.<>_GenericWrapper::.ctor(System.Action1<T>)' in assembly '[projectpath]\Library\Bee\artifacts\WebGL\ManagedStripped\mscorlib.dll System.InvalidOperationException: Attempting to return from void method 'System.Void System.Threading.<>_GenericWrapper::.ctor(System.Action1<T>)' when there are values on the stack. Is this invalid IL code

Any ideas how to fix that ?

AgainJBC avatar Feb 24 '24 15:02 AgainJBC

Here's the fix.

https://github.com/RageAgainstThePixel/com.utilities.async/pull/13/files#diff-3c2a243f73942f45e9f92906a31b6ad885205bae85be6e88bc4c90cae5754075R165

StephenHodgson avatar Feb 24 '24 20:02 StephenHodgson

Here's the fix.

https://github.com/RageAgainstThePixel/com.utilities.async/pull/13/files#diff-3c2a243f73942f45e9f92906a31b6ad885205bae85be6e88bc4c90cae5754075R165

Cool thanks !

AgainJBC avatar Feb 25 '24 22:02 AgainJBC

Here's the fix.

https://github.com/RageAgainstThePixel/com.utilities.async/pull/13/files#diff-3c2a243f73942f45e9f92906a31b6ad885205bae85be6e88bc4c90cae5754075R165

@StephenHodgson Well ... not sure what the fix should be ? I installed your Utilities.async package but it doesnt fix the WebGL Threading patcher build error .... so I thought it is more like a replacement than fix, uninstalled WebGL Threading patcher, but then await methods are not awaited in webGL

AgainJBC avatar Mar 04 '24 20:03 AgainJBC

Here's the fix. https://github.com/RageAgainstThePixel/com.utilities.async/pull/13/files#diff-3c2a243f73942f45e9f92906a31b6ad885205bae85be6e88bc4c90cae5754075R165

@StephenHodgson Well ... not sure what the fix should be ? I installed your Utilities.async package but it doesnt fix the WebGL Threading patcher build error .... so I thought it is more like a replacement than fix, uninstalled WebGL Threading patcher, but then await methods are not awaited in webGL

Really? Bc I ran into the same exact build error, and needed fixing for one of my other popular packages.

Unity engineer also gave me the fix

StephenHodgson avatar Mar 04 '24 20:03 StephenHodgson

@StephenHodgson Thank you for the fast response. Just to be sure that I understand everything well ... installing your package should fix that WebGL Threading Patcher right ? So the install process should be:

  1. Install WebGL Threading Patcher ( will throw that IL2CPP error )
  2. Install Utilities.Async

... done, error goes away and the build is now flawless ? Does the order of those 2 steps matter ? Nothing else needs to be done/setup and the build should now work with WebGL Threading Patcher installed ?

AgainJBC avatar Mar 04 '24 22:03 AgainJBC

@StephenHodgson Thank you for the fast response. Just to be sure that I understand everything well ... installing your package should fix that WebGL Threading Patcher right ? So the install process should be:

  1. Install WebGL Threading Patcher ( will throw that IL2CPP error )
  2. Install Utilities.Async

... done, error goes away and the build is now flawless ? Does the order of those 2 steps matter ? Nothing else needs to be done/setup and the build should now work with WebGL Threading Patcher installed ?

You only need Utilities.Async from OpenUPM. WebGL thread patcher is already part of my package as post build step.

StephenHodgson avatar Mar 04 '24 22:03 StephenHodgson

@StephenHodgson Ok so I would call it more of a replacement than a fix. Do I need any tweaks to my code for it to work ? As typicall "var result = await function();" seems to never end awaiting for some specific methods ( Evm.ContractSend in that case ) which are probably interacting with javascript or something under the hood. Hard to say as its compiled into dll.

But the exact same line of code finished correctly on older unity version with original WebGL Threading Patcher. I had to switch to more recent version because of other WebGL stuff support unfortunatelly.

AgainJBC avatar Mar 04 '24 23:03 AgainJBC

? As typicall "var result = await function();" seems to never end awaiting for some specific method

Sounds like those are blocking calls.

exact same line of code finished correctly on older unity version with original WebGL Threading Patcher

Sure but keep in mind, according to the Unity engineer, the call stacks have always been misaligned and broken. Which was causing some other undefined behavior. So I guess pick your poison.

StephenHodgson avatar Mar 05 '24 13:03 StephenHodgson

@StephenHodgson Ok, thank you for your time and willingess then.

AgainJBC avatar Mar 05 '24 18:03 AgainJBC