Skip to content

Script thread with no root document#14013

Merged
bors-servo merged 1 commit intoservo:masterfrom
asajeffrey:script-thread-no-root-document
Nov 8, 2016
Merged

Script thread with no root document#14013
bors-servo merged 1 commit intoservo:masterfrom
asajeffrey:script-thread-no-root-document

Conversation

@asajeffrey
Copy link
Copy Markdown
Contributor

@asajeffrey asajeffrey commented Nov 1, 2016

This PR removes the single root document from the script thread, and replaces it by a lookup table from PipelineIds to Documents. This is needed if we're going to share script threads, as per #633.

The last commit is the one that matters, the ones before are #13646.

cc @jdm @Ms2ger @ConnorGBrewster


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes do not require tests because refactoring

This change is Reviewable

@asajeffrey asajeffrey added the A-content/script Related to the script thread label Nov 1, 2016
@highfive highfive assigned ghost Nov 1, 2016
@highfive
Copy link
Copy Markdown

highfive commented Nov 1, 2016

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/dom/htmliframeelement.rs, components/script/dom/document.rs, components/script/webdriver_handlers.rs, components/script/dom/node.rs, components/script/dom/browsingcontext.rs, components/script/dom/storage.rs, components/script_traits/script_msg.rs, components/script_traits/script_msg.rs, components/script/document_loader.rs, components/script/dom/nodelist.rs, components/script/script_thread.rs, components/script_traits/lib.rs, components/script_traits/lib.rs, components/script/devtools.rs
  • @KiChjang: components/script/dom/htmliframeelement.rs, components/script/dom/document.rs, components/script/webdriver_handlers.rs, components/net/http_loader.rs, components/script/dom/node.rs, components/script/dom/browsingcontext.rs, components/script/dom/storage.rs, components/script_traits/script_msg.rs, components/script_traits/script_msg.rs, components/script/document_loader.rs, components/script/dom/nodelist.rs, components/script/script_thread.rs, components/script_traits/lib.rs, components/script_traits/lib.rs, components/script/devtools.rs

@highfive
Copy link
Copy Markdown

highfive commented Nov 1, 2016

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Nov 1, 2016
for it_context in root_context.iter() {
let current_url = it_context.active_document().url().to_string();
for document in self.documents.borrow().iter() {
let current_url = document.url().to_string();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might be able to get by with let current_url = document.url().as_str(); here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a bit trickier than that, but I did manage to avoid double-copying the urls here.

@emilio
Copy link
Copy Markdown
Member

emilio commented Nov 1, 2016

@bors-servo try

@bors-servo
Copy link
Copy Markdown
Contributor

⌛ Trying commit d8de7de with merge 2d7d730...

bors-servo pushed a commit that referenced this pull request Nov 1, 2016
…try>

Script thread with no root document

<!-- Please describe your changes on the following line: -->

This PR removes the single root document from the script thread, and replaces it by a lookup table from `PipelineId`s to `Document`s. This is needed if we're going to share script threads, as per #633.

The last commit is the one that matters, the ones before are #13646.

cc @jdm @Ms2ger @ConnorGBrewster
---
<!-- 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 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/14013)
<!-- Reviewable:end -->
@bors-servo
Copy link
Copy Markdown
Contributor

☀️ 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

@asajeffrey asajeffrey force-pushed the script-thread-no-root-document branch from 35a6929 to 7bc34d0 Compare November 2, 2016 20:20
@asajeffrey
Copy link
Copy Markdown
Contributor Author

Rebased. @bors-servo try

@bors-servo
Copy link
Copy Markdown
Contributor

⌛ Trying commit 18b7b5d with merge 2a6c3bb...

bors-servo pushed a commit that referenced this pull request Nov 2, 2016
…try>

Script thread with no root document

<!-- Please describe your changes on the following line: -->

This PR removes the single root document from the script thread, and replaces it by a lookup table from `PipelineId`s to `Document`s. This is needed if we're going to share script threads, as per #633.

The last commit is the one that matters, the ones before are #13646.

cc @jdm @Ms2ger @ConnorGBrewster
---
<!-- 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 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/14013)
<!-- Reviewable:end -->
@bors-servo
Copy link
Copy Markdown
Contributor

💥 Test timed out

@jdm
Copy link
Copy Markdown
Member

jdm commented Nov 3, 2016

@bors-servo: try

@jdm
Copy link
Copy Markdown
Member

jdm commented Nov 3, 2016

@bors-servo: retry

@bors-servo
Copy link
Copy Markdown
Contributor

⌛ Trying commit 18b7b5d with merge 4fe3e6f...

bors-servo pushed a commit that referenced this pull request Nov 3, 2016
…try>

Script thread with no root document

<!-- Please describe your changes on the following line: -->

This PR removes the single root document from the script thread, and replaces it by a lookup table from `PipelineId`s to `Document`s. This is needed if we're going to share script threads, as per #633.

The last commit is the one that matters, the ones before are #13646.

cc @jdm @Ms2ger @ConnorGBrewster
---
<!-- 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 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/14013)
<!-- Reviewable:end -->
@bors-servo
Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel-css

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label Nov 3, 2016
@asajeffrey
Copy link
Copy Markdown
Contributor Author

  ▶ CRASH [expected FAIL] /css-text-3_dev/html/line-break-strict-017.htm
  │ 
  │ VMware, Inc.
  │ Gallium 0.4 on softpipe
  │ 3.3 (Core Profile) Mesa 12.0.1
  │ called `Result::unwrap()` on an `Err` value: IoError(Error { repr: Os { code: 104, message: "Connection reset by peer" } }) (thread main, at ../src/libcore/result.rs:837)
  │ stack backtrace:
  │    0:     0x7ffc0078f3ad - backtrace::backtrace::trace::h16372ee7bf1517e5
  │    1:     0x7ffc0078fa42 - backtrace::capture::Backtrace::new::hcc43c50c4b11c693
  │    2:     0x7ffbff126e7d - servo::main::_{{closure}}::h993bd385ff269be0
  │    3:     0x7ffc00d52b74 - std::panicking::rust_panic_with_hook
  │                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:452
  │    4:     0x7ffc00d52a34 - std::panicking::begin_panic<collections::string::String>
  │                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:413
  │    5:     0x7ffc00d52959 - std::panicking::begin_panic_fmt
  │                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:397
  │    6:     0x7ffc00d528e7 - std::panicking::rust_begin_panic
  │                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:373
  │    7:     0x7ffc00d8f34d - core::panicking::panic_fmt
  │                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libcore/panicking.rs:69
  │    8:     0x7ffc008202df - core::result::unwrap_failed::h97cf4d1c2597280e
  │    9:     0x7ffc008213d2 - webrender_traits::api::_<impl webrender_traits..RenderApiSender>::create_api::h8aae9b868a4fcac9
  │   10:     0x7ffbff1248fd - servo::main::hf0cef208a66e3646
  │   11:     0x7ffc00d5b1da - panic_unwind::__rust_maybe_catch_panic
  │                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libpanic_unwind/lib.rs:97
  │   12:     0x7ffc00d51b9a - std::panicking::try<(),fn()>
  │                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:332
  │                          - std::panic::catch_unwind<fn(),()>
  │                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/panic.rs:351
  │                          - std::rt::lang_start
  │                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/rt.rs:57
  │   13:     0x7ffbfca39f44 - __libc_start_main
  │   14:     0x7ffbff0f9909 - <unknown>
  │   15:                0x0 - <unknown>
  │ thread panicked while processing panic. aborting.
  └ thread panicked while processing panic. aborting.

@asajeffrey
Copy link
Copy Markdown
Contributor Author

Looks like #13480.

@asajeffrey asajeffrey added the S-needs-squash Some (or all) of the commits in the PR should be combined. label Nov 3, 2016
@bors-servo
Copy link
Copy Markdown
Contributor

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

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Nov 3, 2016
@asajeffrey asajeffrey force-pushed the script-thread-no-root-document branch from 18b7b5d to 1080827 Compare November 3, 2016 20:57
@highfive highfive removed the S-tests-failed The changes caused existing tests to fail. label Nov 3, 2016
@asajeffrey
Copy link
Copy Markdown
Contributor Author

Rebased and squashed. @bors-servo try

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. S-needs-squash Some (or all) of the commits in the PR should be combined. labels Nov 8, 2016
@bors-servo
Copy link
Copy Markdown
Contributor

⌛ Testing commit ae9268d with merge 8236d19...

bors-servo pushed a commit that referenced this pull request Nov 8, 2016
Script thread with no root document

<!-- Please describe your changes on the following line: -->

This PR removes the single root document from the script thread, and replaces it by a lookup table from `PipelineId`s to `Document`s. This is needed if we're going to share script threads, as per #633.

The last commit is the one that matters, the ones before are #13646.

cc @jdm @Ms2ger @ConnorGBrewster
---
<!-- 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 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/14013)
<!-- Reviewable:end -->
@bors-servo
Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel-wpt

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Nov 8, 2016
@asajeffrey
Copy link
Copy Markdown
Contributor Author

Hmm, failing tests. Puts on debugging hat...

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Nov 8, 2016
@asajeffrey asajeffrey added S-needs-squash Some (or all) of the commits in the PR should be combined. S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Nov 8, 2016
@asajeffrey asajeffrey force-pushed the script-thread-no-root-document branch from b779e69 to 90e9c91 Compare November 8, 2016 16:49
@asajeffrey asajeffrey removed the S-needs-squash Some (or all) of the commits in the PR should be combined. label Nov 8, 2016
@asajeffrey
Copy link
Copy Markdown
Contributor Author

@bors-servo r=jdm

@bors-servo
Copy link
Copy Markdown
Contributor

📌 Commit 90e9c91 has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 8, 2016
@bors-servo
Copy link
Copy Markdown
Contributor

⌛ Testing commit 90e9c91 with merge d1b7f19...

bors-servo pushed a commit that referenced this pull request Nov 8, 2016
Script thread with no root document

<!-- Please describe your changes on the following line: -->

This PR removes the single root document from the script thread, and replaces it by a lookup table from `PipelineId`s to `Document`s. This is needed if we're going to share script threads, as per #633.

The last commit is the one that matters, the ones before are #13646.

cc @jdm @Ms2ger @ConnorGBrewster
---
<!-- 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 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/14013)
<!-- Reviewable:end -->
@bors-servo
Copy link
Copy Markdown
Contributor

@bors-servo bors-servo merged commit 90e9c91 into servo:master Nov 8, 2016
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Nov 8, 2016
bors-servo pushed a commit that referenced this pull request Nov 9, 2016
…-lifetime, r=jdm

Constellation manages script thread lifetime

<!-- Please describe your changes on the following line: -->

Yet another step towards fixing #633...

At the moment, script threads are responsible for killing themselves when they have no more pipelines to manage. This is fine right now, because script threads have a root pipeline: once it is closed, everything is closed. It's not fine once we fix #633 because there's a race condition where the constellation could kill the last pipeline in a script thread, then open a new one in the same script thread.

We can't have the constellation block on the script thread, waiting to make sure a pipeline is created, since this could introduce deadlock. The easiest solution is to have the constellation manage the script thread lifetime: when the constellation discovers that a script thread is not managing any live pipelines, it closes the script thread, and updates its own state.

Most of the commits are from #14013, its just "Script thread lifetime is now managed by the constellation." (9ac6e4d) that's new.

cc @jdm @ConnorGBrewster

---
<!-- 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 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/14052)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-content/script Related to the script thread

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants