Skip to content

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

Open
@trzeciak

Description

@trzeciak

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions