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

WebAssembly MIME Type #981

Closed
RyanLamansky opened this Issue Feb 9, 2017 · 12 comments

Comments

Projects
None yet
4 participants
@RyanLamansky

RyanLamansky commented Feb 9, 2017

Files served over HTTP should have an associated MIME type so the consumer has some idea of what to do with it in the absence of any contextual hints. For example, if there's a desire to someday allow WASM to be loaded via the HTML <script> element, a MIME type would be a strong hint to the browser that it shouldn't try to parse it as JavaScript. This also allows web server extensions that act based on MIME type (like compression modules) to make a better choice (WASM compresses well so automatic server caching of a compressed response is beneficial).

application/webassembly is my personal preference, as it's similar to application/javascript in that the technology name is fully spelled out.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 9, 2017

If a custom decoder and translator is used then the source might be more like a binary blob with no well defined encoding. Perhaps it still helps to have a MIME type for it, so it is known to be an input into this pipeline, but it might want something distinct from application/webassembly which might be reserved for the raw input into the compilation stage?

ghost commented Feb 9, 2017

If a custom decoder and translator is used then the source might be more like a binary blob with no well defined encoding. Perhaps it still helps to have a MIME type for it, so it is known to be an input into this pipeline, but it might want something distinct from application/webassembly which might be reserved for the raw input into the compilation stage?

@RyanLamansky

This comment has been minimized.

Show comment
Hide comment
@RyanLamansky

RyanLamansky Feb 9, 2017

@Wllang You can use custom decoders and translators with any file format, not just WASM. The most famous of example of this is GZIP, which is communicated with the Content-Encoding header, and it's only used if the request includes a matching Accept-Encoding. You're not blocked from anything like you describe by having a defined MIME for WASM files.

RyanLamansky commented Feb 9, 2017

@Wllang You can use custom decoders and translators with any file format, not just WASM. The most famous of example of this is GZIP, which is communicated with the Content-Encoding header, and it's only used if the request includes a matching Accept-Encoding. You're not blocked from anything like you describe by having a defined MIME for WASM files.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 9, 2017

The 'Content-Encoding` support depends on the web browser, if the web browser does not support it then it can not be used. For wasm I expect a user defined (custom) decoder, one that might be specific to a app and have no public standard. Even without such a custom decompressor I expect a translator between the received and decompressed data and the input to the target compiler, to do things like macro expansion, and this blob might again have an encoding that is not a public standard or that warrants a specific MIME type. I am not blocking anything, just trying to get some perspective on what the MIME type represents.

ghost commented Feb 9, 2017

The 'Content-Encoding` support depends on the web browser, if the web browser does not support it then it can not be used. For wasm I expect a user defined (custom) decoder, one that might be specific to a app and have no public standard. Even without such a custom decompressor I expect a translator between the received and decompressed data and the input to the target compiler, to do things like macro expansion, and this blob might again have an encoding that is not a public standard or that warrants a specific MIME type. I am not blocking anything, just trying to get some perspective on what the MIME type represents.

@RyanLamansky

This comment has been minimized.

Show comment
Hide comment
@RyanLamansky

RyanLamansky Feb 9, 2017

@Wllang The WAST file format is an example of what you describe: it's not a valid WASM file by itself, but it can become one after being processed. For something like that, to avoid compatibility risks, you'd use a different MIME type (like text/webassembly), the last-resort application/octet-stream, or even no Content-Type header at all (it's not required by the HTTP standard).

RyanLamansky commented Feb 9, 2017

@Wllang The WAST file format is an example of what you describe: it's not a valid WASM file by itself, but it can become one after being processed. For something like that, to avoid compatibility risks, you'd use a different MIME type (like text/webassembly), the last-resort application/octet-stream, or even no Content-Type header at all (it's not required by the HTTP standard).

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 9, 2017

@Kardax Yes, great example, thanks. We could have a translator that accepted the wast text format and converts it to the wasm binary format for compilation. I was thinking of other binary formats, but you raise a really good example that might be interesting for some small development or training uses. So in #982 I would like to see it be possible to submit the text file as an input, plus a description of the translator, to make that work.

ghost commented Feb 9, 2017

@Kardax Yes, great example, thanks. We could have a translator that accepted the wast text format and converts it to the wasm binary format for compilation. I was thinking of other binary formats, but you raise a really good example that might be interesting for some small development or training uses. So in #982 I would like to see it be possible to submit the text file as an input, plus a description of the translator, to make that work.

@jfbastien

This comment has been minimized.

Show comment
Hide comment
@jfbastien

jfbastien May 11, 2017

Member

@annevk / @domenic I think you were discussing this?

Member

jfbastien commented May 11, 2017

@annevk / @domenic I think you were discussing this?

@domenic

This comment has been minimized.

Show comment
Hide comment
@domenic

domenic May 11, 2017

Member

Yes, someone needs to add the MIME type check to the compileStreaming/instantiateStreaming spec in JS.md...

Member

domenic commented May 11, 2017

Yes, someone needs to add the MIME type check to the compileStreaming/instantiateStreaming spec in JS.md...

@annevk

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk May 12, 2017

Member

I think you mean in Web.md which already has this requirement. I think this issue is about renaming the MIME type subtype from "wasm" to "webassembly" though it's not entirely clear from OP.

Member

annevk commented May 12, 2017

I think you mean in Web.md which already has this requirement. I think this issue is about renaming the MIME type subtype from "wasm" to "webassembly" though it's not entirely clear from OP.

@jfbastien

This comment has been minimized.

Show comment
Hide comment
@jfbastien

jfbastien May 12, 2017

Member

@annevk ah gotcha. Sounds like we can close then, if it's just a rename at this point?

Member

jfbastien commented May 12, 2017

@annevk ah gotcha. Sounds like we can close then, if it's just a rename at this point?

@annevk

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk May 12, 2017

Member

@jfbastien if you don't want to rename it from "wasm" to "webassembly", yes.

Member

annevk commented May 12, 2017

@jfbastien if you don't want to rename it from "wasm" to "webassembly", yes.

@jfbastien

This comment has been minimized.

Show comment
Hide comment
@jfbastien

jfbastien May 12, 2017

Member

Well, isn't this already shipping in Chrome or about to ship? IIUC it's hard to change at this point, and I don't see much upside from one name to another.

Closing for now, happy to reopen if I was wrong.

Member

jfbastien commented May 12, 2017

Well, isn't this already shipping in Chrome or about to ship? IIUC it's hard to change at this point, and I don't see much upside from one name to another.

Closing for now, happy to reopen if I was wrong.

@jfbastien jfbastien closed this May 12, 2017

@RyanLamansky

This comment has been minimized.

Show comment
Hide comment
@RyanLamansky

RyanLamansky May 13, 2017

@annevk , @jfbastien At the time I wrote this issue, the MIME hadn't yet been publicly decided as application/wasm. I wasn't aware that there was already considerable momentum behind that choice (relatively little of the team's activity is published). I don't have a problem with the decision 🙂

RyanLamansky commented May 13, 2017

@annevk , @jfbastien At the time I wrote this issue, the MIME hadn't yet been publicly decided as application/wasm. I wasn't aware that there was already considerable momentum behind that choice (relatively little of the team's activity is published). I don't have a problem with the decision 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment