Skip to content
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

Rewrite websocket array buffer handling to use typed array APIs #14675

Closed
jdm opened this issue Dec 22, 2016 · 6 comments
Closed

Rewrite websocket array buffer handling to use typed array APIs #14675

jdm opened this issue Dec 22, 2016 · 6 comments

Comments

@jdm
Copy link
Member

@jdm jdm commented Dec 22, 2016

The current implementation uses the JSAPI to create an array buffer, get its buffer and populate it with the received websocket message. We should be using the ArrayBufferU8::create API instead (see FileReader::perform_readasarraybuffer for an example).

Code: components/script/dom/websocket.rs
Tests: ./mach test-wpt tests/wpt/websockets/

@dpyro
Copy link
Contributor

@dpyro dpyro commented Dec 22, 2016

I will give it a try!

@KiChjang
Copy link
Member

@KiChjang KiChjang commented Dec 22, 2016

Alright!

@KiChjang KiChjang added the C-assigned label Dec 22, 2016
@dpyro
Copy link
Contributor

@dpyro dpyro commented Dec 23, 2016

I’ve rewritten the handling to use Uint8Array::create. It compiles and passes ./mach test-wpt tests/wpt/web-platform-tests/websockets/ but I am unsure how to verify that the modified behavior is correct/equivalent.

@jdm
Copy link
Member Author

@jdm jdm commented Dec 23, 2016

Great work! Two notes, though:

  • Does ArrayBuffer::create work instead? That would be equivalent with the previous code.
  • You can remove the code which extracts the buffer pointer and fills it with data; passing Some(data) to the creation function has the same effect.
@Ms2ger
Copy link
Contributor

@Ms2ger Ms2ger commented Dec 23, 2016

Also, feel free to go ahead and create a PR; that might make discussion easier.

@jdm
Copy link
Member Author

@jdm jdm commented Dec 23, 2016

Huh, I'm surprised that dpyro@9bd1fab#diff-c13bae09b178a30151ecebdc13c30a26R619 passes tests, however. Additionally, dpyro@9bd1fab#diff-c13bae09b178a30151ecebdc13c30a26R613 shouldn't compile, since the last argument is supposed to be a mutable handle.

bors-servo added a commit that referenced this issue Dec 24, 2016
Rewrote websocket array buffer handling to typed array API

<!-- Please describe your changes on the following line: -➜
Replaced existing code for handling `BinaryType::Arraybuffer` from `JS_NewArrayBuffer` to `Uint8Array::create`.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #14675 (github issue number if applicable).

<!-- Either: -->
- [X] These changes do not require tests because they replace an existing implementation

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

I am not certain the test suite will adequately verify my implementation as I am not familiar with the architecture. It compiles and passes the current tests.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14718)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Dec 28, 2016
Rewrote websocket array buffer handling to typed array API

<!-- Please describe your changes on the following line: -➜
Replaced existing code for handling `BinaryType::Arraybuffer` from `JS_NewArrayBuffer` to `Uint8Array::create`.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #14675 (github issue number if applicable).

<!-- Either: -->
- [X] These changes do not require tests because they replace an existing implementation

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

I am not certain the test suite will adequately verify my implementation as I am not familiar with the architecture. It compiles and passes the current tests.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14718)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants
You can’t perform that action at this time.