mozilla / standards-positions

https://mozilla.github.io/standards-positions/
Mozilla Public License 2.0
636 stars 69 forks source link

Compression Streams #207

Closed ricea closed 4 years ago

ricea commented 4 years ago

Request for Mozilla Position on an Emerging Web Specification

Other information

See also the explainer at https://github.com/ricea/compressstream-explainer/blob/master/README.md I have requested WICG incubation for this specification: https://discourse.wicg.io/t/proposal-compression-streams-standard/3920

ekr commented 4 years ago

I'd like to hear from @annevk about this, but from my perspective, this seems like it's kind of platform bloat. What's the reason for baking a specific set of compression algorithms into the platform rather than just having a generic system (which may not need any new standardization) that allows one to write your compressor in WASM?

The choice algorithms here is suggestive:

Gzip and Deflate are ubiquitous and already shipping in every browser. This means the incremental cost of exposing them is very low. They are used so extensively in the web platform that there is almost zero chance of them ever being removed, so committing to supporting them long-term is safe.

However, gzip and deflate are also old (which is why they are ubiquitous) and hence not very advanced, but that means that more or less by definition this API will always be behind. Note that we've already seen this problem with WebCrypto, so it's not hypothetical, but at least WebCrypto had the excuse that you really needed the algorithms implemented in the browser. That doesn't seem to apply here.

annevk commented 4 years ago

I have seen some requests for this from web developers, but yeah, it would be interesting to know to what extent implementing this in JavaScript or Wasm (or importing a module that has done it) is prohibitive.

ricea commented 4 years ago

Thank you for your feedback. I'd like to address your points one-by-one.

I'd like to hear from @annevk about this, but from my perspective, this seems like it's kind of platform bloat.

What's the reason for baking a specific set of compression algorithms into the platform rather than just having a generic system (which may not need any new standardization) that allows one to write your compressor in WASM?

People can and do already include compressors in WASM or JavaScript in their apps. The benefits of supplying compression algorithms in the platform are:

However, gzip and deflate are also old (which is why they are ubiquitous) and hence not very advanced

more or less by definition this API will always be behind.

In conclusion, for a low investment from browser vendors we can provide a substantial benefit to developers in terms of functionality, and to users in terms of reduced data usage.

Krinkle commented 4 years ago

In case it helps - This standard would benefit Wikipedia users. Our VisualEditor software has to upload a sizeable HTML document to the server. In order to reduce upload times we currently use a JavaScript implementation of Deflate which cuts down the payload from e.g. 1.4MB to 205K, which generally makes saving changes a lot faster.

The only downside is that often takes between 1 and 2 seconds to compress with a JavaScript implementation (ThinkPad running Ubuntu). We're working on tuning the compression levels and considering competing JS implementations, but it's hard to beat native of course. Also as it would avoid needing to download the JavaScript library itself.

annevk commented 4 years ago

@Krinkle how big is the JavaScript library? Did you look into Wasm? Point taken though that it would be simpler and faster (definitely compared to JavaScript) if builtin.

Yoric commented 4 years ago

CloudFlare has tested compiling brotli into wasm for server-side use. While I don't have exact numbers, I remember that the binary was multi-megabytes large (possibly owing to the fact that brotli contains a pretty large built-in dictionary), which made it essentially unusable for their use case. I suspect that the same applies here.

dbaron commented 4 years ago

I think this is a pretty basic gap in the platform (and one where something the platform already has just isn't exposed), and I'd rather not force less advanced developers to drop into WASM to have to fill it.

mconca commented 4 years ago

For better or worse, Google shipped this in Chrome 80. Reaction from devs has been generally positive, and it's encouraging that several have asked for Mozilla's position on this from a standards point-of-view.

I think I'm generally supportive of this because it reduces the need for devs to ship compress/decompress code (JS or WASM), and leveraging the native browser implementation is going to be faster, regardless. Smaller page sizes and faster execution is a performance win for web users.

yutakahirano commented 2 years ago

We're adding "defalte-raw" compression format, to allow web developers to access the raw deflate stream. Please see https://github.com/wicg/compression/issues/25. Chrome is working to ship the feature.

miketaylr commented 2 years ago

@mconca @annevk should we open a new issue for "deflate-raw", or do you consider that covered by the existing Compression Streams entry (maybe not, it's new and all)?

mconca commented 2 years ago

This seems like a logical extension of "deflate" so I don't think a new entry is needed. Thanks.

jimmywarting commented 1 year ago

Thinking of doing some p2p file transfer and would like to use the de/compression streams, I can't really figure out if the other peer supports compression streams so i need to signal that in advance (durning sdp signaling) if they support it or not.

BenjaminAster commented 1 year ago

Apple will ship CompressionStreams in Safari 16.4, so Firefox will be the only browser not supporting it. Implementing this is now a question of web compatibility.

Personally, I am particularly excited for compression streams because they let you natively read and write .zip, .docx, .xlsx, etc. files in the browser without any libraries.

ekr commented 1 year ago

Apple will ship CompressionStreams in Safari 16.4, so Firefox will be the only browser not supporting it. Implementing this is now a question of web compatibility.

Reminder: this is not the place to discuss Firefox's product plans.

cavac commented 1 year ago

I must say, with all the faffing about by the Firefox team, as a web developer i have resigned to relegate Firefox to a "backup platform" instead of being a main target for our software. It regularly falls behind other browsers in terms of implemented standard APIs because the team "doesn't see the point in implementing those".

It's a rather frustrating experience. And frankly, i'm not sure how much longer i can even support the platform at all, since it time-and-again needs special handling in my web systems.

olfek commented 1 year ago

😢😢😢

tantek commented 1 year ago

@olfek @cavac neither of your comments provided any new technical information on this specification and are out of scope for this repo. If you want to vent, please use your own blog to do so.

Please re-read the CONTRIBUTING guide https://github.com/mozilla/standards-positions/blob/main/CONTRIBUTING.md before making any further comments on any issue in the repo.

All of the comments made on this issue in this year were out of scope, and none of them provided any new technical information about the specification so I am locking this issue accordingly.

(Originally published at: https://tantek.com/2023/079/t1/)