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
New Session History #20507
New Session History #20507
Conversation
Heads up! This PR modifies the following files:
|
@bors-servo try |
[WIP] New Session History <!-- Please describe your changes on the following line: --> --- <!-- 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. -->
💔 Test failed - linux-dev |
Hi @cbrewster I have a question: In the context of #20329, (before)unload, I have to find out from within I'm currently doing this there: https://github.com/servo/servo/pull/20329/files#diff-55c92a6a5ba7654ce45fe6fc6c63740fR2041, which happens by way of a message sent from https://github.com/servo/servo/pull/20329/files#diff-7ea9bf6c0d2a7a541eef145db84a6937R56 The reason for this extra step involving sending/receiving a message to/from the constellation, is that before deciding to unload and go ahead with the traversal, we first need to prompt the user(via a to be implemented blocking message send/receive to the embedder, and I believe we can't block from the constellation so it has to be done from script before sending the It's a bit of a hack, mostly replicating logic already found in Also, am I correct to think that the concept of the 'current entry' of a browsing context, is same as the 'active document' that the spec refers to? The spec refers to "A browsing context's active document is its WindowProxy object's [[Window]] internal slot value's associated Document.", which in Servo is a pipeline id, I assumed it's the same pipeline as the 'current entry', but wasn't sure. Thanks. |
OK, read through the current WIP, it looks much much nicer! Yay for not having to keep those timestamps around! A couple of questions... a) Way back when, we were keeping the session history as a list of pipeline ids, then we ripped it out and replaced it with the current solution of timestamps and explicit iterators. I'm not sure why we didn't go for this implementation then? Did we just not think of it? b) In I also need to think about how we're handling unloading documents, and when the session history gets updated. Also, it might be worth writing an addendum to the navigation history paper talking about this implementation strategy. |
a) The initial intention was to keep as close to the spec as possible while still having correct behavior. Unfortunately, that made it very difficult and complex to handle history state and discards. Since other browsers don't follow the spec either, I think its okay to do an implementation like this as long as the behavior matches. b) Yeah there are a lot of new structs that have slightly different purposes.
In the future I would plan to add a I'm open to any ideas on how to reduce the number of structs here. I would like to add this implementation to the paper and make sure it still meets all of the properties defined in the paper. @gterzian I'll have to think about unloading a bit more before I can give any concrete ideas. The active document of a browsing context is the same thing as the document of the current entry. So yes, the pipeline of the current entry is the "active document". |
Perhaps we can unify all the I think |
My concern with combining the As for servo/components/constellation/constellation.rs Lines 1684 to 1688 in 122bfa0
We could get the same pipeline by getting the active pipeline_id from the browsing context. |
Hmm, I see what you mean about the enum SessionHistoryDiff {
Initial {
pipeline_id: PipelineId,
browsing_context_id: BrowsingContextId,
load_data: LoadData,
},
Navigate {
old_pipeline_id: PipelineId,
new_pipeline_id: PipelineId,
browsing_context_id: BrowsingContextId,
old_load_data: LoadData,
new_load_data: LoadData,
},
PushState {
pipeline_id: PipelineId,
browsing_context_id: BrowsingContextId,
old_history_state: HistoryStateId,
new_history_state: HistoryStateId,
},
} I think the reason why we're keeping the old pipeline id in the change is so we can discard the change if the browsing context has already changed? E.g. a race between two navigations? |
IRC Chat: https://mozilla.logbot.info/servo/20180404#c14561798 |
6e433b1
to
35c1ade
Compare
@bors-servo try |
[WIP] New Session History <!-- Please describe your changes on the following line: --> Remaining Work: - [x] Move `LoadData` from `BrowsingContext` to `Pipeline` - [x] Cleanup `*Diff` and `*Changeset` types - [ ] Implement pipeline discarding and reloading - [ ] Document new code --- <!-- 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 - [ ] 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/20507) <!-- Reviewable:end -->
💔 Test failed - linux-rel-css |
@bors-servo try |
[WIP] New Session History <!-- Please describe your changes on the following line: --> Remaining Work: - [x] Move `LoadData` from `BrowsingContext` to `Pipeline` - [x] Cleanup `*Diff` and `*Changeset` types - [ ] Implement pipeline discarding and reloading - [ ] Document new code --- <!-- 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 - [ ] 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/20507) <!-- Reviewable:end -->
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
@@ -2470,7 +2464,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF> | |||
.filter_map(|maybe_pipeline| maybe_pipeline) | |||
.collect::<Vec<_>>(); | |||
|
|||
pipelines_to_evict.extend(session_history.future.iter() | |||
pipelines_to_evict.extend(session_history.future.iter().rev() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really? The session history future is in increasing chronological order isn't it? We should be evicting ones far off in the future, not the near future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we want to reverse here because this will put the diffs in the near future first, which we then skip by history_length
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay, this is much nicer!
@@ -29,72 +25,33 @@ pub struct BrowsingContext { | |||
/// The size of the frame. | |||
pub size: Option<TypedSize2D<f32, CSSPixel>>, | |||
|
|||
/// The timestamp for the current session history entry. | |||
pub instant: Instant, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay! No more timestamps!
@@ -277,6 +274,8 @@ pub struct Constellation<Message, LTF, STF> { | |||
/// to become same-origin, at which point they can share DOM objects. | |||
event_loops: HashMap<TopLevelBrowsingContextId, HashMap<Host, Weak<EventLoop>>>, | |||
|
|||
joint_session_histories: HashMap<TopLevelBrowsingContextId, SessionHistory>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bikeshed: should we rename SessionHistory
to TopLevelBrowsingContext
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IRC: JointSessionHistory
@@ -1732,14 +1661,17 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF> | |||
let IFrameLoadInfo { | |||
parent_pipeline_id, | |||
new_pipeline_id, | |||
replace, | |||
replace: _replace, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a ...
pattern for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops, meant to go and fix this...
match diff { | ||
SessionHistoryDiff::BrowsingContextDiff { | ||
browsing_context_id, | ||
ref new_pipeline_id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this ref
? Does PipelineId
not impl Copy
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an AliveOrDeadPipeline
which can't have Copy
since it may contain LoadData
. Probably could do better names here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see, yes a different name would help!
} | ||
|
||
for _ in 0..forward { | ||
let diff = session_history.future.pop().expect("Infallible"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this source of panic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
}, | ||
AliveOrDeadPipeline::Dead(pipeline_id, _) => { | ||
match *other { | ||
AliveOrDeadPipeline::Dead(other_pipeline_id, _) if pipeline_id == other_pipeline_id => true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
} | ||
|
||
impl PartialEq for AliveOrDeadPipeline { | ||
fn eq(&self, other: &AliveOrDeadPipeline) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment about why we're not just using the derived version.
match *self { | ||
SessionHistoryDiff::BrowsingContextDiff { ref mut old_pipeline_id, ref mut new_pipeline_id, .. } => { | ||
if *old_pipeline_id == *replaced_pipeline_id { | ||
*old_pipeline_id = pipeline_id.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we not copy the pipeline ids?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same this, this is an AliveOrDeadPipeline
which may contain LoadData
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable naming?
ports/servo/browser.rs
Outdated
@@ -122,14 +122,18 @@ impl Browser { | |||
} | |||
(CMD_OR_ALT, None, Key::Right) | (KeyModifiers::NONE, None, Key::NavigateForward) => { | |||
if let Some(id) = self.browser_id { | |||
let event = WindowEvent::Navigation(id, TraversalDirection::Forward(1)); | |||
self.event_queue.push(event); | |||
if state == KeyState::Pressed { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it should be in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
ports/servo/browser.rs
Outdated
let event = WindowEvent::Navigation(id, TraversalDirection::Back(1)); | ||
self.event_queue.push(event); | ||
if state == KeyState::Pressed { | ||
let event = WindowEvent::Navigation(id, TraversalDirection::Back(1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Remove the WIP tag? |
29b84e3
to
369b8e2
Compare
OK, just some minor nits left, then we can squash and merge! I will trust you to do that, and I'm on PTO tomorrow, so you can r=me. |
This new implementation of the session history keeps track of a single tree of browsing contexts and pipelines which represents the active entry of the session history and it keeps track of diffs between adjacent entries. This allows use to traverse across the joint session history by applying diffs to the active tree.
369b8e2
to
f3d068f
Compare
@bors-servo r=asajeffrey |
📌 Commit f3d068f has been approved by |
New Session History <!-- Please describe your changes on the following line: --> Remaining Work: - [x] Move `LoadData` from `BrowsingContext` to `Pipeline` - [x] Cleanup `*Diff` and `*Changeset` types - [x] Implement pipeline discarding and reloading - [x] Document new code --- <!-- 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 - [ ] 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/20507) <!-- Reviewable:end -->
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
Remaining Work:
LoadData
fromBrowsingContext
toPipeline
*Diff
and*Changeset
types./mach build -d
does not report any errors./mach test-tidy
does not report any errorsThis change is