Skip to content

Link entry pipelines - #15566

Closed
cbrewster wants to merge 2 commits into
servo:masterfrom
cbrewster:link_entry_pipelines
Closed

cbrewster wants to merge 2 commits into
servo:masterfrom
cbrewster:link_entry_pipelines

Conversation

@cbrewster

@cbrewster cbrewster commented Feb 15, 2017 •

Copy link
Copy Markdown
Contributor

Soon we will be allowing multiple entries to share pipelines. This causes issues when handling how we discard pipelines in distant history entries. This change uses an Rc to make all entries that share the same pipeline id actually point to the same pipeline id. Once one of the entries is reloaded, the pipeline is now automatically used in all other entries that previously shared the discarded pipeline.

A link is broken when a navigation occurs or when a navigation with replacement enabled occurs.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #__ (github issue number if applicable).
  • There are tests for these changes OR
  • These changes do not require tests because _____

This change is Reviewable

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @asajeffrey: components/constellation/constellation.rs, components/constellation/frame.rs, components/constellation/lib.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Feb 15, 2017
@cbrewster

Copy link
Copy Markdown
Contributor Author

r? @asajeffrey

@highfive highfive assigned asajeffrey and unassigned Manishearth Feb 15, 2017
None => {
let pipeline_id = match entry.pipeline_id() {
Some(pipeline_id) => pipeline_id,
None => {

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.

Revert indentation change

ExitPipelineMode::Normal => pipeline.exit(dbc),
ExitPipelineMode::Force => pipeline.force_exit(dbc),
}
debug!("Closed pipeline {:?}.", pipeline_id);

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.

Does this still belong 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.

whoops just needs to be moved up.

@cbrewster
cbrewster force-pushed the link_entry_pipelines branch from e79ab89 to 2170b0d Compare February 15, 2017 16:37
@cbrewster cbrewster mentioned this pull request Feb 15, 2017
3 of 5 tasks
@cbrewster
cbrewster force-pushed the link_entry_pipelines branch from 2170b0d to 558843b Compare February 16, 2017 00:29
@bors-servo

Copy link
Copy Markdown
Contributor

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

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Feb 16, 2017
@cbrewster
cbrewster force-pushed the link_entry_pipelines branch from 558843b to e64556b Compare February 16, 2017 16:19
@cbrewster cbrewster removed the S-needs-rebase There are merge conflict errors. label Feb 16, 2017

@asajeffrey asajeffrey left a comment

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.

I'm not in love with Rc'ing a PipelineId; I wonder if we can use the same sort of weak Rc that we used for event loops? That is, a FrameState would contain an Rc<Pipeline> (for recent uses) or Weak<Pipeline> (for potentially-discardable uses), and the pipelines map would contain Weak<Pipeline>.

/// The URL for the current session history entry
pub url: ServoUrl,
/// The current session history entry.
pub current: FrameState,

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.

The reason for having instant, pipeline_id and url as separate fields was to ensure that the current pipeline id is never None. This is in the constellation, so doing some hoop-jumping to avoid panic is probablyu worth it.

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.

Fair enough, Although this does become hard to maintain once we add more info on FrameState. Maybe we could have an info struct that contains all the frame state info other than the pipeline id?

extern crate msg;
extern crate servo_url;

#[cfg(test)] mod frame;

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.

Do we need the cfg(test) here? This is only compiled in unit tests.

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.

Probably not, but all of the other unit test crates follow this pattern.

// Discard should work now that current is no longer linked to this entry.
let evicted_id = frame.discard_entry(&frame.prev[0]);
assert_eq!(evicted_id, Some(pipeline_id));
}

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.

Ooh tests!

@cbrewster

Copy link
Copy Markdown
Contributor Author

Using Weak would help with the case where a pipeline is destroyed and all entries need to be updated, but I don't think it would solve the case where a new pipeline is created to replace the discarded one and the entries that shared the old pipeline need to be updated.

@asajeffrey

Copy link
Copy Markdown
Contributor

True, I wonder if there's an API which is like Weak, but allows a strong reference to be recovered, even if a upgrade fails. Something like:

  RecoverableWeak<T> {
    ...
    fn upgrade_or(&self, default: T) -> Rc<T> { ... }
    fn upgrade_or_else(&self, factory: F) -> Rc<T> where F: FnOnce() -> T { ... }
  }

@asajeffrey

Copy link
Copy Markdown
Contributor

I think we could implement that using Rc<Weak<T>>.

@bors-servo

Copy link
Copy Markdown
Contributor

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

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Mar 9, 2017
@cbrewster

Copy link
Copy Markdown
Contributor Author

I believe we are going to take this in a different direction

@cbrewster cbrewster closed this Mar 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed. S-needs-rebase There are merge conflict errors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants