New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unity 2021.2 - IIl2CppProcessor' is obsolete #2
Comments
I spent some time researching this bug, wasn't able to solve it, but here are my findings: You can change what
But, it still fails at build time due to .net being upgraded from version 4 to version 5. This has changed some of the classes that this code is trying to patch, so it fails doing the patching. |
Thanks for the feedback! |
Hi. Any status for this? |
You could use this script in the meantime: https://github.com/transformsai/UnityWebGLThreadingFix/blob/main/Runtime/WebGLThreadPoolPumper.cs |
@MHDante That script works really well, given its simplicity. EDIT: my bad - reported crash was a bug on my side |
I have made changes to the plugin. now it will not use IIl2CppProcessor. also, some minor codegen changes to support newer Unity versions |
Hey. Sorry for bothering again. Thanks for looking into it, but have you tried with 2021.3.4f1, 2021.3.5f1, 2022.1.7f1, 2022.2.0a17? I see you mention Unity 2021.2.0, so would you recommend downgrading to it to make this work? I'm currently using 2021.3.5 Also, would this work with UniTask (particularly the SwitchToThreadPool/SwitchToMainThread) and regular Task? If you could check this code sample and confirm, I'd be very grateful 🙏 : Update: I used 2021.2.19f1 and still can't get past the compilation part. Were you able to compile with 2021.2.x after you added the timer patch? I'm just looking to find any version that could build the project. |
it's interesting issue. I will try to reproduce it locally
I mentioned 2021.2 just becouse it was version from issue title. but in fact I tested on latest 2021.2 and 2021.3. so I don't think that downgrade will help |
Thanks. Looking forward to it! At this point, I downgraded all the way to 2020.1.0f1 (ofc, it's not a solution, because downgrading doesn't work in general, with the prefabs and all that). Compilation passes, but then I get this. |
Both my solution and Volodymyr's (use one, not both) are meant to allow short tasks that have been added to the thread pool to execute on the main thread. This is primarily because there are many c# libraries that assume the easy availability of a thread pool (like grpc). Neither solution allows for true concurrency on webgl. The , Due to a bevy of issues involving memory sharing across threads, the emscripten memory model, the .Net threading/memory model and Il2cpp, it will be a while until unity can make use of emscripten threads to allow C# threads to function. Due to this, unless you are writing c++ plugins and have a thorough understanding of emscripten's peculiarities. I would recommend leaving |
Oh, that's so good to know! Then I don't have to worry about downgrading. Thanks a lot for clarifying it with such great detail! 🙏 What puzzles me is, with any of your 2 approaches (Unity 2021.3.5f1), the execution path just stops at this code:
The way I'm calling it is via:
I'm using Tasks (and UniTask on Unity side) mainly because some libraries only offer Async APIS, including a library that uses .net Web requests and web clients, and some Google Auth/Storage libs (although on WebGL the Google APIs are not essential) |
the problem is not threading but if you want to use UnityWebRequest in async/await manner, then you can add code like this to your project public struct AsyncOperationAwaiter : INotifyCompletion
{
private AsyncOperation _asyncOperation;
public bool IsCompleted => _asyncOperation.isDone;
public AsyncOperationAwaiter(AsyncOperation asyncOperation) => _asyncOperation = asyncOperation;
public void GetResult() { }
public void OnCompleted(Action continuation)
{
_asyncOperation.completed += _ => continuation();
}
}
public static class AsyncOperationAwaitable
{
public static AsyncOperationAwaiter GetAwaiter(this AsyncOperation operation)
{
return new AsyncOperationAwaiter(operation);
}
} it will allow you to write |
Oh, good, there's some light here. So after all threads would probably work fine, and I have to just hunt these points in the app that use WebClient/WebRequest. Still kind of a blocker for my project. Basically, I have to adapt my own libraries so that I pass them a "Downloader" interface that they'll use to download stuff, and for 3rd party libraries that I don't have control over - not sure if I can do something about it. |
This is out of the scope of this ticket, but I wrote an HTTPHandler for WebGL you can find here: https://github.com/transformsai/UnityWebGLHttpHandler It's undocumented and based on MonoWASM's Http web handler. It uses fetch for web requests. I would recommend using UnityWebRequest if you can, however. |
Following-up my previous message, I confirm all works well. So to clarify, there are no real threads (and please correct me if I'm wrong), but async/await works fine. I also posted this on a related thread on Unity forum. |
Packages\WebGLThreadingPatcher\ThreadingPatcher\Editor\WebGLThreadingPatcher.cs(13,37): error CS0619: 'IIl2CppProcessor' is obsolete: 'The IIl2CppProcessor interface has been removed from Unity. Use IPostBuildPlayerScriptDLLs if you need to access player assemblies before il2cpp runs.'
The text was updated successfully, but these errors were encountered: