Implement brotli for Compression/DecompressionStream
Categories
(Core :: DOM: Streams, enhancement, P3)
Tracking
()
People
(Reporter: saschanaz, Assigned: saschanaz)
References
(Regressed 1 open bug)
Details
(Keywords: dev-doc-complete, parity-safari)
Attachments
(5 files)
Per today's resolution in TPAC WHATWG/WebPerf joint meeting.
We should also add some telemetry to see the usage ratio (between comp/decomp for each format)
| Assignee | ||
Updated•1 year ago
|
Comment 1•9 months ago
|
||
:saschanaz, do you have any idea about when this feature will be available ?
I'm asking because it seems that brotli decompression will be a part of the pdf 2.0 specs:
https://pdfa.org/brotli-compression-coming-to-pdf/
| Assignee | ||
Comment 2•9 months ago
•
|
||
Err, I was thinking maybe we can go straight to zstd, do you have some info why they chose brotli? Maybe the decision was made a few years ago already?
We got zstd support internally for the translation module and hasn't been doing much for brotli yet (which doesn't mean we have a strong reason not to ship brotli).
Comment 3•9 months ago
|
||
Hi. I'm the guy that did the investigation for the introduction of Brotli to PDF.
We considered a range of different options, (including LZMA, Brotli, ZStd), and in our testing found that Brotli was as good, if not better, than all the others at the different compression/decompression settings we tried.
The fact that a Brotli decoder will likely be included in most web environments (not least because it is required for WOFF2 fonts, I believe) is reinforcement to this decision.
Adding multiple new compression methods is not really a good idea for us, as we want PDF to continue to be readable in resource constrained environments.
| Assignee | ||
Updated•9 months ago
|
| Assignee | ||
Comment 4•9 months ago
|
||
(In reply to Calixte Denizet (:calixte) from comment #1)
:saschanaz, do you have any idea about when this feature will be available ?
I'm asking because it seems that brotli decompression will be a part of the pdf 2.0 specs:
https://pdfa.org/brotli-compression-coming-to-pdf/
Hi Calixte, how urgent is this for your team? Trying to adjust the priority.
Comment 5•9 months ago
|
||
:Robin, do you know when BrotliDecode will be in the PDF 2.0 specs ?
:saschanaz, for now it isn't in the PDF specs, Acrobat doesn't implement the feature, so I'd say it isn't urgent but if you could add it to the 2025 roadmap, it'd be nice.
Anyway, on the pdf.js' side, we've some work too in order to make sure we're able to get the data asynchronously from a BrotliDecode stream.
Comment 6•9 months ago
|
||
We are currently preparing the official Brotli Decode in PDF documentation. An informal document is available to members of the PDF association, but is not currently public.
Basically, if you use "BrotliDecode" in all the places that you currently read "FlateDecode" you won't go far wrong.
Development versions of MuPDF and Ghostscript both have support for the current version so files can be generated for testing, and generated files can be tested.
There is no guarantee that the spec won't change before publication (In particular, I was interested in doing a new custom dictionary for PDF compression, but this hasn't shown any meaningful benefits so far), but I suspect you'll be safe just going with the obvious.
If you're interested in participating more thoroughly with this and other developments coming down the line, you'd be well advised to consider joining the PDFA.
Comment 7•9 months ago
|
||
I should have said "We have no exact timeline for this as yet. It needs to go through the ISO fast-track process, but I have no personal experience on how long that will take."
Comment 9•9 months ago
|
||
(In reply to Robin Watts from comment #3)
We considered a range of different options, (including LZMA, Brotli, ZStd), and in our testing found that Brotli was as good, if not better, than all the others at the different compression/decompression settings we tried.
Can you share your measurement code, and the corpus you tried it on? I find this claim surprising, but it's hard to design an experiment that allows for a fair comparison.
The fact that a Brotli decoder will likely be included in most web environments (not least because it is required for WOFF2 fonts, I believe) is reinforcement to this decision.
zstd is going to be on the Web in the coming months to years (https://github.com/whatwg/compression/issues/54).
Comment 10•9 months ago
|
||
(In reply to Paul Adenot (:padenot) from comment #9)
Can you share your measurement code, and the corpus you tried it on? I find this claim surprising, but it's hard to design an experiment that allows for a fair comparison.
Sure. If you'd like to be involved, then just join the PDFA. Then I can give you access to my code where I tried LZMA vs Brotli vs ZStd.
zstd is going to be on the Web in the coming months to years (https://github.com/whatwg/compression/issues/54).
But not necessarily everywhere that PDF renderers need to be implemented. It seems likely that PDF will want to support WOFF/WOFF2 fonts in some future version, so Brotli is probably going to be required within PDF implementations at some point.
It's bad enough to insist that every PDF renderer in the world needs to implement another decoder; we can't in good conscience insist that they all need to implement every decoder people might want. So we picked 'the best' one (for at least the values of 'best' that I tested).
Honestly, we'd need some pretty compelling evidence to relitigate this now. And the place to present that evidence is in the PDFA committee process. Ideally 6 months ago :) We'd love to see you there.
Whatever option we pick, someone will complain that we picked the wrong one.
Comment 11•3 months ago
|
||
:saschanaz, it seems that it's becoming more and more relevant to have this feature implemented in Firefox at least in the pdf.js context:
https://github.com/mozilla/pdf.js/issues/20290#:~:text=Several,possible,-%2E
Could we prioritize it ?
| Assignee | ||
Comment 12•3 months ago
|
||
Ah, thanks for heads up. I'll find some time.
| Assignee | ||
Comment 13•3 months ago
|
||
| Assignee | ||
Comment 14•2 months ago
|
||
Out of curiosity, will pdf.js also use CompressionStream for brotli? Maybe to save PDF?
Comment 15•2 months ago
|
||
Yes it's already possible to add some elements (images, texts, ...) which are saved and then compressed.
We are currently working on the possibility to split and merge pdfs, and having a good compression tool would be amazing.
| Assignee | ||
Comment 16•2 months ago
|
||
Updated•2 months ago
|
| Assignee | ||
Updated•2 months ago
|
Comment 17•2 months ago
|
||
| Assignee | ||
Updated•2 months ago
|
Comment 19•2 months ago
|
||
| bugherder | ||
| Assignee | ||
Comment 21•2 months ago
|
||
| Assignee | ||
Comment 22•2 months ago
|
||
Comment 23•2 months ago
|
||
Reopened for unpublished changesets.
Updated•2 months ago
|
Updated•2 months ago
|
| Assignee | ||
Comment 24•2 months ago
|
||
| Assignee | ||
Comment 25•2 months ago
|
||
Jonathan, I added you as a reviewer of brotli dependency because you were the last reviewer, but are you still the right one or should I look for someone else?
Comment 26•2 months ago
|
||
Yeah - I'll take a look, sorry for not getting to this right away.
(Aside: One thing to be aware of when it comes to compression is that IIRC brotli can be pretty slow compared to other compressors; it's optimized for good compression-ratio and decompression performance, but compression is expensive.)
| Assignee | ||
Comment 27•2 months ago
|
||
True, but given PDF decided to use brotli we have not much choice π (given we also need to edit PDF)
Comment 28•2 months ago
|
||
Comment 30•2 months ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/2d2eb89217a0
https://hg.mozilla.org/mozilla-central/rev/beb6ff283dd5
https://hg.mozilla.org/mozilla-central/rev/2f380b2498eb
https://hg.mozilla.org/mozilla-central/rev/1ba472652b90
Comment 31•2 months ago
|
||
Is this worth calling out in the Fx147 relnotes? Please nominate if yes.
| Assignee | ||
Comment 33•2 months ago
|
||
Release Note Request (optional, but appreciated)
[Why is this notable]: adding web platform feature for brotli compression
[Affects Firefox for Android]: Yes
[Suggested wording]: Both CompressionStream and DecompressionStream now can handle the brotli format.
[Links (documentation, blog post, etc)]:
Comment 34•1 month ago
|
||
Increased the installer size on Windows non-shippable opt builds by 333KB.
Probably expected from the nature of the bug (moar stuff is being compiled now).
| Assignee | ||
Updated•1 month ago
|
Comment 36•1 month ago
|
||
FF147 MDN docs work for this can be tracked in https://github.com/mdn/content/issues/42251
Description
•