Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upFrame should store some of the data that is currently in Pipeline #14692 #21559
Conversation
highfive
commented
Aug 31, 2018
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @gw3583 (or someone else) soon. |
highfive
commented
Aug 31, 2018
|
Heads up! This PR modifies the following files:
|
|
r? @cbrewster |
|
Thank you for working on this, I think this is a good improvement. There are quite a few times where we are now nesting lookups. pipeline ID -> pipeline -> BC ID -> BC. I would prefer trying to keep things more flat that nesting. Ex: let browsing_context_id = self.pipelines.get(&pipeline_id) {
Some(pipeline) => pipeline.browsing_context_id,
None => warn!(...),
};
let (...) = match self.browsing_contexts.get(&browsing_context_id) {
Some(browsing_context) => (...),
None => warn!(...),
}; |
| @@ -1244,13 +1239,17 @@ where | |||
| warn!("Sending reply to get browsing context failed ({:?}).", e); | |||
| } | |||
| }, | |||
| // TODO(mandreyel): maybe change semantics of this message to | |||
This comment has been minimized.
This comment has been minimized.
cbrewster
Aug 31, 2018
Member
This would be a good change and could remove some extra messages sent to the constellation.
See:
servo/components/script/script_thread.rs
Lines 2115 to 2136 in 2351872
Specifically, we shouldn't need to have this line:
servo/components/script/script_thread.rs
Line 2122 in 2351872
I'm not sure how involved this change would be, so it may be a good followup.
This comment has been minimized.
This comment has been minimized.
mandreyel
Aug 31, 2018
Author
Contributor
I think I'll leave this to another PR (I'd like to do it!) to keep things neatly isolated, if that's alright.
This comment has been minimized.
This comment has been minimized.
mandreyel
Sep 1, 2018
Author
Contributor
Hmm, yeah, this could actually be coalesced into a single message to constellation. Something like ScriptMsg::GetBrowsingContextInfo(PipelineId) that returns the most relevant fields (in this case browsing_context_id and parent_pipeline_id).
This comment has been minimized.
This comment has been minimized.
| let pipeline_id = browsing_context.map(|browsing_context| browsing_context.pipeline_id); | ||
| (window_size, pipeline_id) | ||
| let window_size = browsing_context.and_then(|context| context.size); | ||
| // TODO(mandreyel): browsing_context_id was originally |
This comment has been minimized.
This comment has been minimized.
cbrewster
Aug 31, 2018
Member
You are correct, the parent should always be None since we get the top level browsing context. You can remove the code that gets the parent pipeline id and change the call to self.new_pipeline to pass None as the parent info.
| None => return debug!("Pipeline {} has no parent.", pipeline_id), | ||
| Some(pipeline) => match self.browsing_contexts.get(&pipeline.browsing_context_id) { | ||
| Some(browsing_context) => (browsing_context.id, browsing_context.parent_pipeline_id), | ||
| // TODO(mandreyel): message? |
This comment has been minimized.
This comment has been minimized.
| ), | ||
| None => { | ||
| return warn!( | ||
| // TODO(mandreyel): message? |
This comment has been minimized.
This comment has been minimized.
| match self.browsing_contexts.get(&parent_browsing_context_id) { | ||
| Some(browsing_context) => (browsing_context.is_private, browsing_context.is_visible), | ||
| None => { | ||
| // TODO(mandreyel): message? |
This comment has been minimized.
This comment has been minimized.
| pipeline.browsing_context_id, | ||
| browsing_context.parent_pipeline_id, | ||
| ), | ||
| // TODO(mandreyel): message? |
This comment has been minimized.
This comment has been minimized.
| @@ -2664,12 +2774,26 @@ where | |||
| } | |||
| } | |||
|
|
|||
| fn handle_focus_msg(&mut self, pipeline_id: PipelineId) { | |||
This comment has been minimized.
This comment has been minimized.
cbrewster
Aug 31, 2018
Member
Would you be willing to also change the constellation to track a focused BrowsingContext rather than a focused Pipeline? If not, that can be done as a followup.
This comment has been minimized.
This comment has been minimized.
mandreyel
Aug 31, 2018
Author
Contributor
Yes, in fact that's the next issue I want to be working on but I thought I'd keep that as a separate PR :)
This comment has been minimized.
This comment has been minimized.
| @@ -2717,24 +2834,41 @@ where | |||
| }, | |||
| }; | |||
|
|
|||
| let child_pipeline_ids: Vec<PipelineId> = self | |||
| // TODO(mandreyel): can we make a mutable version of | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
mandreyel
Aug 31, 2018
Author
Contributor
I think this could be a separate PR since it's a minor optimization and not directly related to this PR. What do you think?
This comment has been minimized.
This comment has been minimized.
| browsing_context.id, | ||
| browsing_context.parent_pipeline_id, | ||
| ), | ||
| // TODO(mandreyel): is this warning message ok? |
This comment has been minimized.
This comment has been minimized.
cbrewster
Aug 31, 2018
Member
I would have it be:
warn!("Visibility change for closed browsing context {:?}.", pipeline.browsing_context_id) It's good to include a little context in the warning message (like "visibility change") so we can quickly figure out where the warning was triggered.
| load_data: load_data, | ||
| history_state_id: None, | ||
| history_states: HashSet::new(), | ||
| }; | ||
|
|
||
| pipeline.notify_visibility(); |
This comment has been minimized.
This comment has been minimized.
cbrewster
Aug 31, 2018
Member
It may be good to keep this here and pass in the visibility to this function, I am worried that there may be times where Pipeline::new is called but notify_visibility is not.
This comment has been minimized.
This comment has been minimized.
mandreyel
Aug 31, 2018
Author
Contributor
Yes, I was a bit torn on this. On the one hand, it seems to me that the "constructor" shoudn't do a lot of extra work apart from setting up the object, but on the other hand it is indeed error prone to let the user take care of always calling notify_visibility. I guess avoiding potential errors is a higher priority, so I'll change it back.
This comment has been minimized.
This comment has been minimized.
cbrewster
Sep 1, 2018
Member
Agreed, Ideally this would be inside of Constellation::new_pipeline and that would be the only way pipelines are constructed in the constellation, but multiple edge cases caused us to use Pipeline::new directly in multiple placed
|
I would prefer adding a |
|
Thanks a lot for taking time to look at this! I'll try to implement the fixes asap. |
|
Okay, I did a few changes. Looking at it now, it does not seem like encapsulating the fields in Can you please double-check that the places I've added Thanks! |
|
Oh, damn, I see I messed up the commit history and introduced a bug. Let me fix that real quick. EDIT: OK, done. |
195f2ba
to
2acc818
|
Nearly there! Make sure to remove the leftover It would be great if you could create issues for the followups you are planning to do (if one does not already exist). |
| load_data: load_data, | ||
| history_state_id: None, | ||
| history_states: HashSet::new(), | ||
| }; | ||
|
|
||
| pipeline.notify_visibility(); |
This comment has been minimized.
This comment has been minimized.
cbrewster
Sep 1, 2018
Member
Agreed, Ideally this would be inside of Constellation::new_pipeline and that would be the only way pipelines are constructed in the constellation, but multiple edge cases caused us to use Pipeline::new directly in multiple placed
| @@ -1244,13 +1239,17 @@ where | |||
| warn!("Sending reply to get browsing context failed ({:?}).", e); | |||
| } | |||
| }, | |||
| // TODO(mandreyel): maybe change semantics of this message to | |||
This comment has been minimized.
This comment has been minimized.
| browsing_context.is_visible, | ||
| ), | ||
| None => { | ||
| // TODO(mandreyel): message? |
This comment has been minimized.
This comment has been minimized.
| @@ -2664,12 +2774,26 @@ where | |||
| } | |||
| } | |||
|
|
|||
| fn handle_focus_msg(&mut self, pipeline_id: PipelineId) { | |||
This comment has been minimized.
This comment has been minimized.
| @@ -2717,24 +2834,41 @@ where | |||
| }, | |||
| }; | |||
|
|
|||
| let child_pipeline_ids: Vec<PipelineId> = self | |||
| // TODO(mandreyel): can we make a mutable version of | |||
This comment has been minimized.
This comment has been minimized.
|
Sorry I missed the changes for the |
| // | ||
| // If this browsing context didn't exist, insert a pending info | ||
| // entry so that we can construct it later. | ||
| new_browsing_context_info: Some(NewBrowsingContextInfo { |
This comment has been minimized.
This comment has been minimized.
cbrewster
Sep 1, 2018
Member
This can be None since the browsing_context_id is from an already existing browsing context.
| replace: Some(NeedsToReload::Yes(pipeline_id, load_data.clone())), | ||
| is_private: is_private, | ||
| is_visible: is_visible, | ||
| // TODO(mandreyel): browsing context must exist at this |
This comment has been minimized.
This comment has been minimized.
| @@ -8,6 +8,27 @@ use pipeline::Pipeline; | |||
| use std::collections::{HashMap, HashSet}; | |||
| use style_traits::CSSPixel; | |||
|
|
|||
| // TODO(mandreyel): is this explanation lucid enough? | |||
This comment has been minimized.
This comment has been minimized.
| let new_context_info = match change.new_browsing_context_info { | ||
| Some(new_context_info) => new_context_info, | ||
| None => { | ||
| return warn!( |
This comment has been minimized.
This comment has been minimized.
cbrewster
Sep 1, 2018
Member
It's unfortunate that we have to add this check here, but I'm not sure of a way around it at the moment.
This comment has been minimized.
This comment has been minimized.
mandreyel
Sep 1, 2018
Author
Contributor
Yeah, I agree. While overall the introduction of NewBrowsingContextInfo makes the code cleaner and more explicit, this is an unfortunate side effect.
It could be solved by moving parent_pipeline_id back to SessionHistoryChange and always setting it so that it's available in this function, but that kind of muddies the semantics, since most of the time the field isn't actually needed by whoever uses SessionHistoryChange.
|
@bors-servo try |
…r=<try> Frame should store some of the data that is currently in Pipeline #14692 <!-- Please describe your changes on the following line: --> Apologies, meant to land it sooner but deadline at work got hectic. So I moved the `Pipeline::{visible, is_private, parent_info}` fields (`size` was moved earlier) to `BrowsingContext`, and renamed them where appropriate (and did some minor refactoring on the side, hope that's alright). This introduced some complications, because when a pipeline is spawned for a browsing context that does not yet exist, the browsing context won't be constructed until after pipeline has made its document active. Thus, values for the fields that used to be in `Pipeline` and are now in `BrowsingContext` could not be easily retrieved when constructing the `BrowsingContext` (since in most cases they were only available when spawning a pipeline). For this reason, I've put these fields in `SessionHistoryChange` since one is always created and added to `Constellation::pending_changes` when a new pipeline is created, so it provides an easy way to forward the necessary values to new `BrowsingContext`s. Though frankly I'm not sure I like expanding `SessionHistoryChange`'s purpose to serve as a crutch to construct browsing contexts, so a way to uncouple purposes would be to separately store the values for a to-be-created `BrowsingContext` in a collection of structs in `Constellation` and consume them when a new `BrowsingContext` is created. Here's a PoC: mandreyel@6fa2160. I didn't include this by default because it introduces a little overhead. Perhaps `PendingBrowsingContextInfo` could be stored as an `Option<>` next to a `SessionHistoryChange` in `Constellation::pending_changes`? That'd uncouple the two structs but not incur any overhead. I don't think it's finished, so I've marked some areas where I need input on small matters with `TODO(mandreyel)`, but the general idea is done. I'll be sure to squash commits when no further changes need be done! --- <!-- 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 #14692. <!-- Either: --> - [x] These changes do not require tests because no new features or behaviour were introduced. <!-- 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/21559) <!-- Reviewable:end -->
|
|
…r=cbrewster Frame should store some of the data that is currently in Pipeline #14692 <!-- Please describe your changes on the following line: --> Apologies, meant to land it sooner but deadline at work got hectic. So I moved the `Pipeline::{visible, is_private, parent_info}` fields (`size` was moved earlier) to `BrowsingContext`, and renamed them where appropriate (and did some minor refactoring on the side, hope that's alright). This introduced some complications, because when a pipeline is spawned for a browsing context that does not yet exist, the browsing context won't be constructed until after pipeline has made its document active. Thus, values for the fields that used to be in `Pipeline` and are now in `BrowsingContext` could not be easily retrieved when constructing the `BrowsingContext` (since in most cases they were only available when spawning a pipeline). For this reason, I've put these fields in `SessionHistoryChange` since one is always created and added to `Constellation::pending_changes` when a new pipeline is created, so it provides an easy way to forward the necessary values to new `BrowsingContext`s. Though frankly I'm not sure I like expanding `SessionHistoryChange`'s purpose to serve as a crutch to construct browsing contexts, so a way to uncouple purposes would be to separately store the values for a to-be-created `BrowsingContext` in a collection of structs in `Constellation` and consume them when a new `BrowsingContext` is created. Here's a PoC: mandreyel@6fa2160. I didn't include this by default because it introduces a little overhead. Perhaps `PendingBrowsingContextInfo` could be stored as an `Option<>` next to a `SessionHistoryChange` in `Constellation::pending_changes`? That'd uncouple the two structs but not incur any overhead. I don't think it's finished, so I've marked some areas where I need input on small matters with `TODO(mandreyel)`, but the general idea is done. I'll be sure to squash commits when no further changes need be done! --- <!-- 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 #14692. <!-- Either: --> - [x] These changes do not require tests because no new features or behaviour were introduced. <!-- 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/21559) <!-- Reviewable:end -->
|
|
|
I am not sure whether to be worried about this:
|
|
@jdm Hmm :/ I ran the |
|
E.g. this is what I get on master (2351872) on a debug build:
|
|
I'm willing to believe it's a latest intermittent failure that just hasn't hit us before. |
…r=cbrewster Frame should store some of the data that is currently in Pipeline #14692 <!-- Please describe your changes on the following line: --> Apologies, meant to land it sooner but deadline at work got hectic. So I moved the `Pipeline::{visible, is_private, parent_info}` fields (`size` was moved earlier) to `BrowsingContext`, and renamed them where appropriate (and did some minor refactoring on the side, hope that's alright). This introduced some complications, because when a pipeline is spawned for a browsing context that does not yet exist, the browsing context won't be constructed until after pipeline has made its document active. Thus, values for the fields that used to be in `Pipeline` and are now in `BrowsingContext` could not be easily retrieved when constructing the `BrowsingContext` (since in most cases they were only available when spawning a pipeline). For this reason, I've put these fields in `SessionHistoryChange` since one is always created and added to `Constellation::pending_changes` when a new pipeline is created, so it provides an easy way to forward the necessary values to new `BrowsingContext`s. Though frankly I'm not sure I like expanding `SessionHistoryChange`'s purpose to serve as a crutch to construct browsing contexts, so a way to uncouple purposes would be to separately store the values for a to-be-created `BrowsingContext` in a collection of structs in `Constellation` and consume them when a new `BrowsingContext` is created. Here's a PoC: mandreyel@6fa2160. I didn't include this by default because it introduces a little overhead. Perhaps `PendingBrowsingContextInfo` could be stored as an `Option<>` next to a `SessionHistoryChange` in `Constellation::pending_changes`? That'd uncouple the two structs but not incur any overhead. I don't think it's finished, so I've marked some areas where I need input on small matters with `TODO(mandreyel)`, but the general idea is done. I'll be sure to squash commits when no further changes need be done! --- <!-- 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 #14692. <!-- Either: --> - [x] These changes do not require tests because no new features or behaviour were introduced. <!-- 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/21559) <!-- Reviewable:end -->
|
|
|
@bors-servo retry |
…r=cbrewster Frame should store some of the data that is currently in Pipeline #14692 <!-- Please describe your changes on the following line: --> Apologies, meant to land it sooner but deadline at work got hectic. So I moved the `Pipeline::{visible, is_private, parent_info}` fields (`size` was moved earlier) to `BrowsingContext`, and renamed them where appropriate (and did some minor refactoring on the side, hope that's alright). This introduced some complications, because when a pipeline is spawned for a browsing context that does not yet exist, the browsing context won't be constructed until after pipeline has made its document active. Thus, values for the fields that used to be in `Pipeline` and are now in `BrowsingContext` could not be easily retrieved when constructing the `BrowsingContext` (since in most cases they were only available when spawning a pipeline). For this reason, I've put these fields in `SessionHistoryChange` since one is always created and added to `Constellation::pending_changes` when a new pipeline is created, so it provides an easy way to forward the necessary values to new `BrowsingContext`s. Though frankly I'm not sure I like expanding `SessionHistoryChange`'s purpose to serve as a crutch to construct browsing contexts, so a way to uncouple purposes would be to separately store the values for a to-be-created `BrowsingContext` in a collection of structs in `Constellation` and consume them when a new `BrowsingContext` is created. Here's a PoC: mandreyel@6fa2160. I didn't include this by default because it introduces a little overhead. Perhaps `PendingBrowsingContextInfo` could be stored as an `Option<>` next to a `SessionHistoryChange` in `Constellation::pending_changes`? That'd uncouple the two structs but not incur any overhead. I don't think it's finished, so I've marked some areas where I need input on small matters with `TODO(mandreyel)`, but the general idea is done. I'll be sure to squash commits when no further changes need be done! --- <!-- 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 #14692. <!-- Either: --> - [x] These changes do not require tests because no new features or behaviour were introduced. <!-- 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/21559) <!-- Reviewable:end -->
|
|
…s, r=paulrouget Create ScriptMsg::GetBrowsingContextInfo Script used to send two messages to constellation to first retrieve the id of the browsing context in which a pipeline resides and then its parent pipeline's id. This patch introduces a minor optimization to instead retrieve those fields in a single message. Also, fixed a potential bug introduced in #21559 where if a browsing context wasn't found for a pipeline in response to `GetParentInfo` (which is now deleted), constellation sent nothing back, presumably causing the script thread to hang on the receiving channel. --- <!-- 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 #21703 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because no new behaviour was introduced. <!-- 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/21705) <!-- Reviewable:end -->
mandreyel commentedAug 31, 2018
•
edited
Apologies, meant to land it sooner but deadline at work got hectic.
So I moved the
Pipeline::{visible, is_private, parent_info}fields (sizewas moved earlier) toBrowsingContext, and renamed them where appropriate (and did some minor refactoring on the side, hope that's alright).This introduced some complications, because when a pipeline is spawned for a browsing context that does not yet exist, the browsing context won't be constructed until after pipeline has made its document active. Thus, values for the fields that used to be in
Pipelineand are now inBrowsingContextcould not be easily retrieved when constructing theBrowsingContext(since in most cases they were only available when spawning a pipeline).For this reason, I've put these fields in
SessionHistoryChangesince one is always created and added toConstellation::pending_changeswhen a new pipeline is created, so it provides an easy way to forward the necessary values to newBrowsingContexts.Though frankly I'm not sure I like expanding
SessionHistoryChange's purpose to serve as a crutch to construct browsing contexts, so a way to uncouple purposes would be to separately store the values for a to-be-createdBrowsingContextin a collection of structs inConstellationand consume them when a newBrowsingContextis created. Here's a PoC: mandreyel@6fa2160.I didn't include this by default because it introduces a little overhead. Perhaps
PendingBrowsingContextInfocould be stored as anOption<>next to aSessionHistoryChangeinConstellation::pending_changes? That'd uncouple the two structs but not incur any overhead.I don't think it's finished, so I've marked some areas where I need input on small matters with
TODO(mandreyel), but the general idea is done. I'll be sure to squash commits when no further changes need be done!./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is