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

Implement browsing context discarding #14559

Merged

Conversation

@asajeffrey
Copy link
Member

asajeffrey commented Dec 12, 2016

Implement browsing context discarding (https://html.spec.whatwg.org/multipage/browsers.html#discard-a-document).

  • When a pipeline is closed, inform the script thread whether the browsing context is to be discarded.
  • In script threads, synchronously discard any similar-origin documents and browsing contexts.
  • When a browsing context is discarded, it loses the reference to the active document, but the window keeps it, so we need to move the Document pointer from BrowsingContext to Window.
  • Fix the webIDL for Window to make parent and top optional (the spec says they can return null when the browsing context is discarded).

  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #14411
  • There are tests for these changes

This change is Reviewable

@highfive
Copy link

highfive commented Dec 12, 2016

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/dom/htmliframeelement.rs, components/script/dom/document.rs, components/script/dom/browsingcontext.rs, components/script_traits/script_msg.rs, components/script_traits/script_msg.rs, components/script/script_thread.rs, components/script/dom/window.rs, components/script/dom/webidls/Window.webidl, components/script_traits/lib.rs, components/script_traits/lib.rs
  • @KiChjang: components/script/dom/htmliframeelement.rs, components/script/dom/document.rs, components/script/dom/browsingcontext.rs, components/script_traits/script_msg.rs, components/script_traits/script_msg.rs, components/script/script_thread.rs, components/script/dom/window.rs, components/script/dom/webidls/Window.webidl, components/script_traits/lib.rs, components/script_traits/lib.rs
@asajeffrey
Copy link
Member Author

asajeffrey commented Dec 12, 2016

This should help with the crash we were seeing in #13996 (comment) (though that crash has mysteriously disappeared). cc @Ms2ger @jdm

@asajeffrey
Copy link
Member Author

asajeffrey commented Dec 12, 2016

Also see #14434

@bors-servo
Copy link
Contributor

bors-servo commented Dec 13, 2016

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

@asajeffrey asajeffrey force-pushed the asajeffrey:script-track-document-and-bc-discarding branch from 9d314d3 to 7f5f9d6 Dec 13, 2016
@bors-servo
Copy link
Contributor

bors-servo commented Dec 15, 2016

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

@asajeffrey asajeffrey force-pushed the asajeffrey:script-track-document-and-bc-discarding branch from 7f5f9d6 to 8be8c54 Dec 15, 2016
@bors-servo
Copy link
Contributor

bors-servo commented Dec 15, 2016

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

@asajeffrey asajeffrey force-pushed the asajeffrey:script-track-document-and-bc-discarding branch from 8be8c54 to c4d1813 Dec 23, 2016
@asajeffrey
Copy link
Member Author

asajeffrey commented Dec 23, 2016

Rebased. r? @ConnorGBrewster

@highfive highfive assigned cbrewster and unassigned wafflespeanut Dec 23, 2016
Copy link
Member

cbrewster left a comment

Looks good! Although it looks like removing the reference to the active document in the browsing context caused a couple of regressions. I think we should find a way to fix those before merging.

Also since the BS doesn't store the active document, we will need to find a way to determine if the document is active vs fully_active.

@@ -3190,8 +3187,8 @@ impl DocumentMethods for Document {

// Step 2.
// TODO: handle throw-on-dynamic-markup-insertion counter.

if !self.is_active() {
// FIXME: this should check for being active rather than fully active

This comment has been minimized.

Copy link
@cbrewster

cbrewster Dec 23, 2016

Member

Should we implement is_active again before merging this?

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Dec 23, 2016

Author Member

The problem is that we're currently not sending enough information from the constellation to the script thread to determine if a document is active. We're sending freeze/thaw messages to determine if a document is fully active, but not any messages about being active. I think this is a spec issue, the spec should really say "fully active" here.

@@ -2304,7 +2295,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}
}
for entry in evicted_pipelines {
self.close_pipeline(entry.pipeline_id, ExitPipelineMode::Normal);
self.close_pipeline(entry.pipeline_id, DiscardBrowsingContext::No, ExitPipelineMode::Normal);

This comment has been minimized.

Copy link
@cbrewster

cbrewster Dec 23, 2016

Member

Why do we not discard the Browsing Context here?

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Dec 23, 2016

Author Member

This code is used when a browsing context navigates, we don't want to close the BC in this case. Nested BCs will get closed, when the recursive call is made it's with DiscardBrowsingContext::Yes.

}

pub fn active_document(&self) -> Root<Document> {

This comment has been minimized.

Copy link
@cbrewster

cbrewster Dec 23, 2016

Member

What are the reasons behind not storing a reference to the Document in the BC?

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Dec 23, 2016

Author Member

We never needed it, so I removed it! SpiderMonkey does the dance to resolve WindowProxy to Window, which tracks the current document.

}
// TODO Step 3.

This comment has been minimized.

Copy link
@cbrewster

cbrewster Dec 23, 2016

Member

I think we should find a way to do this, and other cases that may have regressed with this PR before merging.

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Dec 23, 2016

Author Member

I think it's broken in the same way as it was before. Did this cause a regression?

@@ -1345,6 +1357,13 @@ impl Window {
unsafe { SetWindowProxy(cx, window, browsing_context.reflector().get_jsobject()); }
}

#[allow(unsafe_code)]

This comment has been minimized.

Copy link
@cbrewster

cbrewster Dec 23, 2016

Member

Is this needed?

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Dec 23, 2016

Author Member

Good catch.

@@ -183,6 +183,15 @@ pub struct NewLayoutInfo {
pub layout_threads: usize,
}

/// When a pipeline is closed, should its browsing context be discarded too?

This comment has been minimized.

Copy link
@cbrewster

cbrewster Dec 23, 2016

Member

Maybe add a spec link here that discussing when to discard browsing contexts?

@bors-servo
Copy link
Contributor

bors-servo commented Dec 24, 2016

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

@asajeffrey asajeffrey force-pushed the asajeffrey:script-track-document-and-bc-discarding branch from e3788d8 to 7c2de62 Jan 5, 2017
@asajeffrey
Copy link
Member Author

asajeffrey commented Jan 5, 2017

Rebased.

@asajeffrey
Copy link
Member Author

asajeffrey commented Jan 5, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Jan 5, 2017

Trying commit 7c2de62 with merge c0706a2...

bors-servo added a commit that referenced this pull request Jan 5, 2017
…ding, r=<try>

Implement browsing context discarding

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

Implement browsing context discarding (https://html.spec.whatwg.org/multipage/browsers.html#discard-a-document).

* When a pipeline is closed, inform the script thread whether the browsing context is to be discarded.
* In script threads, synchronously discard any similar-origin documents and browsing contexts.
* When a browsing context is discarded, it loses the reference to the active document, but the window keeps it, so we need to move the `Document` pointer from `BrowsingContext` to `Window`.
* Fix the webIDL for Window to make parent and top optional (the spec says they can return null when the browsing context is discarded).

---
<!-- 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 #14411
- [X] There are tests for these changes

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

bors-servo commented Jan 5, 2017

💔 Test failed - linux-rel-wpt

@jdm
Copy link
Member

jdm commented Jan 6, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Jan 6, 2017

Trying commit 7c2de62 with merge 1d5503b...

bors-servo added a commit that referenced this pull request Jan 6, 2017
…ding, r=<try>

Implement browsing context discarding

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

Implement browsing context discarding (https://html.spec.whatwg.org/multipage/browsers.html#discard-a-document).

* When a pipeline is closed, inform the script thread whether the browsing context is to be discarded.
* In script threads, synchronously discard any similar-origin documents and browsing contexts.
* When a browsing context is discarded, it loses the reference to the active document, but the window keeps it, so we need to move the `Document` pointer from `BrowsingContext` to `Window`.
* Fix the webIDL for Window to make parent and top optional (the spec says they can return null when the browsing context is discarded).

---
<!-- 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 #14411
- [X] There are tests for these changes

<!-- 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/14559)
<!-- Reviewable:end -->
@cbrewster
Copy link
Member

cbrewster commented Jan 6, 2017

@bors-servo r+ retry

@bors-servo
Copy link
Contributor

bors-servo commented Jan 6, 2017

📌 Commit 7c2de62 has been approved by cbrewster

@bors-servo
Copy link
Contributor

bors-servo commented Jan 6, 2017

Testing commit 7c2de62 with merge 8b274f2...

bors-servo added a commit that referenced this pull request Jan 6, 2017
…ding, r=cbrewster

Implement browsing context discarding

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

Implement browsing context discarding (https://html.spec.whatwg.org/multipage/browsers.html#discard-a-document).

* When a pipeline is closed, inform the script thread whether the browsing context is to be discarded.
* In script threads, synchronously discard any similar-origin documents and browsing contexts.
* When a browsing context is discarded, it loses the reference to the active document, but the window keeps it, so we need to move the `Document` pointer from `BrowsingContext` to `Window`.
* Fix the webIDL for Window to make parent and top optional (the spec says they can return null when the browsing context is discarded).

---
<!-- 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 #14411
- [X] There are tests for these changes

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

bors-servo commented Jan 6, 2017

@bors-servo bors-servo merged commit 7c2de62 into servo:master Jan 6, 2017
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
@bors-servo bors-servo mentioned this pull request Jan 6, 2017
3 of 5 tasks complete
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.