feat(scheme-handler): Improve memory usage & Range support #1481
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.
Platforms affected
iOS
Motivation and Context
Improve memory usage and support range requests for resources loaded via a custom scheme.
Description
Changed the implementation of CDVURLSchemeHandler to do file reading on a background thread in 4MiB chunks rather than trying to load entire files into memory. 4MiB should be sufficient for most HTML/CSS/JS files, while still being low enough to not cause iOS to freak out about memory usage.
Improved URL building for file paths to ensure that things like query strings don't end up affecting which file gets loaded from the filesystem. Closes GH-909.
Also, implement support for the Range header to load subsections of files (mostly used for audio/video files) to further improve memory usage. Closes GH-1033.
Testing
Existing tests pass. All content for the mobile spec testcase loaded properly with these changes.
Checklist