-
Notifications
You must be signed in to change notification settings - Fork 726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read media files more efficiently from zipped files #9761
Comments
A recent issue arose that showed the usefulness of this - when the H5P contains particularly large media files (whether because they are very long or have not been adequately compressed), this can cause excessive memory usage on memory constrained client devices, which will cause fflate to return undefined from its unzip command. Avoiding the loading and unzipping of large media files until they are demanded would help to prevent this issue, while still solving the issue that client side unpacking of H5P files was intended to resolve, which is to avoid the hundreds of HTTP requests initiated by a more naive implementation. |
I have a slight concern with this approach - mostly to do with the fact that the ability to generate an object URL for a MediaSource object, while currently widely supported, is being phased out and will be dropped in the future. MediaSource objects instead have to be programmatically attached via the
|
Spec has been updated to address @rtibbles' concerns here. |
Currently in our implementation of H5P, we load the entire H5P file into the frontend and then extract all its constituent files into
Blob
objects and create URLs for them.This has the distinct advantage of being very robust and being very predictable. It has the slight downside of causing incredibly long loading times for H5P files that contain large bundled media files such as video or audio.
Once #9157 has been implemented, it would be useful to augment the zip file wrapper in the following ways:
Instead of reading the entire file at once, first read the file metadata and listing in the zip file via a range request. To accomplish this we can use try to either directly use zipinfo.js or vendor it and modify it for our needs.
For reference, this is a Python implementation of a similar mechanism https://github.com/saulpw/unzip-http.
Once we have the listing of all the files, in a minimal number of requests, we load and unzip all files below a certain size cut off (say 500KB) at which we decide to defer loading of a file.
For any files not loaded through the above mechanism, we do the following:
The text was updated successfully, but these errors were encountered: