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

Share script threads by tab and by eTLD+1 #14211

Merged

Conversation

@asajeffrey
Copy link
Member

asajeffrey commented Nov 14, 2016

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 -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #633.
  • These changes do not require tests because refactoring.

This change is Reviewable

@highfive
Copy link

highfive commented Nov 14, 2016

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/dom/dedicatedworkerglobalscope.rs, components/script_traits/script_msg.rs, components/script_traits/script_msg.rs, components/script/script_thread.rs, components/script_traits/lib.rs, components/script_traits/lib.rs
  • @KiChjang: components/script/dom/dedicatedworkerglobalscope.rs, components/script_traits/script_msg.rs, components/script_traits/script_msg.rs, components/script/script_thread.rs, components/script_traits/lib.rs, components/script_traits/lib.rs
@asajeffrey asajeffrey changed the title S Share script threads by tab and by eTLD+1 Nov 14, 2016
@asajeffrey
Copy link
Member Author

asajeffrey commented Nov 14, 2016

There's two commits in this PR. The first one is #14173, the second one is the subject of this PR.

@bors-servo
Copy link
Contributor

bors-servo commented Nov 15, 2016

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

@asajeffrey asajeffrey force-pushed the asajeffrey:constellation-share-more-script-threads branch 2 times, most recently from 8db72d1 to 0f92143 Nov 15, 2016
@bors-servo
Copy link
Contributor

bors-servo commented Nov 17, 2016

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

@asajeffrey asajeffrey force-pushed the asajeffrey:constellation-share-more-script-threads branch from 0f92143 to daaf77a Nov 18, 2016
@asajeffrey asajeffrey force-pushed the asajeffrey:constellation-share-more-script-threads branch from daaf77a to 4ef42c1 Nov 21, 2016
@asajeffrey
Copy link
Member Author

asajeffrey commented Nov 21, 2016

This is now ready for review, since #14173 landed. @bors-servo r? @jdm

@highfive highfive assigned jdm and unassigned emilio Nov 21, 2016
@asajeffrey asajeffrey force-pushed the asajeffrey:constellation-share-more-script-threads branch from 4ef42c1 to 5c472e9 Nov 21, 2016
Copy link
Member

jdm left a 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.

@@ -162,19 +162,20 @@ impl LoadData {
}
}

/// 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.

This comment has been minimized.

Copy link
@jdm

jdm Nov 22, 2016

Member

s/associated/required/

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Nov 22, 2016

Author Member

Fixed.

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(),

This comment has been minimized.

Copy link
@jdm

jdm Nov 22, 2016

Member

We could keep trying other threads if sending to the first one fails. Maybe file as a followup?

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Nov 22, 2016

Author Member

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.

This comment has been minimized.

Copy link
@jdm

jdm Nov 22, 2016

Member

That does sound better. A followup would be good.

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Nov 22, 2016

Author Member

Filed #14328

is_private: bool) {
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.

This comment has been minimized.

Copy link
@jdm

jdm Nov 22, 2016

Member

I don't understand what this means. It doesn't sound possible as written.

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Nov 22, 2016

Author Member

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 pipeline_url = pipeline_id.and_then(|id| self.pipelines.get(&id).map(|pipeline| pipeline.url.clone()));
let parent_info = pipeline_id.and_then(|id| self.pipelines.get(&id).and_then(|pipeline| pipeline.parent_info));
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);

This comment has been minimized.

Copy link
@jdm

jdm Nov 22, 2016

Member

Should we remove any entries from the script channels map?

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Nov 22, 2016

Author Member

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> {

This comment has been minimized.

Copy link
@jdm

jdm Nov 22, 2016

Member

This can be a free function instead, since it never uses self.

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Nov 22, 2016

Author Member

Fixed.

@@ -133,6 +134,9 @@ pub struct Constellation<Message, LTF, STF> {
/// to receive sw manager message
swmanager_receiver: Receiver<SWManagerMsg>,

/// A map from top-level frame id and registered domain name to script channels.

This comment has been minimized.

Copy link
@jdm

jdm Nov 22, 2016

Member

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."

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Nov 22, 2016

Author Member

Done.

@jdm
jdm approved these changes Nov 22, 2016
@jdm jdm removed the S-awaiting-review label Nov 22, 2016
@asajeffrey asajeffrey force-pushed the asajeffrey:constellation-share-more-script-threads branch from 5ab118f to 7ae19c0 Nov 22, 2016
@asajeffrey
Copy link
Member Author

asajeffrey commented Nov 22, 2016

@bors-servo r=jdm

@bors-servo
Copy link
Contributor

bors-servo commented Nov 22, 2016

📌 Commit 7ae19c0 has been approved by jdm

@jdm jdm closed this Nov 22, 2016
@jdm jdm reopened this Nov 22, 2016
@bors-servo
Copy link
Contributor

bors-servo commented Nov 22, 2016

Testing commit 7ae19c0 with merge 1535f84...

bors-servo added a commit that referenced this pull request Nov 22, 2016
…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 -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 22, 2016

@bors-servo bors-servo merged commit 7ae19c0 into servo:master Nov 22, 2016
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

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