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

Continue message port #23637

Merged
merged 2 commits into from Oct 19, 2019
Merged

Continue message port #23637

merged 2 commits into from Oct 19, 2019

Conversation

@gterzian
Copy link
Member

gterzian commented Jun 26, 2019

Fixes #7457.
Fixes #12715.
Fixes #12717.
Fixes #16095.
Fixes #18969.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #___ (GitHub issue number if applicable)
  • There are tests for these changes OR
  • These changes do not require tests because ___

This change is Reviewable

@highfive
Copy link

highfive commented Jun 26, 2019

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/messagechannel.rs, components/script/dom/messageport.rs, components/script/dom/mod.rs, components/script/dom/dissimilaroriginwindow.rs, components/script/dom/window.rs and 28 more
  • @cbrewster: components/constellation/Cargo.toml, components/constellation/constellation.rs
  • @jgraham: tests/wpt/include.ini
  • @paulrouget: components/constellation/Cargo.toml, components/constellation/constellation.rs
  • @KiChjang: components/script/dom/messagechannel.rs, components/script/dom/messageport.rs, components/script/dom/mod.rs, components/script/dom/dissimilaroriginwindow.rs, components/script/dom/window.rs and 28 more
@highfive
Copy link

highfive commented Jun 26, 2019

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
@gterzian
Copy link
Member Author

gterzian commented Jun 26, 2019

Still an early sketch. cc @KiChjang @jdm

Messages are still routed via the constellation, not directly script to script, and I haven't actually run it yet, just trying to have a rough sketch that compiles.

One question @KiChjang do I understand it correctly that transfer_receive will be called once for every object in the initial transfer: CustomAutoRooterGuard<Option<Vec<*mut JSObject>>>?

@gterzian gterzian force-pushed the gterzian:continue-message-port branch 3 times, most recently from 7f30795 to a9f3a5a Jun 26, 2019
@@ -19,7 +19,7 @@ no_wgl = ["canvas/no_wgl"]
background_hang_monitor = { path = "../background_hang_monitor"}
backtrace = "0.3"
bluetooth_traits = { path = "../bluetooth_traits" }
canvas = {path = "../canvas", default-features = false}
canvas = {path = "../canvas", default-features = true}

This comment has been minimized.

Copy link
@gterzian

gterzian Jun 26, 2019

Author Member

note: remove change

@jdm jdm removed the S-awaiting-review label Jun 28, 2019
@gterzian gterzian force-pushed the gterzian:continue-message-port branch from 0b4c36a to 9a50c92 Jun 28, 2019
@bors-servo
Copy link
Contributor

bors-servo commented Jun 29, 2019

The latest upstream changes (presumably #23344) made this pull request unmergeable. Please resolve the merge conflicts.

@gterzian gterzian force-pushed the gterzian:continue-message-port branch from d2d3bae to 35de5eb Jun 30, 2019
@gterzian
Copy link
Member Author

gterzian commented Jun 30, 2019

@jdm @KiChjang Ok so at this point, I almost dare to say that it's "working".

I don't think I'll have time during the week to make progress, so it might be worth it if anyone has time to review the current work-in-progress(or not and I'll just pick things up later).

Some highlights:

  1. Same-origin and cross-origin transfer and messaging seems to work(with script-to-script ipc).
  2. There are quite a few tests we're not passing yet "as is", because we're not implementing all requires arguments to postMessage, and other things like not setting source of MessageEvent to be a cross-origin window proxy in some cases, which the tests are using. But I've done some manual testing by adapting some tests and the base case of transferring and messaging appear to work.
  3. I switched to using the GlobalScope as the place to write the glue between ports and the constellation. I think it's a good idea because that means it will work for workers as well. It's important because even though we don't have to use an actual message ports for the "implicit port" of dedicated workers, we still have to allow for ports to be transferred into them via worker.postMessage. On that regards we're not implementing the transfer argument yet, so I haven't tested it, but in theory it should work.
  4. I kept using the structured transfer API, if only because it's actually quite nice as a way to hide the transfer from the various postMessage clients. I've been able to write across a single MessagePortId, and I'd like to find a way to write across a second one for the entangled port(there is one content pointer which might be useful, but just assigning the id to a raw pointer gives weird results on the other side, but maybe de-constructing the id in a u64 like is already could work with the void pointer as well).
  5. It turns out that using MessagePortId in workers requires a PipelineNameSpace to have been installed for their thread, I currently do this with a blocking call to the constellation when the worker starts...
  6. There's a lot of code that can't quite see the light of day, and lots of notes that probably only make sense to me, please bear with me.
  7. An entangled port and constellation share a sender to the other port, and a message type, wondering if those should be separated.
@gterzian
Copy link
Member Author

gterzian commented Jul 3, 2019

@bors-servo try=wpt Let's see what tests have been affected outside of webmessaging.

@bors-servo
Copy link
Contributor

bors-servo commented Jul 3, 2019

Trying commit 208c4d3 with merge 9ed8848...

bors-servo added a commit that referenced this pull request Jul 3, 2019
[WIP] Continue message port

<!-- Please describe your changes on the following line: -->
Fixes #7457.
Fixes #12715.
Fixes #12717.
Fixes #16095.
Fixes #18969.

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

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/23637)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 3, 2019

💔 Test failed - linux-rel-css

@gterzian
Copy link
Member Author

gterzian commented Jul 3, 2019

One thing that is left to do for sure is setting the windowproxy of the source of the message on the message event, because a lot of test rely on that in sending some sort of acknowledgement back.

EDIT: the problem was we were using the origin of the window receiving the message, instead of the one sending the message, in the origin field of message event.

@gterzian gterzian force-pushed the gterzian:continue-message-port branch from 208c4d3 to 29ce72d Jul 3, 2019
@highfive highfive removed the S-tests-failed label Jul 3, 2019
@gterzian
Copy link
Member Author

gterzian commented Jul 3, 2019

"If this is failing: DANGER, are you sure you want to expose the new interface MessagePort to all webpages as a property on the global? Do not make a change to this file without review from jdm or Ms2ger for that specific change!"

@gterzian gterzian force-pushed the gterzian:continue-message-port branch from 11a3fcb to 4a9795a Jul 4, 2019
@jdm
Copy link
Member

jdm commented Jul 4, 2019

For the record, I am about 1/3 of the way through reviewing the changes so far.

@bors-servo
Copy link
Contributor

bors-servo commented Jul 5, 2019

The latest upstream changes (presumably #23483) made this pull request unmergeable. Please resolve the merge conflicts.

@gterzian
Copy link
Member Author

gterzian commented Jul 5, 2019

@bors-servo try=wpt (let's get an update on the rest of the suite)

KiChjang and others added 2 commits Dec 11, 2016
Accept transfer argument for StructuredCloneData::write

Allow structured clone reads to return a boolean

Add Transferable trait

Add basic skeletons to MessagePort

Implement transfer and transfer-receiving steps on MessagePort

Use transfer and transfer_receive in StructuredClone callbacks

Implement MessageChannel

Freeze the array object for the MessageEvent ports attribute

Implement transfer argument on window.postMessage

Use ReentrantMutex instead for MessagePortInternal

Accept origin as a parameter in dispatch_jsval

Fix BorrowMut crash with pending_port_message

Detach port on closure and check for detached during transfer

Enable webmessaging tests

fix webidl

fix
@gterzian gterzian force-pushed the gterzian:continue-message-port branch from 9d7b0cd to 2f8932a Oct 19, 2019
@servo-wpt-sync
Copy link
Collaborator

servo-wpt-sync commented Oct 19, 2019

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at web-platform-tests/wpt#17663.

@gterzian
Copy link
Member Author

gterzian commented Oct 19, 2019

Ok so this needed a rebase, and I've also added a re-routing of the task if the global is not managing any ports, at https://github.com/servo/servo/pull/23637/files#diff-59d233642d0ce6d687484bdd009e1017R520

@jdm r?

@jdm
Copy link
Member

jdm commented Oct 19, 2019

@bors-servo
Copy link
Contributor

bors-servo commented Oct 19, 2019

📌 Commit 2f8932a has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Oct 19, 2019

Testing commit 2f8932a with merge c466b40...

bors-servo added a commit that referenced this pull request Oct 19, 2019
Continue message port

<!-- Please describe your changes on the following line: -->
Fixes #7457.
Fixes #12715.
Fixes #12717.
Fixes #16095.
Fixes #18969.

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

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/23637)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Oct 19, 2019

💔 Test failed - status-taskcluster

@jdm
Copy link
Member

jdm commented Oct 19, 2019

@bors-servo retry

@bors-servo
Copy link
Contributor

bors-servo commented Oct 19, 2019

Testing commit 2f8932a with merge a905916...

bors-servo added a commit that referenced this pull request Oct 19, 2019
Continue message port

<!-- Please describe your changes on the following line: -->
Fixes #7457.
Fixes #12715.
Fixes #12717.
Fixes #16095.
Fixes #18969.

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

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/23637)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Oct 19, 2019

☀️ Test successful - linux-rel-css, linux-rel-wpt, status-taskcluster
Approved by: jdm
Pushing a905916 to master...

@bors-servo bors-servo merged commit 2f8932a into servo:master Oct 19, 2019
2 checks passed
2 checks passed
Taskcluster (pull_request) TaskGroup: success
Details
homu Test successful
Details
@gterzian gterzian deleted the gterzian:continue-message-port branch Oct 20, 2019
@jdm jdm mentioned this pull request Oct 23, 2019
4 of 5 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.