Utilities WebRequestRest Rest.GetAsync() Causes Unity To Hang
Describe the bug
When Rest.GetAsync(downloadUrl, readResponseData: true) is called with a download uri for a 79.9KB OneDrive file, Unity hangs for about a minute, with both the running player and Unity Editor completely frozen.
To reproduce
- Generate a download uri for a file (the larger the file, the longer Unity hangs). I used a download uri for a OneDrive file.
- In a Unity scene, include a script with an async function with the lines: (i) Response response = new Response(); (ii) response = await Rest.GetAsync(downloadUrl, readResponseData: true);
- Run the scene so that the async function is called. When the program executes line (ii) from Step 2, Unity hangs.
Expected behavior
In MRTK v2.7.3, Unity does not hang, but after updating to v2.8.0 it does.
Setup
- Unity Version [2020.3.35f1]
- MRTK Version [v2.8.0]
Target platform
- HoloLens 2
Additional context
In Rest.cs, line 375/376 there used to be an async call when creating a Response to return if readResponseData is true, and now there is a different call.
@t-mklein Hello! Yes, you are right, I looked at the changes, they really were!
Thank you!
@keveleigh @davidkline-ms Hello! I will post a PR with changes later
I'll take a look at the PR tomorrow, but I'll say we intentionally reverted some of these changes in 2.8.0 because the async calls didn't resolve in-editor. See #10406 for more info. @davidkline-ms and I are going to try to support both cases.
@keveleigh Thank you.
I looked and checked. Yes, that's right. DevicePortal is now working correctly with the suggested changes.
So both ways work. If you see a counter case, please let me know