Closed zangetsu-oe closed 1 year ago
Thank you for taking the time to improve LibreMetaverse! We will review your contribution shortly.
Potentially fixed in 2f743ade0dd0d37912ab5715a1836eb77701f1a6
I tried out the changes, and it seems that #if NET_4_6 doesn't seem to be a working solution. I'm working towards using the pre-compiled net48 version of LibreMetaverse, which means that by the time Unity sees the .dll the #if NET_4_6 code has already been removed. I don't think we can rely on Unity's Compiler directives to solve this.
Let me add more information about what I have tried today. Scenario One - Basic Attempt:
Scenario Two - Remove the NET_4_6 directive:
#if NETSTANDARD2_1_OR_GREATER || NET48_OR_GREATER || NETCOREAPP3_1_OR_GREATER
if (Utils.GetRunningRuntime() != Utils.Runtime.Mono)
handler.MaxConnectionsPerServer = Settings.MAX_HTTP_CONNECTIONS;
#endif
Side note: I ended up trying a bunch of different stuff because I was getting crash to desktop from the compiled unity exe under several different scenarios, but that turned out to be something crufty with my environment. When I forced Unity to do a 'Clean' build, I got the above described behavior.
So my experimental observations are: Setting .MaxConnectionsPer Server does not work when LibreMetaverse is Compiled for .Net Framework 4.8 and the 4.8 assemblies are executed using the Mono Runtime.
This got me thinking about the System.Net.Http.dll. There are two different implementations of this, and I went looking at the source code for both trying to understand more: https://github.com/mono/mono/tree/main/mcs/class/System.Net.Http https://github.com/microsoft/referencesource/tree/master/System/net/System/Net/Http
And then I remembered that at some point I had delibrately added the Microsoft System.Net.Http implementation to the unity project, and went and looked and its not there anymore. I added it back to the unity project, but the Mono Runtime seems to have ignored its presence. So my best guess is that i knows better than we do that it wants to use its own internal implementation. That's fine. I don't need to argue with them.
At this point my full understanding is that the code probably doesn't even need the
#if NETSTANDARD2_1_OR_GREATER || NET48_OR_GREATER || NETCOREAPP3_1_OR_GREATER
since that will be true for all the LibreMetaverse.csproj Target Frameworks:
<TargetFrameworks>net48;netstandard2.1;net6.0;net7.0</TargetFrameworks>
As such, this revision seems to be working just fine for me: https://github.com/zangetsu-oe/libremetaverse-crystal-frost/commit/95457c151503fb6d4bbb6d3275e3023f93a5334a
I'm going to go ahead and make a pull request.
We have a Unity project that using the Mono Scripting Backend, and the .Net Framework API Compatibility Level. We are referencing the netstandard2.1 version of the compiled assembly in the Unity Project.
We have found that the SetupHttpCapsClient code in GridClient, attempts to configure MaxConnectionsPerServer. The MaxConnectionsPerServer property is not supported on all platforms. We have found that if we take out the code to set that on the HttpClientHandler, then the HttpClientHandler works just fine.
See: https://github.com/zangetsu-oe/libremetaverse-crystal-frost/commit/72c16209ae5c6fab31fb6e69a7c6e6b8b82ad4b1
I'm not sure what's the correct way to go about making this particular line conditional, otherwise I would have and included a pull request.
Advice is appreciated.