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
Create a dedicated channel for constellation -> embedder communication #15934
Comments
Ok, please add the "assigned" label to this one as well, I'll take it on as well... |
Here is my understanding of the situation, to be confirmed by feedback, followed by an implementation plan based thereon: As it currently stands:
The problem I see with the above, is that it appears that the embedder If that is correct, I propose that this issue also involves making the The result would be: A. A new "constellation -> embedder" channel, that bypasses the compositor. Candidates for that are a bunch of messages currently handled inside So I propose to implement the following solution:
Please let me know what you think. @paulrouget @asajeffrey |
After some additional consideration, I'm wondering if 1 and 2 in the implementation plan above are really necessary, from this comment I can tell that the coupling of the client/embedder with the channel/event loop is intentional, in which case we could focus on 3 in this issue. To 3 I would like to add the need for the embedder to be aware in some way of the shutdown state of the compositor. Perhaps the constellation should forward messages pertaining to this to the embedder? |
If I'm not mistaken, This is confusing. Ideally, this notion of CompositorProxy would disappear and the embedder would simply provide a "EventLoopRiser" thread safe object that could be used from both the compositor and the constellation. Here is how I see it:
1 is done via compositor.window.foo where foo is a WindowMethod. So even for non-compositor stuff, we always go through the compositor, because it's the only way we have to communicate back and forth with the emebedder. So we need another mechanism for the constellation. I am not providing any solution to the initial problem here, just describing how things work. Let me know what you think. Also - do not hesitate to consider getting rid of some existing concepts. For example, I don't think we have to keep WindowMethods and CompositorProxy. |
PS: when you create a link to a line of code, press |
Thanks for the additional info and the github protip. 😄
I agree with the above, and would also like to state the obvious which is that the messages that are being proxied are currently all like "constellation -> compositor <- webrender", with the compositor sitting in between all communication, and sometimes forwarding some messages to the embedder via the window. As this issues has pointed out, some of those messages actually belong in a separate constellation -> embedder channel. I can't prove it, but I have a feeling that the
Perhaps the above might have promoted something along the lines of "window is creating this compositor communication channel, so we can put everything through it, both related to compositor and window"? As a first step towards better separation of communication channels, I would like to propose the following:
The benefits of this refactoring?
Once we have the above, we can start thinking about the best structure for the "constellation -> embedder" channel(s) of communication. I can think of the following elements that could be needed:
|
Will you be able to call this function ever? At that point the main thread is blocked. |
We need a function that returns a thread safe object that can wake up the event loop from any thread. Maybe something like this: fn create_event_loop_riser(&self) -> Box<EventLoopRiser>;
pub trait EventLoopRiser {
fn clone(&self) -> Box<EventLoopRiser + Send>;
fn rise(&self);
} |
Also - I agree that the first step should be to move the CompositorProxy-related things to Browser. |
@paulrouget thanks, I think it's time to write a first draft of this replacement of CompositorProxy, and see what the compiler has to say about the design... |
Once #17068 lands, this is what I think should happen next:
Embedder send WindowEvent::Reload to compositor. What we want is either: Embedder send WindowEvent::Reload(browsing_context) to compositor. … or: Embedder send WindowEvent::Reload to compositor.
Where basically the compositor doesn't need to forward anymore. I don't know how to do 2) yet. 1) needs to happen soon as we want to land #17077. Greg, if that works for you, I'd like to take care of 1). I let you handle 2). |
@paulrouget ok, I'll take care of 2) |
Remove pipeline non-compositing-logic code from compositor: #17200 |
Separate waking the event loop, from communicating with Compositor <!-- Please describe your changes on the following line: --> @paulrouget first step of #15934, Glutin only for now, please take a look... If this makes sense, I will also update the code for ports other than Glutin... One question: one do I add the `warn!` macro to `servolib`? Also perhaps we would also want to add `box`, since I had to switch to using `Box::new`... --- <!-- 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 #__ (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/17068) <!-- Reviewable:end -->
In the light of the current 'proof of concept' at #17269 I'm starting to think that 'libservo/Browser' could become the main piece of glue between the embedder and other servo internals, this could also facilitate further improvements like multiple compositors and/or multiple "tabs"(Browser currently has one compositor, so I guess that could be the place to keep track of several ones) . Regarding embedder => constellation communication, perhaps 'WindowMethods' and 'WindowEvents' is still the way to go, with the main change being:
@paulrouget I'm still looking into your Tabs prototype at paulrouget@6f3bdef and so far it seems that we're thinking of something similar, with the difference being that I would just put everything into Browser(and perhaps indeed rename it Servo), essentially doing what you are doing with I guess once this would be in place, it would move us one step further to offering some sort of 'Tabs' to the embedder by way of an API, perhaps using "window.open"? |
@paulrouget There was a very good point of @cbrewster here #17269 (comment) about whether we should have a new type of event for the stuff that isn't handled by the compositor, which made me think of the Taking the "tabs prototype" found at paulrouget@6f3bdef as a starting point:
Making those observations, I am getting more convinced of the need for
The result, going back to the history changed example, would allow us to do something like:
Other operations initiated by the embedder, like 'opening a new tab' or 'selecting a new tab' would be communicated via WindowEvents, again handled by Browser, which could send messages to constellation, call compositor methods(or send messages on a clone of compositor_proxy), and so on... Lastly, it could be a really good idea to rename Browser into Servo, otherwise potential embedders will for eternity think in terms of browsers with tabs... 😄 |
I agree with what you're saying. So we could rename "Browser" to "Constellation" or "Servo". How would we create a new browser ( This is what I'd like the final API to look like, more or less: https://gist.github.com/paulrouget/248c0d7bd308242c43e05648b1245fab Look at the example at the end of the file and tell me what you think. |
So what we want to do for this issue is:
|
I disagree with that step. Browser should not have any internal state. Nothing to update, just redirect messages. The embedder will have a list of (ServoUrl, TopLevelBrowsingContextId) pairs, not Browser. |
@paulrouget thanks. First of all, I would like to confirm my understanding of the "event loop", to make sure I am not missing something in the context of this discussion. Is the following correct regarding the current Glutin implemention:
If the above is correct, whatever we do, we will still need to call |
By the way, it seems the answer to my question above is found in #15734 |
ok @paulrouget I think I now understand better(again!) what it is that I am trying to propose here, after having read about your proposed Essentially, what I had in mind is the 'reverse' of you: have Browser handle However, I think the part of your proposal that has the embedder call And I also think we could consider hiding the compositor from the embedder, passing the native_window along with the call to I would propose the following changes to your api, assuming we also rename Browser to Servo in libservo:
Example: Constellation sends a
Example: The embedder sends a The result is that we really separate "handling window events from the embedder" from "pulling internal messages in response to a event loop wake up", making the later an explicit |
cleanup embedder/compositor/constellation/script messages Fix: #17226 #17200 #17201 This is work in progress. Some tests still fail. I'd like to get early feedback as it's a pretty large PR. There is nothing fundamentally new. Basically, I added TopLevelBrowsingContrextId to the relevant messages between the embedder, the compositor and the constellation, and enforced the PipelineId to be attached to each ScriptMsg (see #17201). I unaliased all the ScriptMsg. It was getting difficult to understand the nature of the message as ScriptMsg was used aliased CompositorMsg sometimes (CompositorMsg is an actually type of message already). I renamed constellation_chan to script_to_constellation_chan, again, for clarification. This cleanup code is necessary for #15934 and for tabs support. /cc @asajeffrey can I ask you to look at this? No need for a formal review, I need feedback at this stage. <!-- 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/17425) <!-- Reviewable:end -->
cleanup embedder/compositor/constellation/script messages Fix: #17226 #17200 #17201 This is work in progress. Some tests still fail. I'd like to get early feedback as it's a pretty large PR. There is nothing fundamentally new. Basically, I added TopLevelBrowsingContrextId to the relevant messages between the embedder, the compositor and the constellation, and enforced the PipelineId to be attached to each ScriptMsg (see #17201). I unaliased all the ScriptMsg. It was getting difficult to understand the nature of the message as ScriptMsg was used aliased CompositorMsg sometimes (CompositorMsg is an actually type of message already). I renamed constellation_chan to script_to_constellation_chan, again, for clarification. This cleanup code is necessary for #15934 and for tabs support. /cc @asajeffrey can I ask you to look at this? No need for a formal review, I need feedback at this stage. <!-- 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/17425) <!-- Reviewable:end -->
…_use_dedicated_mechanism, r=cbrewster,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 -->
…_use_dedicated_mechanism, r=cbrewster,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 -->
…_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 -->
…_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 -->
Thank you @gterzian |
This issue is part of an effort to improve Servo's embedding story. See https://github.com/paulrouget/servoshell/projects/2
Follow up of #15795.
As of now, Servo communicates with the embedder by calling the
WindowMethods
, in the main thread. These methods are called from the compositor, and the main thread is woken up via the compositor proxy.A subset of these methods are relevant to the compositor (
framebuffer_size()
,window_rect()
, …) and some are not (set_page_title()
,status()
, …).Also, some of these calls need to be synchronous (
framebuffer_size()
) some don't (set_cursor()
).As Alan noted in #15795:
So to make the embedding API more sensible (separation of concerns), it would be great to have a dedicated mechanism for the constellation to communicate with the embedder.
This channel should be between the constellation and the embedder.
We would end up with 2 channels between the servo and the embedder: constellation -> embedder and compositor -> embedder. With the embedder code running in the main thread.
Ideally, both channels would follow the same pattern: sync calls would be methods, async calls would be events, and the embedder would provide a mechanism to both channels to wake up the main thread.
We would need to identify in the current WindowMethods what falls under compositor and constellation concerns.
The text was updated successfully, but these errors were encountered: