-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[webdriver] Move Webdriver to ServoShell #36714
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
Does that mean that every embedder will need to add Webdriver support code? |
It's a nice question. I think we can separate Webdriver support code as much as possible and reuse in different embedders. |
I think this makes sense to some extent. For instance Webdriver can open and close |
Discussed with @longvatrong111 offline. It's better to make WebDriver independent of ServoShell, as WebDriver shouldn't depend on any specific embedder. WebDriver and real events should still share the same code paths as much as possible. |
I still think it isn't a good idea to make it totally independent. At the very least, servoshell should use some generic WebDriver interface, but still execute the requested actions using its internal interface. WebDriver should be driving a browser, and not just the embedding layer. |
As discussed with @longvatrong111 , I will move change in |
+1 to this. We'll see how it will be carried out. |
It seems new assertion failure is introduced for
I will start by working from there. |
6a25d08
to
c2e54dd
Compare
Rebase PR. Will check all reviews 1 by 1. |
c2e54dd
to
def26b0
Compare
Is there a clearer illustration / doc of what the relation between servoshell and web driver is, and what the relation should be? |
Yes, sorry for the confusion. The WebDriver is an HTTP server that can drive the browser via commands from tests that are sent to the server. Currently: The WebDriver is activated by the Servo embedding API. When active, the Constellation spawns a thread to listen for HTTP requests and send IPC messages directly to the Constellation or ScriptThreads. This presents an issue for several reasons including:
Future: servoshell would run a WebDriver thread that runs the HTTP server. Many commands become Servo embedding API commands and a good amount of special code can be removed from Servo to deal with the WebDriver. Note that this will still require an API to send some of the more specific WebDriver commands to the Constellation and then to the ScriptThread. This means that things like opening and closing WebViews work exactly the same way they do in a browser application. In order to avoid having the WebDriver code depend directly on servoshell, servoshell may be able to provide some callbacks which the WebDriver code can use. |
Thanks for the clarification, that makes much more sense to me now! So far my understanding of the objectives are: (1) Make servoshell manage the lifetime of WebDriver; (2) Make WebDriver drive Servo with the embedding API. Is that correct? Another question: besides lifetime management, is there other communication needed between WebDriver and servoshell? |
That's a good question. I'm not exactly sure of the answer here. I think it depends on the details of all of the WebDriver APIs. If there are cases where WebDriver wants to do something like move the browser window around, then it will need to move the servoshell window. |
def26b0
to
158b62b
Compare
@xiaochengh @mrobinson it is confirmed that the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is confirmed that the implementation of event route of commands in Context section are much simpler if sending events to servoshell instead of constellation. For example Close Window
I don't think so. Right now close window shares Constellation::handle_close_top_level_browsing_context
with request ScriptToConstellationMessage
and EmbedderToConstellationMessage::CloseWebView
. Isn't that nice?
One by one, move the handling of webdriver commands from constellation to embedder
Some of them would still be easier to handle in Constellation as they require information from it. Need to be very careful with each case... :(
We need to hold a bit more, all tests are timeout in CI: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code itself looks good. Very excited for this!
Side notes:
I've been verifying the execution path, and found some redundancy for channel communication which has been there for quite a while. (Not really related to this PR)
But I wanna ask: why we sometimes use crossbeam_channel
, and sometimes ipc
? I assume the former is more efficient + mpmc, the latter is required for inter-process communication (to Content Process, e.g. script thread). If I'm correct, then we are misusing many ipc channels in webdriver_server/lib.rs
if only talking to Constellation/embedder. Instead, should just use crossbeam_channel
or even mpsc
?
cc @jdm @sagudev
I'm also looking for a way to easily plug webdriver into any embedder. Thank you for the suggestion. |
Apologies for not getting to this one yet. I will look at it first thing tomorrow morning. |
You guessed right, it is for cross process reasons, but even though some stuff currently live in same process (actually all because we run servo in single process mode by default), but that might not be true in the future (there is also plan to have GPU process, etc), so we use ipc-channel in more places for easier potential process split up. Here are other interesting ipc stuff: |
You are correct; uses like servo/components/constellation/constellation.rs Lines 4761 to 4768 in 96ef92b
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff!
I just have a few suggestions.
174bf83
to
dd7b393
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! One more comment before landing, but once that's done feel free to land without another review.
09002a4
to
7c5844a
Compare
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
Decompose webdriver::embedder_proxy to a sender and a waker. Make the sender channel uses only webdriver command message. Rebase main and solve conflict Signed-off-by: batu_hoang <longvatrong111@gmail.com>
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
7c5844a
to
83fb014
Compare
I added some minor rustdoc comments and did a little re-ordering of members. Sending to the merge queue now. Thanks @longvatrong111! |
…etWindowSize` to servoshell (#37555) Follow up to: #36714 Moving webdriver [context commands](https://www.w3.org/TR/webdriver2/#contexts) to be handled in embedder: - [x] New Window command - `WebdriverCommandMsg::NewWebView` - [x] Switch To Window command - `WebdriverCommandMsg::FocusWebView` - [x] Resizing commands cc: @xiaochengh --------- Signed-off-by: batu_hoang <longvatrong111@gmail.com>
Moving
webdriver
toservoshell
:servoshell
manage lifecycle ofwebdriver
constellation
toembedder
Partially fix: #37370
Partially fix webdriver test timeout with
no_top_browsing_context
cc: @xiaochengh