Share script threads by tab and by eTLD+1#14211
Conversation
|
Heads up! This PR modifies the following files:
|
|
There's two commits in this PR. The first one is #14173, the second one is the subject of this PR. |
|
☔ The latest upstream changes (presumably #14023) made this pull request unmergeable. Please resolve the merge conflicts. |
8db72d1 to
0f92143
Compare
|
☔ The latest upstream changes (presumably #14246) made this pull request unmergeable. Please resolve the merge conflicts. |
0f92143 to
daaf77a
Compare
daaf77a to
4ef42c1
Compare
|
This is now ready for review, since #14173 landed. @bors-servo r? @jdm |
4ef42c1 to
5c472e9
Compare
jdm
left a comment
There was a problem hiding this comment.
Excellent work! This feels like a sensible design, and it's nice that new_pipeline is completely in control of selecting a script thread now.
components/script_traits/lib.rs
Outdated
| } | ||
|
|
||
| /// The initial data associated with a newly-created framed pipeline. | ||
| /// The initial data associated to create a new layout attached to an existing script thread. |
| match self.documents.borrow().iter().next() { | ||
| None => panic!("Layout attached to empty script thread."), | ||
| // Tell the layout thread factory to actually spawn the thread. | ||
| Some((_, document)) => document.window().layout_chan().send(msg).unwrap(), |
There was a problem hiding this comment.
We could keep trying other threads if sending to the first one fails. Maybe file as a followup?
There was a problem hiding this comment.
Really we should provide the script thread with a factory method for building layout threads, this would also deal with the corner case where a pipeline is asked to create a layout thread despite not having any current layout threads.
There was a problem hiding this comment.
That does sound better. A followup would be good.
| if self.shutting_down { return; } | ||
|
|
||
| // TODO: think about the case where the child pipeline is created | ||
| // before the parent is part of the frame tree. |
There was a problem hiding this comment.
I don't understand what this means. It doesn't sound possible as written.
There was a problem hiding this comment.
I made this comment into a question. You're right, I don't think this can happen, but I'm not sure we should be relying on that.
| let window_size = pipeline_id.and_then(|id| self.pipelines.get(&id).and_then(|pipeline| pipeline.size)); | ||
|
|
||
| self.close_frame_children(frame_id, ExitPipelineMode::Force); | ||
| self.close_frame_children(top_level_frame_id, ExitPipelineMode::Force); |
There was a problem hiding this comment.
Should we remove any entries from the script channels map?
There was a problem hiding this comment.
Once we've got document discarding, that should all happen automatically, because the old page will be discarded, which will remove the script channel map entry.
| /// Returns None if the URL has no host name. | ||
| /// Returns the registered suffix for the host name if it is a domain. | ||
| /// Leaves the host name alone if it is an IP address. | ||
| fn reg_host<'a>(&self, url: &'a ServoUrl) -> Option<&'a str> { |
There was a problem hiding this comment.
This can be a free function instead, since it never uses self.
| /// to receive sw manager message | ||
| swmanager_receiver: Receiver<SWManagerMsg>, | ||
|
|
||
| /// A map from top-level frame id and registered domain name to script channels. |
There was a problem hiding this comment.
Let's add a comment to the effect of "This double indirection ensures that separate tabs do not share script threads, even if the same domain is loaded in each."
5ab118f to
7ae19c0
Compare
|
@bors-servo r=jdm |
|
📌 Commit 7ae19c0 has been approved by |
…eads, r=jdm Share script threads by tab and by eTLD+1 <!-- Please describe your changes on the following line: --> This PR shares script threads among all similar-origin documents in the same tab. This allows DOM object to be shared among same-origin same-tab documents. --- <!-- 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 #633. - [X] These changes do not require tests because refactoring. <!-- 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/14211) <!-- Reviewable:end -->
|
☀️ Test successful - arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css, mac-rel-wpt1, mac-rel-wpt2, windows-dev |
This PR shares script threads among all similar-origin documents in the same tab. This allows DOM object to be shared among same-origin same-tab documents.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is