itisnajim / SocketIOUnity

A Wrapper for socket.io-client-csharp to work with Unity.
MIT License
419 stars 71 forks source link

IL2CPP Problem Resolution #77

Open ZhouXinyu001 opened 11 months ago

ZhouXinyu001 commented 11 months ago

I have found the reason why IL2CPP faster runtime cannot run.

It is mainly due to the fact that System.Reactive.Subjects.Subject cannot be translated properly when full generic sharing is not supported in IL2CPP.

It is expected that UniRx (https://github.com/neuecc/UniRx) can be used to solve this issue.

Error code Location: image

Error Stack: System.ExecutionEngineException: Attempting to call method 'System.Reactive.Concurrency.CurrentThreadScheduler::Schedule<System.ValueTuple2[[System.Action1[[System.ValueTuple2[[System.Reactive.Producer2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Reactive.Linq.ObservableImpl.AsObservable1+_[[System.String, mscorlib, Version=[4.0.0.0](http://4.0.0.0/), Culture=neutral, PublicKeyToken=b77a5c561934e089]], System.Reactive, Version=[5.0.0.0](http://5.0.0.0/), Culture=neutral, PublicKeyToken=94bc3704cddfc263]], System.Reactive, Version=[5.0.0.0](http://5.0.0.0/), Culture=neutral, PublicKeyToken=94bc3704cddfc263],[System.Reactive.Linq.ObservableImpl.AsObservable1+[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], System.Reactive, Version=5.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.ValueTuple2[[System.Reactive.Producer2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Reactive.Linq.ObservableImpl.AsObservable`1+[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], System.Reactive, Version=5.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263]], System.Reactive, Version=5.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263],[System.Reactive.Linq.ObservableImpl.AsObservable`1+_[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], System.Reactive, Version=5.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]>' for which no ahead of time (AOT) code was generated. Consider increasing the --generic-virtual-method-iterations=1 argument

itisnajim commented 9 months ago

Thank you for reporting this issue. I'm currently tied up with other commitments if you or the community find a fix, please consider submitting a pull request. Your contribution is highly valued.

noobogami commented 8 months ago

in IL2CPP build socket.io couldn't connect to server without any error but when I updated my unity from 2021.x to 2022.3.20, problem fixed.

Fafou commented 5 months ago

Hi, Big thanks for this bug search.

I did not do a deep search in socket.io client source code, but between the 3.0.6 and 3.0.8 versions they did some refactoring and they do not use Subscribe anymore. So this pending pull request, updateing library from 3.0.6 to 3.0.8, seem to fix this issue.

I changed my package.json in unity to use the forked repository and I'm now able to connect to my server in android.

EwertonLug commented 5 months ago

Hi, Big thanks for this bug search.

I did not do a deep search in socket.io client source code, but between the 3.0.6 and 3.0.8 versions they did some refactoring and they do not use Subscribe anymore. So this pending pull request, updateing library from 3.0.6 to 3.0.8, seem to fix this issue.

I changed my package.json in unity to use the forked repository and I'm now able to connect to my server in android.

This fix my problem too. Thanks!