I have upgraded Unity to 2022.3 but my UnityWebRequests slowed down extremely. If I make a few requests it does not matter but if I make 30 requests, the response time is around 10 times slower in Unity 2022 and 2023.
I opened a fresh new project and run this code in four Unity versions. In Unity 2020 and 2021 the completion time is around 1.6 seconds but for Unity 2022 and 2023 it takes around 17 seconds. Is something changed in Unity 2022 or am I missing a setting or something?
Thanks
using System.Collections;
using UnityEngine;
using UnityEngine.Networking;
public class TestUnityWebRequest : MonoBehaviour
{
[ContextMenu("Test UnityWebRequests")]
void TestUnityWebRequests() {
for (int i = 0; i < 30; i++) {
StartCoroutine(MakeWebRequest());
}
}
IEnumerator MakeWebRequest() {
using var request = UnityWebRequest.Get("https://someexamplewebsite.com");
var stopWatch = new System.Diagnostics.Stopwatch();
stopWatch.Start();
yield return request.SendWebRequest();
stopWatch.Stop();
Debug.Log($"Completed in {stopWatch.ElapsedMilliseconds} miliseconds ");
}
}
Could you make it use Start instead of menu, in order to rule out any Editor play mode on/suspended. Even better to use Standalone player.
Another thing worth to try is using http instead of https, to rule out TLS.
I’m not aware of performance issue, certainly not of such magnitude.
Hi, Thanks for the reply.
I used Start and made a standalone build with http instead of https (There is a player setting in Unity 2022 “Allow downloads over http”, this should be enabled to use http).
This decreased the time in Unity 2022 from 17 to around 3 seconds(still behind 2021), but I am using Playfab as backend platform and it uses https, so I can’t use http.
In Unity 2021 it is still around 1.7 seconds.
Not: These times of course change according to the website called, but I made the tests with same website.
Also I noticed that, if I make a few batch requests, like 30 and again another 30, only the first batch is slow.
Second and other batch requests are around 0.7 to 0.4 seconds both in 2021 and 2022.
The is expected - connection reuse. So, establishing a connection is the problem, with TLS being problematic in particular. Could you report a bug for this?
I can confirm this issue happen from upgrading from version 2021 to any version of 2022 where concurrent https requests from playfab does show a noticeable different in respond time from around 1.3s to 10 second,
If one request send, it work perfectly fine it depend more than one request at same time and it start to delay down badly.