Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement transferable/cloneable objects #15021
Comments
|
This support is necessary for the transferable arguments to |
|
Hi @jdm! What are the requirements to be able to take this issue? Florent |
|
Ability to read Gecko's C++ code (as linked in the original comment) and translate that into equivalent Rust code, mainly! |
|
This would be a nice thing to have for |
|
Is someone already working on this one? If not, I would be happy to give it a try... |
|
Let's give @fflorent the right of first refusal here. |
|
I'd also highly encourage the person to work on this discuss the implementation plan here first before attempting. |
|
Sure take it! :) Florent |
|
Hi there, I've started looking into this, and the first questions I have are: The stuff found in https://github.com/servo/rust-mozjs/, are those just stubs or actual implementations as well? For example I see Servo is using JS_WriteStructuredClone but I can't find the actual implementations, either in Same thing for JSStructuredCloneCallbacks, are those actually implemented somewhere? Looking at the Firefox code, I can see the actual callbacks implementation, so I'm wondering, does this issue require implementing those callbacks? If so, would that be done in |
|
@gterzian rust-mozjs is a repository for Rust bindings to the JavaScript engine that we use called SpiderMonkey. It is essentially the js directory in Gecko. |
|
@KiChjang thanks for the info. Why is it that those JSStructuredCloneCallbacks are found within EDIT: I think I get it, the stuff in |
|
Ok so here is what I can make out of the Gecko code:
So basically, like Gecko, we need to:
So my question now is, am I getting it somewhat right? And also, am I right to think that, while we can implement all the callbacks, we should probably just start with one or two handler operations? I believe you mentioned two potential use cases("transferable arguments to postMessage" and "MessagePost"), so we should probably just do those for now? |
|
Yep, that sounds like a correct summary of how all the pieces fit together. I think implementing stubs for all of the callbacks makes the most sense; we will presumably need some kind of delegation like https://dxr.mozilla.org/mozilla-central/rev/1d025ac534a6333a8170a59a95a8a3673d4028ee/dom/base/StructuredCloneHolder.cpp#62-65, and then we can focus on supporting a single small use case like using |
|
@jdm awesome, thanks! I'll get started then... |
|
first pass at #15519, if you could please take a look... |
…r=jdm implement structured clone callbacks - support Blob cloning <!-- Please describe your changes on the following line: --> 1. Implement stubs for structured clone callbacks. 2. Support Blob cloning. Partial implementation of https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm --- <!-- 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 - [ ] These changes fix #15021 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/15519) <!-- Reviewable:end -->
…r=jdm implement structured clone callbacks - support Blob cloning <!-- Please describe your changes on the following line: --> 1. Implement stubs for structured clone callbacks. 2. Support Blob cloning. Partial implementation of https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm --- <!-- 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 - [ ] These changes fix #15021 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/15519) <!-- Reviewable:end -->
Spec: https://html.spec.whatwg.org/multipage/infrastructure.html#transferable-objects, https://html.spec.whatwg.org/multipage/infrastructure.html#cloneable-objects
We currently do not pass pointers to JSStructuredCloneCallbacks when calling JS_WriteStructuredClone and JS_ReadStructuredClone. These callbacks control what to do when DOM objects are encountered in the structured clone algorithm. We'll need to duplicate what Gecko does to support this in Servo.