-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Using SignalR core with Unity and IL2CPP (AOT) #12102
Comments
I don't currently have unity on any of my work machines, but I might try this out on a personal machine to see if I can figure anything out. Meanwhile, is it possible for you to grab the network trace so we can verify what payload the client is receiving from the server? |
@BrennanConroy I am not sure how to take a network trace. I set both of my server and client to verbose debug logging. The logs are included in the git repo above (server and client) If I can provide better traces please let me know how :) Also of note, when I build with the mono runtime the handshake succeeds. I would guess this is a client side error instead of server side. Thanks for the help! |
@thorgeirk11 We have some guidance on network traces here: https://docs.microsoft.com/en-us/aspnet/core/signalr/diagnostics?view=aspnetcore-2.2
This indicates that the response from the server is incorrect (missing a required property). Can you provide a sample response from the |
Unity apparently doesn't play well with fiddler so after testing out different tools I managed to get a network trace through WireShark. See NetworkTraces.zip As far as I can see both the IL2CPP and Mono receive the same response. Request:
Response:
Can you investigate if the deserialization mechanism is AOT (IL2CPP) compatible? Please let me know if I can provide more info, check out the git repo for my simple project that reproduces this error. |
I haven't gotten the chance to try out the repo project yet (thanks for that btw!). I did take a glance at the project though, and how does it know what version of the client to download and use? Also, could you try to replace the json protocol to use Newtonsoft and see if it works with that? Here are the steps to switch to newtonsoft, note you need to add another package (for the link.xml file). |
@thorgeirk11 any update/success connecting from IL2CPP Unity client? Sort of having the same issue ages ago and decided to use a plugin from the AssetStore by then. But really looking fwd to using asp.net core SignalR client straight into Unity instead. |
We would also really like to use the official signalR client in unity |
@crevelop Nope not yet, I guess the problem would be solved by switching out the serializer for an AOT friendly implementation. I have not spent much time on it. The game I am working on is on standalone and currently using Mono. However, in the coming months, I would like the option to switch to IL2CPP to export to WebGL. |
You may need to use Linker.xml to avoid field stripping |
Check out my repo. I induded a Linker.xml for all of the SignalR binaries. |
Hello @thorgeirk11 ! Is the SignalR core running with Unity finally ? I would like to integrate it on Hololens but at this time I've not found any documentation to do this. You are my last hope :) |
@samoteph It works out of the box for any platform that does not require IL2CPP. |
We also encounter this problem : ( |
Did you have any luck with messagepack? |
Finally, I rewrote my own sharing service with WebSocket as a communication channel |
Anyone get messagepack working? I added an entry to my link.xml file to the Microsoft.AspNetCore.SignalR.Protocols.MessagePack.dll, but I get missing constructor error. |
Yeah, we are currently using Messagepack successfully |
@thorgeirk11 great to hear - to confirm: are you using it with IL2CPP (iOS)? After downloading v3.1.2, I have extracted the netstandard2.0 I then added an additional entry in my Yet when I run it on a device, I get the following error:
Could you list the steps you guys are taking to get it working in your project? My link.xml file:
|
Ah I have yet to Port my project over to IL2CPP however I assume to get that working you would have to pre-compile a message pack parser. |
Works fine under mono - but iOS now only allows IL2CPP which is the stumbling block. Could you advise on process to |
Hello, |
@youtpout - mind sharing more details about your working setup? E.g. the link.xml file, how you configured the dlls, etc. Would love to get this working for us too. =) |
Exemple of project who works with enum in editor but not in IL2CPP mobile @jwittner see UnityEnum, you have plugins folder with all files who works for me |
@youtpout how do you workaround the fact that sígnalr only works with 11.0.0 version of newtonsoft.json? |
@xabio I use v12 without problem, see my project test plugins folder |
@youtpout And how did you managed to do that? last version of signalr depends on netwonsoft 11.0.0 right? |
@xabio My bad, SignalR use textjson I think I include Newtosoft because I use HttpClient for rest api call on my real project. |
Has anyone solved the problem with IL2CPP and SignalR Core? |
I can use SignalR Core with IL2CPP, the only problem for me is to use Messagepack... See my project SignalREnum and UnityEnum |
SignalR uses MessagePack in an unsupported way on Unity + IL2CPP: both of which are unsupported when building with IL2CPP. 1.See the lines on MessagePack's repository: 2.Notice that the SignalR code is calling both of them: https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/common/Protocols.MessagePack/src/Protocol/DefaultMessagePackHubProtocolWorker.cs 3.SignalR won't work with MessagePack built with IL2CPP
|
@BrennanConroy @davidfowl this issue is still causing problems. @michalpypek has digged into the cause of the problem. Can you please take a look at this issue before .net 6 arrives. Our game is using SignalR and MessagePack to great effect and this issue is preventing us form using this stack for an IL2CPP mobile game. |
We never attempted to make unity work with the default SignalR client, especially not with IL2CPP. It's not on the list for .NET 6 and we're near the end. Unless it's a trivial fix, this won't be something that we work on for the upcoming release. |
Finally I buy a plugin on asset store for call SignalR with Messagepack on IL2CPP. |
@davidfowl we would highly appreciate you giving it a chance. This issue doesn't sound as a major effort. The heavy lifting has already been done the MessagePack Generator. Can you have someone investigate if this could be fixed in the coming release? |
If there is a trivial fix, then someone could try it out by copying the MessagePackHubProtocol and worker, modify it with the fix, then try it out on the client. class MyCustomHubProtocol : IHubProtocol
{
// modified from MessagePackHubProtocol
} hubConnectionBuilder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IHubProtocol, MyCustomHubProtocol>()); We don't have any cycles during the last leg of .NET 6 to work on this. |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
We are also experiencing this issue as we try to build to Android in Unity IL2CPP |
MessagePack hub protocol also fails for .NET 7 NativeAOT. I guess the problem lies around here: dotnet/aspnetcore/.../src/Protocol/MessagePackHubProtocol.cs#L80-L113 |
I've got Next, I'll work on |
After implementing native invoke and send, another issue appears: #37340 |
Boilerplate for quick fix:
|
Check out FlyByWireless.SignalRTunnel.Client.Native and wegylexy/SignalRTunnel/tree/native#nativeaot-usage. Built-in types would work out-of-the-box. |
Any update? MessagePack still not work on il2cpp |
No update from my side
El El lun, 8 may 2023 a las 17:45, Lailore ***@***.***>
escribió:
… Any update? MessagePack still not work on il2cpp
—
Reply to this email directly, view it on GitHub
<#12102 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABMGSKOPZJ43AFYCWGMYKULXFEIJ7ANCNFSM4IBWGA4Q>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
for android : add this code to AndroidManifest.xml
for ios : add this code to Info.plist |
I am having a similar issue as #10080. I am using preview 6 of asp.net core SignalR client inside of unity and compiling with IL2CPP. I created a small git repo with the code I use to reproduce this issue
I am running into an exception when starting the connection:
The
connection.StartAsync
fails with the following exception:Unity's IL2CPP strips unused assemblies. It caused another issue but I fixed that by adding link.xml file. So the issue described here should not be affected by code stripping.
Here are the server and client traces.
The text was updated successfully, but these errors were encountered: