Skip to content

Remove compositor forwarding code and use dedicated mechanism#17269

Merged
bors-servo merged 2 commits intoservo:masterfrom
gterzian:remove_compositor_forwarding_code_and_use_dedicated_mechanism
Aug 29, 2017
Merged

Remove compositor forwarding code and use dedicated mechanism#17269
bors-servo merged 2 commits intoservo:masterfrom
gterzian:remove_compositor_forwarding_code_and_use_dedicated_mechanism

Conversation

@gterzian
Copy link
Copy Markdown
Member

@gterzian gterzian commented Jun 11, 2017

@paulrouget Here is a first sketch of the proposed "design", handling a first message as a proof of concept, if you could please already take a look before I move all the messages(or method calls) across... thanks


  • 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

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jun 11, 2017
@gterzian gterzian force-pushed the remove_compositor_forwarding_code_and_use_dedicated_mechanism branch from e9c224a to 88fa2fc Compare June 11, 2017 13:41
@paulrouget
Copy link
Copy Markdown
Contributor

Can you add a change to ports/ to show how this endup being used? Maybe you could rewrite the title update mechanism (the title of the current page is displayed in the glutin window).

@paulrouget
Copy link
Copy Markdown
Contributor

Two examples where the compositor should not been involved:

  • Title of the pages changes. Embedder needs to update the window title (script to constellation to embedder).
  • Page reload when the user press Cmd-R. (embedder to constellation to script)

@bors-servo
Copy link
Copy Markdown
Contributor

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

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Jun 12, 2017
@gterzian
Copy link
Copy Markdown
Member Author

gterzian commented Jun 12, 2017

@paulrouget I've just added a commit to support changing the page title, tested it locally and "it works". It doesn't require any changes in ports, however it does require reaching for the root pipeline inside the compositor.

@gterzian gterzian force-pushed the remove_compositor_forwarding_code_and_use_dedicated_mechanism branch 2 times, most recently from 88657cf to b0ffab7 Compare June 12, 2017 06:15
@gterzian
Copy link
Copy Markdown
Member Author

@paulrouget Ok now also added support for:

  • Title of the pages changes. Embedder needs to update the window title (script to constellation to embedder).
  • Page reload when the user press Cmd-R. (embedder to constellation to script)

Copy link
Copy Markdown
Contributor

@cbrewster cbrewster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial review pass

pub enum EmbedderMsg {
/// A status message to be displayed by the browser chrome.
Status(Option<String>),
/// Alerts the compositor that the current page has changed its title.
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.

s/compositor/embedder/

@@ -29,6 +29,42 @@ pub trait EventLoopWaker : 'static + Send {
fn wake(&self);
}

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.

s/compositor/embedder/

}
}
}

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.

s/compositor/embedder/

/// A channel for the constellation to receive messages from the compositor thread.
compositor_receiver: Receiver<FromCompositorMsg>,

embedder_proxy: EmbedderProxy,
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.

nit: Add doc comment


/// State needed to construct a constellation.
pub struct InitialConstellationState {
pub embedder_proxy: EmbedderProxy,
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.

nit: Add doc comment

(EmbedderProxy {
sender: sender,
event_loop_waker: event_loop_waker,
},
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.

nit: indentation

(_, _) => {},
}
}
for event in events.clone() {
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.

Since the variants of WindowEvent handled by the embedder and the compositor are disjoint, it would be better to have two separate types. Maybe the window should store events for the compositor and events for the embedder?

Copy link
Copy Markdown
Member Author

@gterzian gterzian Jun 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I would almost be tempted to think that all window events should be handled by Browser, which could call the appropriate methods of compositor, or handle those differently(such as in the cases where the compositor isn't involved). Maybe this could also help support multiple compositors down the line? @paulrouget

So in other words, all window events could be handled here, and Browser could either call a method of 'window', or 'compositor', or both, in response to each event.

fn handle_window_event(&mut self, event: WindowEvent) {
match event {
WindowEvent::Reload => {
let top_level_browsing_context_id = match self.compositor.root_pipeline {
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.

Is the plan to eventually allow the embedder to handle the current top_level_browsing_context_id?

cc @paulrouget

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.

Eventually, the embedder will have a list of top_level_browsing_context_id (tabs).

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.

So asking the compositor for the root pipeline to get the context id will be be a temporary thing.

@cbrewster cbrewster added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. S-needs-rebase There are merge conflict errors. labels Jun 13, 2017
@bors-servo
Copy link
Copy Markdown
Contributor

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

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Jun 14, 2017
@gterzian
Copy link
Copy Markdown
Member Author

gterzian commented Jun 16, 2017

@cbrewster thanks for the review so far, I'm on standby for a bit more "big picture" guidance from @paulrouget...

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Jun 17, 2017
@gterzian
Copy link
Copy Markdown
Member Author

gterzian commented Jun 17, 2017

OK so I've done one more thing to just follow along the current line, and learned some stuff along the way:

  • I moved all WindowEvent handling to Browser, which calls compositor methods in response.
  • The one catch is when we are shutting down. If you look at the current (on master) implementation of compositor.handle_browser_messages, you can see that the default is to return true, while in the case that the compositor has or is about to shutdown, it returns false. There shouldn't be any more WindowEvent handling or receiving of messages(either by the compositor or a dedicated embedder channel) after that. I'm currently handling this here. This will also be relevant if we move towards a 'pull' model of event handling from the window(through something like window.get_events)...
  • One thing worth noting is that I tried to only have the compositor and browser receive messages in response to the WindowEvent::Idle and WindowEvent::InitializeCompositing, and that would freeze up the browser. This could be relevant if we move to an explicit browser.perform_updates method call by the embedder, as it would mean that doing so only in response to WindowEvent::Idle wouldn't be "enough". (to be confirmed, maybe there was some other reason for the freeze-up)

My conclusion so far on this experiment:

  • Compositor doesn't need to be handling window events directly.
  • A "browser" or "servo" could do all the event handling, either by waiting on events like now, or in response to a call to perform_updates from the embedder.
  • A "browser" or "servo" could also receive messages directly from constellation, entirely by-passing the compositor where appropriate.
  • A "browser" or "servo" could also tell compositor to receive messages(or "perform updates").
  • A "browser" or "servo" could essentially be the only embedder facing component, by handling window events, and calling window methods, as well as providing the main entry point for the event loop through a perform_updates method.
  • I speculate that having a "browser" or "servo" doing all of the above, rather then the current setup where compositor is essentially doing it, would facilitate having multiple windows and/or multiple compositor.

@gterzian gterzian force-pushed the remove_compositor_forwarding_code_and_use_dedicated_mechanism branch from 01c4eaf to 186139c Compare June 17, 2017 14:01
@gterzian
Copy link
Copy Markdown
Member Author

gterzian commented Jun 19, 2017

@paulrouget Ok just to continue the current experiment, I made an attempt to move all messages from constellation that don't relate to the compositor to the dedicated "embedder" channel, and I've also moved all window event handling from compositor to browser. I think the first part is the stated goal of this issue, and I'm wondering if we shouldn't include moving all window event handling as I did as well.

Worth noting is that the way the compositor was previously handling it's "own" messages, as well as window events, was intertwined with the ShutDownState of the compositor. So I've tried to replicate the logic in browser.handle_events, which required breaking up compositor.handle_events into compositor.perform_updates and compositor.receive_messages...

When I run servo, I keep getting a called `Option::unwrap()` on a `None` value (thread ScriptThread PipelineId { namespace_id: PipelineNamespaceId(0), index: PipelineIndex(0) }, at src/libcore/option.rs:335) just before shutdown(which doesn't seem to crash servo in it's entirety), which I haven't been able to solve yet.

Also when I tried to run some tests, it seemed very slow, and I'm not sure if it's just my machine or if I introduce something that slows down the event loop or something else...

(note: the PR still contains debug messages).

@paulrouget
Copy link
Copy Markdown
Contributor

@gterzian your work and my work may conflict. It's work in progress, but you might want to take a look: master...paulrouget:attach-pipeline-wip

@gterzian
Copy link
Copy Markdown
Member Author

gterzian commented Jun 19, 2017

@paulrouget There will defenitely be a huge "conflict" in terms of git 😄 , however the direction you're moving to is very compatibly with what I am trying to do here, since it seems to be moving logic out of the compositor. If "browser/servo" handles WindowEvent, as in this PR, it would simply be "browser/servo" that would be sending ConstellationMsg, and inside constelation we would obbiously have to import them as FromEmbedderMsg, as opposed to FromCompositorMsg.

@bors-servo
Copy link
Copy Markdown
Contributor

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

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Jun 21, 2017
@gterzian gterzian force-pushed the remove_compositor_forwarding_code_and_use_dedicated_mechanism branch from d4e1022 to e79db2e Compare June 22, 2017 03:44
@highfive highfive assigned asajeffrey and unassigned cbrewster Aug 28, 2017
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. S-needs-rebase There are merge conflict errors. labels Aug 28, 2017
@bors-servo
Copy link
Copy Markdown
Contributor

⌛ Testing commit 6bca340 with merge 1657ad4815034e5c27cf130f7ef77adfb1030ba3...

@bors-servo
Copy link
Copy Markdown
Contributor

💔 Test failed - mac-rel-wpt2

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Aug 28, 2017
@jdm
Copy link
Copy Markdown
Member

jdm commented Aug 28, 2017

@bors-servo
Copy link
Copy Markdown
Contributor

⌛ Testing commit 6bca340 with merge 9307f29805768714a3dee54a32b0e9b672ccfd92...

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Aug 29, 2017
@bors-servo
Copy link
Copy Markdown
Contributor

💔 Test failed - mac-rel-wpt2

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Aug 29, 2017
@paulrouget
Copy link
Copy Markdown
Contributor

Same error multiple times in a row. What does it mean?

exceptions.Exception: Actual commit (f3f80c0dca7408863cfa1a6276862f0927b7947a) differs from requested commit (9307f29805768714a3dee54a32b0e9b672ccfd92)

@jdm
Copy link
Copy Markdown
Member

jdm commented Aug 29, 2017

@bors-servo
Copy link
Copy Markdown
Contributor

⌛ Testing commit 6bca340 with merge 026872b...

bors-servo pushed a commit that referenced this pull request Aug 29, 2017
…_use_dedicated_mechanism, r=asajeffrey

Remove compositor forwarding code and use dedicated mechanism

<!-- Please describe your changes on the following line: -->
@paulrouget Here is a first sketch of the proposed "design", handling a first message as a proof of concept, if you could please already take a look before I move all the messages(or method calls) across... thanks

---
<!-- 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 #15934 (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/17269)
<!-- Reviewable:end -->
@highfive highfive removed the S-tests-failed The changes caused existing tests to fail. label Aug 29, 2017
@bors-servo
Copy link
Copy Markdown
Contributor

💔 Test failed - mac-rel-wpt1

@jdm
Copy link
Copy Markdown
Member

jdm commented Aug 29, 2017

@bors-servo
Copy link
Copy Markdown
Contributor

⌛ Testing commit 6bca340 with merge ef401dd...

@bors-servo
Copy link
Copy Markdown
Contributor

☀️ 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
Approved by: asajeffrey
Pushing ef401dd to master...

@gterzian
Copy link
Copy Markdown
Member Author

Thank you all for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a dedicated channel for constellation -> embedder communication

8 participants