You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 25, 2019. It is now read-only.
Our current Unity implementation for making web requests is quite inefficient. Let's find ways to improve it.
Possible Inefficiencies
Web requests are using coroutines. Each coroutine allocates memory on the heap (every tick). Requesting hundreds of tiles will lead to "massive" GC spikes.
Requests are not threaded.
Each low level object that wants to make a request needs a FileSource. This is often duplicated between objects. Unknown what the correct solution is, but probably depends on our threading options.
Currently, response errors are handled as strings. String compares are expensive and prone to error.
Other Considerations
Coroutines do not operate (sans hacks) at edit time. This makes it difficult to perform requests outside of "play" mode.
I expect developers to hit their rate limits quite easily. It would be nice if we offered a convenience layer to automatically handle the distribution of requests or re-queuing of requests on rate limit exceeded errors. Of course a lot of developers will implement their own version of this to suit their needs, but ours may serve as a solid starting point.
Web requests should have timeouts (I have, on occasion, observed requests never providing a response).
Possible Solutions
Use something like More Effective Coroutines (note: unsure if this will also solve the editor coroutine issues, but it could since you don't need to inherit from MonoBehaviour).
TL;DR
Our current Unity implementation for making web requests is quite inefficient. Let's find ways to improve it.
Possible Inefficiencies
FileSource. This is often duplicated between objects. Unknown what the correct solution is, but probably depends on our threading options.Other Considerations
Possible Solutions
Next Steps
It would be great to have a C# expert (@BergWerkGIS, I'm looking at you) experiment in this area.
/cc @mapbox/games