Skip to content
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

toBlobURL / downloadWithProgress method don't handle compressed files #803

Open
trzeciak opened this issue Dec 16, 2024 · 0 comments
Open

Comments

@trzeciak
Copy link

Hey,
in short: I have a problem with handling progress in toBlobURL method, when downloading a compressed wasm module.

Some observations:

  • if we pass a progress block, the downloadWithProgress implementation is used under-the-hood,
  • the display of the progress block is based on the Content-Length header
  • the Content-Length header is related to Content-Encoding (which is controlled by the client, e.g.: Accept-Encoding: gzip, deflate, br, zstd)
  • the fetch method downloads the compressed module, but returns the uncompressed one,

This causes this exception to occur in this downloadWithProgress method:

        if (total != -1 && total !== received)
          throw ERROR_INCOMPLETED_DOWNLOAD;

Then in the catch block, we call buf = await resp.arrayBuffer(), and this causes a second exception on the already downloaded file:

ffmpegwasm Failed to execute 'arrayBuffer' on 'Response': body stream already read…

Which effectively makes it impossible to download this wasm module.

Wasm files compress very well, for example, the ffmpeg-core.wasm module compresses from ~30MB to ~7MB using brotli.

Personally, I don't know how to fix this properly, that the downloadWithProgress method handles compressed files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant