Opened 6 years ago

Closed 3 years ago

#1606 closed enhancement (fixed)

WebAssembly doesn't work on Firefox/Chrome due to missing MIME type

Reported by: DesWurstes@… Owned by:
Priority: minor Milestone:
Component: other Version: 1.15.x
Keywords: mime mime.types Cc:
uname -a:
nginx -V: nginx version: nginx/1.15.2

Description

WebAssembly's MIME type is application/wasm. If not set; Firefox, Chrome and Vivaldi won't be able to run the WASM.

Here's the Chrome error message:

util.js:1632 wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'.

Could you please add application/wasm wasm to nginx/conf/mime.types?

Change History (9)

comment:1 by Maxim Dounin, 6 years ago

Keywords: mime mime.types added
Priority: majorminor
Type: defectenhancement

Thanks for your suggestion. Note that if you want to add additional types or serve some files with specific custom types, you can do so using the types directive, see the documentation for examples.

Some related facts as found during a quick investigation, just for the record:

Note that we generally only add most popular types to the mime.types as shipped with nginx. It is not currently clear if application/wasm is one of such types, so leaving this open for now. If you are reading this and also want (or don't want) application/wasm to be added, please comment.

comment:2 by dbrgn@…, 5 years ago

If you are reading this and also want (or don't want) application/wasm to be added, please comment.

I signed up here to say: Yes, I'd also like to see this type added! :)

The the WebAssembly specification isn't yet complete, though there is a ​public draft.

It's true that the spec isn't complete, but in the meantime the WebAssembly MVP (https://webassembly.org/docs/mvp/) has shipped across all major browsers (at least Firefox, Chrome, Edge, Safari).

Oh, and it seems that the mime type has been added to cpython as well.

comment:3 by ccouzens@…, 4 years ago

If you are reading this and also want (or don't want) application/wasm to be added, please comment.

Yes please, I would like to see this added. I have a patch, although it isn't exactly a complicated change.

The WebAssembly specification isn't yet complete, though there is a public draft.

It's now a "Proposed Recommendation", which is the final step to becoming a W3C recommendation (although they stress until it's a recommendation it's still a draft).

I think on balance it's reasonable for nginx to hold off until it's a W3C recommendation. I imagine it's easier for the nginx project to add it once it has become a recommendation, than to remove it should it fail.

comment:4 by ccouzens@…, 4 years ago

The WebAssembly? specification isn't yet complete, though there is a ​public draft.

It's now a W3C recommendation. I think this happened today.
And it says that it should be served with the mime type application/wasm

https://www.w3.org/TR/wasm-web-api-1/#streaming-modules

comment:5 by https://stackoverflow.com/users/4228964/florent, 3 years ago

Please add this mime type.
I forgot multiple times to add it to the config file and it's a pain in a multi-host configuration where you can only declare it in a single file.
Without this mime/type, all libraries based on emscripten will fail streaming compilation and instead revert to ArrayBuffer.
Streaming compilation can save almost all wasm compilation time.
https://developers.google.com/web/updates/2018/04/loading-wasm

comment:6 by Laurence 'GreenReaper' Parry, 3 years ago

This is a common enough issue for users of Flash emulator Ruffle (which is getting a lot of attention right now) that it has adding the MIME type as the first thing to do after downloading and extracting files for web deployment.

Version 0, edited 3 years ago by Laurence 'GreenReaper' Parry (next)

comment:7 by Maxim Dounin, 3 years ago

See also #2168.

comment:8 by Maxim Dounin <mdounin@…>, 3 years ago

In 7834:b3f4d83d6fd0/nginx:

MIME: added application/wasm type (ticket #1606).

comment:9 by Maxim Dounin, 3 years ago

Resolution: fixed
Status: newclosed

Committed. Thanks for prodding this.

Note: See TracTickets for help on using tickets.