Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upEmbedder handling of prompts and alerts #20707
Conversation
highfive
commented
Apr 28, 2018
|
Heads up! This PR modifies the following files:
|
|
@paulrouget I ended up in circular dependency hell when trying to use It seemed to me that to have script communicate directly with the embedder, we would need to import at the very least Unfortunately I wasn't able to resolve the circular dependency issue, so I tried it in this way instead. Is there a problem with having an extra step go via the constellation? |
168e7b5
to
0bd70c6
Can you expand on that? I introduced |
|
As I remember it, I tried to quickly move I'll give it a try and let you know... |
|
@paulrouget Ok, looks like it's going to work to move everything to embedder_traits... |
|
I only had to adapt |
|
It's not clear to me how this compiles, because InitialScriptState has a member added to it but UnprivilegedPipelineContent::start_all wasn't modified. In particular, I expect we'll need a different mechanism for the event loop waker in the multiprocess case, since we don't have direct access to the relevant event loop. Probably an IPC channel with a dedicated listener that contains an actual event loop waker it can poke would do the trick. |
af550ae
to
c4dc72e
|
@jdm, as a matter of fact, it wasn't :) and it still fails at https://github.com/gterzian/servo/blob/c4dc72ed07acb471829004e5ada3c762900684c1/components/servo/lib.rs#L600 (the reason I'm passing it as an argument to Couple of questions:
|
|
The content process doesn't have any constellation code. It's only layout/script threads running in there if I'm not mistaken. So when the script thread of the content process needs to talk back to the embedder, it needs a way to make it so the embedder wakes up. The embedder proxy would call the wakeup function on send, making sure the embedder would wake up to consume the new message. This mechanism can be shared between the different threads of Servo (see the clone function that we use for that in the waker trait), but we can't clone the wakeup mechanism between processes. So you need something that would listen that wakeup event in the main process that would then wakeup the embedder. And that should be the constellation probably. But then, maybe, we just end up back with the current setup where script talk to constellation which talks to embedder. |
|
IRC Chat: https://mozilla.logbot.info/servo/20180430#c14687758-c14687762 The main concern with having embedder messages being routed through the constellation was that we were adding a new message to the constellation for each new message added to the embedder. Rather than having each script thread have an embedder sender (since this appears to be more complex than originally thought), we should just add a new constellation message that takes an embedder message and forwards the embedder message to the embedder. |
|
If we end up introducing a Compositor message to forward embedder messages, we might want to change components/net/filemanager_thread.rs and components/bluetooth/lib.rs. We recently started using the embedderproxy there. |
|
Thanks for the input. I have two ideas, both of which are perhaps nonsense, for consideration: First of all, just to make sure I understand, there is no embedder or constellation, in the content process case? If that is indeed the case, I can think of two options:
It seems to be, that in both options, we will still need some sort of 'dummy' embedder for the content process case? Do we need a For option 2, Would an appropriate EventLoopWaker, As @jdm suggested earlier, perhaps be an |
|
So, at the risk of driving everyone crazy, I'm going to share my view on what's happening with the constellation and the embedder when we're running a content process:
So at that point, in order to 'wake up the event loop', we need to wake the glutin event loop of the 'main process' that started at 1 above, not the event loop of the sub process we are in at that point. Makes sense? |
|
Yes, that is the idea I was opaquely proposing in my #20707 (comment). |
4d08719
to
84de812
|
Please take a look, given everyone's input I think the most simple solution is re-using the If this makes sense, I'll move over the remaining ScriptMsg that fit in this pattern, for example |
| EmbedderMsg::Alert(browser_id, _message, response_chan) => { | ||
| if let Err(e) = response_chan.send(true) { | ||
| warn!("Failed to send alert response: {}", e); | ||
| self.event_queue.push(WindowEvent::CloseBrowser(browser_id)); |
This comment has been minimized.
This comment has been minimized.
gterzian
May 2, 2018
Author
Member
@paulrouget Previously the constellation would panic the pipeline if sending failed, this was the closest I got to...
This comment has been minimized.
This comment has been minimized.
paulrouget
May 2, 2018
Contributor
I see that we used to call self.handle_send_error(pipeline_id, e). Having a mechanism to report a communication error with the pipeline, from the embedder, sounds important
@asajeffrey, we are introducing a communication between the embedder and the pipeline. Any recommendation how we could handle a send error? Should we let the constellation now or handle it in the embedder code?
84de812
to
191e723
|
Why not moving |
| EmbedderMsg::Alert(browser_id, _message, response_chan) => { | ||
| if let Err(e) = response_chan.send(true) { | ||
| warn!("Failed to send alert response: {}", e); | ||
| self.event_queue.push(WindowEvent::CloseBrowser(browser_id)); |
This comment has been minimized.
This comment has been minimized.
paulrouget
May 2, 2018
Contributor
I see that we used to call self.handle_send_error(pipeline_id, e). Having a mechanism to report a communication error with the pipeline, from the embedder, sounds important
@asajeffrey, we are introducing a communication between the embedder and the pipeline. Any recommendation how we could handle a send error? Should we let the constellation now or handle it in the embedder code?
| @@ -69,6 +70,8 @@ pub enum LogEntry { | |||
| /// Messages from the script to the constellation. | |||
| #[derive(Deserialize, Serialize)] | |||
| pub enum ScriptMsg { | |||
| /// Forward a message to the embedder. | |||
| Forward(EmbedderMsg), | |||
This comment has been minimized.
This comment has been minimized.
paulrouget
May 2, 2018
•
Contributor
Can you make that message more explicit? ForwardToEmbedder maybe?
This comment has been minimized.
This comment has been minimized.
a157ca8
to
6282789
|
Ok, after rebasing, now got a cyclic dependency on Edit: done, see last commit... |
| @@ -93,7 +93,7 @@ extern crate style; | |||
| extern crate style_traits; | |||
| extern crate swapper; | |||
| extern crate time; | |||
| #[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))] | |||
| #[cfg(any(target_os = "linux"))] | |||
This comment has been minimized.
This comment has been minimized.
| #[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))] | ||
| fn display_alert_dialog(message: &str) { | ||
| if !opts::get().headless { | ||
| tinyfiledialogs::message_box_ok("Alert!", message, MessageBoxIcon::Warning); |
This comment has been minimized.
This comment has been minimized.
paulrouget
May 2, 2018
Contributor
You probably want to run that in a different thread. See platform_get_selected_devices for example.
| let window_proxy = self.window_proxy.get().unwrap(); | ||
| let top_level_browsing_context_id = window_proxy.top_level_browsing_context_id(); | ||
| self.send_to_constellation(ScriptMsg::ForwardToEmbedder(EmbedderMsg::Alert(top_level_browsing_context_id, | ||
| s.to_string()))); |
This comment has been minimized.
This comment has been minimized.
paulrouget
May 2, 2018
•
Contributor
Aren't we supposed to be blocking here? I believe you need a sender/receiver pair, and block on recv(). In ports/, you would use the sender to notify when the user dismissed the alert.
| let filter_ref = &(filter.iter().map(|s| s.as_str()).collect::<Vec<&str>>()[..]); | ||
| let filter_opt = if filter.len() > 0 { Some((filter_ref, "")) } else { None }; | ||
| let filter_ref = &(filters.iter().map(|s| s.as_str()).collect::<Vec<&str>>()[..]); | ||
| let filter_opt = if filters.len() > 0 { Some((filter_ref, "")) } else { None }; |
This comment has been minimized.
This comment has been minimized.
paulrouget
May 2, 2018
Contributor
Could we use FilterPattern here if we move its definition to the embedder_traits? It's a bit annoying that we have to move that logic (FilterPattern to string) in filemanager_thread.rs. Feels like the embedder code is a better place. I'm not sure what's the best approach here.
So close! |
44486bd
to
a5dc1b6
|
fingers crossed |
|
@bors-servo r=payl |
|
|
…ts_2, r=payl Embedder handling of prompts and alerts <!-- Please describe your changes on the following line: --> Allow embedder to allow alerts and prompts, but via constellation forwarding messages from script. --- <!-- 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 build-geckolib` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #19992 (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/20707) <!-- Reviewable:end -->
|
|
|
@bors-servo retry |
seems all related to "/html/browsers/history/the-history-interface/007.html", not sure what I changed that could cause this. |
|
The fact that that failure has not appeared on any previous attempts to merge made me file #20856 for it. |
|
|
|
|
I think this is some sort of intermittent thing... |
|
@bors-servo retry |
|
|
|
|
gterzian commentedApr 28, 2018
•
edited by SimonSapin
Allow embedder to allow alerts and prompts, but via constellation forwarding messages from script.
./mach build -ddoes not report any errors./mach build-geckolibdoes not report any errors./mach test-tidydoes not report any errorsThis change is