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

Remove compositor forwarding code and use dedicated mechanism #17269

Conversation

@gterzian
Copy link
Member

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


  • ./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).
  • There are tests for these changes OR
  • These changes do not require tests because _____

This change is Reviewable

@highfive
Copy link

highfive commented Jun 11, 2017

Heads up! This PR modifies the following files:

  • @asajeffrey: components/constellation/constellation.rs
@gterzian gterzian force-pushed the gterzian:remove_compositor_forwarding_code_and_use_dedicated_mechanism branch from e9c224a to 88fa2fc Jun 11, 2017
@paulrouget
Copy link
Contributor

paulrouget commented Jun 12, 2017

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
Contributor

paulrouget commented Jun 12, 2017

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
Contributor

bors-servo commented Jun 12, 2017

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

@gterzian
Copy link
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 gterzian:remove_compositor_forwarding_code_and_use_dedicated_mechanism branch 2 times, most recently from 88657cf to b0ffab7 Jun 12, 2017
@gterzian
Copy link
Member Author

gterzian commented Jun 12, 2017

@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
Member

cbrewster left a comment

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.

This comment has been minimized.

Copy link
@cbrewster

cbrewster Jun 13, 2017

Member

s/compositor/embedder/

@@ -30,6 +30,42 @@ pub trait EventLoopWaker : 'static + Send {
}

/// Sends messages to the compositor.

This comment has been minimized.

Copy link
@cbrewster

cbrewster Jun 13, 2017

Member

s/compositor/embedder/

}
}

/// The port that the compositor receives messages on.

This comment has been minimized.

Copy link
@cbrewster

cbrewster Jun 13, 2017

Member

s/compositor/embedder/

@@ -171,6 +171,8 @@ pub struct Constellation<Message, LTF, STF> {
/// A channel for the constellation to receive messages from the compositor thread.
compositor_receiver: Receiver<FromCompositorMsg>,

embedder_proxy: EmbedderProxy,

This comment has been minimized.

Copy link
@cbrewster

cbrewster Jun 13, 2017

Member

nit: Add doc comment

@@ -299,6 +301,8 @@ pub struct Constellation<Message, LTF, STF> {

/// State needed to construct a constellation.
pub struct InitialConstellationState {
pub embedder_proxy: EmbedderProxy,

This comment has been minimized.

Copy link
@cbrewster

cbrewster Jun 13, 2017

Member

nit: Add doc comment

(EmbedderProxy {
sender: sender,
event_loop_waker: event_loop_waker,
},

This comment has been minimized.

Copy link
@cbrewster

cbrewster Jun 13, 2017

Member

nit: indentation

(_, _) => {},
}
}
for event in events.clone() {

This comment has been minimized.

Copy link
@cbrewster

cbrewster Jun 13, 2017

Member

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?

This comment has been minimized.

Copy link
@gterzian

gterzian Jun 13, 2017

Author Member

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 {

This comment has been minimized.

Copy link
@cbrewster

cbrewster Jun 13, 2017

Member

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

cc @paulrouget

This comment has been minimized.

Copy link
@paulrouget

paulrouget Jun 13, 2017

Contributor

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

This comment has been minimized.

Copy link
@paulrouget

paulrouget Jun 13, 2017

Contributor

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

@bors-servo
Copy link
Contributor

bors-servo commented Jun 14, 2017

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

@gterzian
Copy link
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...

@gterzian
Copy link
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 gterzian:remove_compositor_forwarding_code_and_use_dedicated_mechanism branch from 01c4eaf to 186139c Jun 17, 2017
@gterzian
Copy link
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
Contributor

paulrouget commented Jun 19, 2017

@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
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
Contributor

bors-servo commented Jun 21, 2017

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

@gterzian gterzian force-pushed the gterzian:remove_compositor_forwarding_code_and_use_dedicated_mechanism branch from d4e1022 to e79db2e Jun 22, 2017
@jdm
Copy link
Member

jdm commented Aug 28, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Aug 29, 2017

Testing commit 6bca340 with merge 9307f29805768714a3dee54a32b0e9b672ccfd92...

@bors-servo
Copy link
Contributor

bors-servo commented Aug 29, 2017

💔 Test failed - mac-rel-wpt2

@paulrouget
Copy link
Contributor

paulrouget commented Aug 29, 2017

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

exceptions.Exception: Actual commit (f3f80c0dca7408863cfa1a6276862f0927b7947a) differs from requested commit (9307f29805768714a3dee54a32b0e9b672ccfd92)
@jdm
Copy link
Member

jdm commented Aug 29, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Aug 29, 2017

Testing commit 6bca340 with merge 026872b...

bors-servo added 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 -->
@bors-servo
Copy link
Contributor

bors-servo commented Aug 29, 2017

💔 Test failed - mac-rel-wpt1

@jdm
Copy link
Member

jdm commented Aug 29, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Aug 29, 2017

Testing commit 6bca340 with merge ef401dd...

bors-servo added 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 -->
@bors-servo
Copy link
Contributor

bors-servo commented Aug 29, 2017

@bors-servo bors-servo merged commit 6bca340 into servo:master Aug 29, 2017
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@bors-servo bors-servo mentioned this pull request Aug 29, 2017
4 of 5 tasks complete
@gterzian
Copy link
Member Author

gterzian commented Aug 30, 2017

Thank you all for your help.

@gterzian gterzian deleted the gterzian:remove_compositor_forwarding_code_and_use_dedicated_mechanism branch Aug 30, 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.

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