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

Link entry pipelines #15566

Closed
wants to merge 2 commits into from
Closed

Conversation

@cbrewster
Copy link
Member

cbrewster commented Feb 15, 2017

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

highfive commented Feb 15, 2017

Heads up! This PR modifies the following files:

  • @asajeffrey: components/constellation/constellation.rs, components/constellation/frame.rs, components/constellation/lib.rs
@cbrewster
Copy link
Member Author

cbrewster commented Feb 15, 2017

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

This comment has been minimized.

@Ms2ger

Ms2ger Feb 15, 2017

Contributor

Revert indentation change

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

This comment has been minimized.

@Ms2ger

Ms2ger Feb 15, 2017

Contributor

Does this still belong here?

This comment has been minimized.

@cbrewster

cbrewster Feb 15, 2017

Author Member

whoops just needs to be moved up.

@cbrewster cbrewster force-pushed the cbrewster:link_entry_pipelines branch from e79ab89 to 2170b0d Feb 15, 2017
@cbrewster cbrewster mentioned this pull request Feb 15, 2017
3 of 5 tasks complete
@cbrewster cbrewster force-pushed the cbrewster:link_entry_pipelines branch from 2170b0d to 558843b Feb 16, 2017
@bors-servo
Copy link
Contributor

bors-servo commented Feb 16, 2017

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

@cbrewster cbrewster force-pushed the cbrewster:link_entry_pipelines branch from 558843b to e64556b Feb 16, 2017
Copy link
Member

asajeffrey left a comment

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,

This comment has been minimized.

@asajeffrey

asajeffrey Feb 21, 2017

Member

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.

This comment has been minimized.

@cbrewster

cbrewster Feb 22, 2017

Author Member

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;

This comment has been minimized.

@asajeffrey

asajeffrey Feb 21, 2017

Member

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

This comment has been minimized.

@cbrewster

cbrewster Feb 22, 2017

Author Member

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));
}

This comment has been minimized.

@asajeffrey

asajeffrey Feb 21, 2017

Member

Ooh tests!

@cbrewster
Copy link
Member Author

cbrewster commented Feb 22, 2017

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
Member

asajeffrey commented Feb 22, 2017

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
Member

asajeffrey commented Feb 22, 2017

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

@bors-servo
Copy link
Contributor

bors-servo commented Mar 9, 2017

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

@cbrewster
Copy link
Member Author

cbrewster commented Mar 15, 2017

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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants
You can’t perform that action at this time.