New resource delivery system for Emscripten port #352
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resource files are no longer packaged and preloaded all in advance. Instead, they are downloaded while the game is running.
The implementation is less than ideal, but it works. Resources are requested on demand and cached into IDBFS. Unfortunately, since the resource system was not designed with web-style asynchrony in mind and we aren't ready for threads either, we have no way to do any useful work while a required file is downloading. To somewhat offset that, we also pre-fetch files that were not requested yet. The pre-fetching is limited to 4 files at a time, which seems to be a reasonable compromise between throughput and cold-cache load latency on slow connections. Also unfortunately, it's dumb as rocks: we have no way of knowing which files we will actually be needing soon, so the pre-fetching is done in whatever order the files were indexed.
Possibly the easiest way to improve this system would be to bundle (and compress) all of the tiny text files together to alleviate the overhead of hundreds of HTTP requests.