-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
script: Implement Compression API #39658
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
Conversation
|
🔨 Triggering try run (#18242461313) for Linux (WPT) |
|
Test results for linux-wpt from try job (#18242461313): Flaky unexpected result (35)
Stable unexpected results that are known to be intermittent (25)
Stable unexpected results (2)
|
|
|
TimvdLippe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a quick review. Given that almost all WPT tests pass, I think it is pretty much complete. Only one remaining question regarding the bad chunks.
tests/wpt/meta/compression/compression-bad-chunks.tentative.any.js.ini
Outdated
Show resolved
Hide resolved
TimvdLippe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last nit, but this still LGTM
| reflector_: Reflector, | ||
|
|
||
| /// <https://streams.spec.whatwg.org/#generictransformstream> | ||
| transform: Dom<TransformStream>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to see the stream work give results and make it easier to implement other browser APIs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The stream work provides a great foundation for implementing this API. The TextEncoderStream and TextDecoderStream implementation also serve as good references for me. It turned out to be easier than I expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @gterzian
| // NOTE: In our implementation, the enum type of context already indicates the format. | ||
| let mut decompressor = ds.context.borrow_mut(); | ||
| let offset = decompressor.get_ref().len(); | ||
| let is_ended = decompressor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you compute is_ended before calling try_finish, but you enqueue before checking !is_ended. That can emit bytes and then throw?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think it is weird, but the spec does emit bytes no matter whether the test passes or not.
https://compression.spec.whatwg.org/#decompress-flush-and-enqueue
p.s. I made a little change in the new commit. I flush and copy the buffer before doing the test. This guarantees the extra bytes won't go into the result. However, it does not resolve the weirdness here.
update: I reverted it, since this could turn a truncated stream (missing one zero byte at the end) into a valid stream.
| // Step 6.1 If this throws an exception e, | ||
| let realm = enter_realm(self); | ||
| let p = Promise::new_in_current_realm((&realm).into(), can_gc); | ||
| // return a promise rejected with e. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you use Promise::new_rejected here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Promise::new_rejected takes value: impl SafeToJSValConvertible, but e is a dom::bindings::error::Error, which currently does not implement this trait. If we use Promise::new_rejected, we still need extra few lines to do the conversion.
|
Rebased to resolve merge conflict. Also appended a fix for passing new WPT tests from upstream. |
Cargo.toml
Outdated
| encoding_rs = "0.8" | ||
| env_logger = "0.11" | ||
| euclid = "0.22" | ||
| flate2 = "1.1.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The specificity was lower in net
| flate2 = "1.1.2" | |
| flate2 = "1.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing out. It's now pinned to 1.1.
|
This PR still LGTM. @Taym95 do you have any further review feedback or does somebody else wants to take a look? If not, then I would opt for merging this PR. |
|
Let's press the button! |
|
Seems like the recent changes to |
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
https://compression.spec.whatwg.org/#decompressionstream Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
This helps passing WPT tests from `compression/decompression-extra-input.any.js`. Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
|
Rebased with 2 new commits to resolve the merge error |
|
We will need to update the exposed interfaces test files to include the new DecompressionStream interface. Don't forget to use |
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
|
https://github.com/servo/servo/actions/runs/18833881485/job/53730445402 Re-queuing this, as all tests are failing. |
The patch implements Compression (https://compression.spec.whatwg.org/) with the compression and decompression provided by the
flate2crate (https://crates.io/crates/flate2).flate2supports several different backends, controlled through the crate's features. By default, it usesminiz_oxide(https://crates.io/crates/miniz_oxide).flate2provides three modulesread,writeandbufreadwhich work on instances of thestd::io::Read,std::io::Writeandstd::io::Bufreadtraits, respectively. Thewritemodule is chosen in the patch since it matches the streaming model in the specification.Testing: Enable WPT for Compression API, and introduce WPT expectation.