mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Fix servoshell can't respond when there's no minibrowser (#30598)
* Fix servoshell can't respond when there's no minibrowser * Remove external_field and update documentation * Update documentation * Fix crash when handling ReadyToPresent if it's headless mode * Fix some wpt tests got timedout
This commit is contained in:
parent
d8e93fa408
commit
44d79269f4
3 changed files with 23 additions and 43 deletions
|
@ -240,10 +240,6 @@ pub struct IOCompositor<Window: WindowMethods + ?Sized> {
|
||||||
/// most up to date rendering.
|
/// most up to date rendering.
|
||||||
waiting_on_pending_frame: bool,
|
waiting_on_pending_frame: bool,
|
||||||
|
|
||||||
/// Whether to send a ReadyToPresent message to the constellation after rendering a new frame,
|
|
||||||
/// allowing external code to draw to the framebuffer and decide when to present the frame.
|
|
||||||
external_present: bool,
|
|
||||||
|
|
||||||
/// Waiting for external code to call present.
|
/// Waiting for external code to call present.
|
||||||
waiting_on_present: bool,
|
waiting_on_present: bool,
|
||||||
}
|
}
|
||||||
|
@ -410,7 +406,6 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
exit_after_load,
|
exit_after_load,
|
||||||
convert_mouse_to_touch,
|
convert_mouse_to_touch,
|
||||||
waiting_on_pending_frame: false,
|
waiting_on_pending_frame: false,
|
||||||
external_present: false,
|
|
||||||
waiting_on_present: false,
|
waiting_on_present: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1858,8 +1853,8 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Perform the page flip. This will likely block for a while.
|
// Nottify embedder that servo is ready to present.
|
||||||
if self.external_present {
|
// Embedder should call `present` to tell compositor to continue rendering.
|
||||||
self.waiting_on_present = true;
|
self.waiting_on_present = true;
|
||||||
let msg = ConstellationMsg::ReadyToPresent(
|
let msg = ConstellationMsg::ReadyToPresent(
|
||||||
self.root_content_pipeline.top_level_browsing_context_id,
|
self.root_content_pipeline.top_level_browsing_context_id,
|
||||||
|
@ -1867,9 +1862,6 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
if let Err(e) = self.constellation_chan.send(msg) {
|
if let Err(e) = self.constellation_chan.send(msg) {
|
||||||
warn!("Sending event to constellation failed ({:?}).", e);
|
warn!("Sending event to constellation failed ({:?}).", e);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
self.present();
|
|
||||||
}
|
|
||||||
|
|
||||||
self.composition_request = CompositionRequest::NoCompositingNecessary;
|
self.composition_request = CompositionRequest::NoCompositingNecessary;
|
||||||
|
|
||||||
|
@ -1904,13 +1896,6 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
let gl = &self.webrender_gl;
|
let gl = &self.webrender_gl;
|
||||||
self.assert_gl_framebuffer_complete();
|
self.assert_gl_framebuffer_complete();
|
||||||
|
|
||||||
if !self.external_present {
|
|
||||||
// Make framebuffer fully transparent.
|
|
||||||
gl.clear_color(0.0, 0.0, 0.0, 0.0);
|
|
||||||
gl.clear(gleam::gl::COLOR_BUFFER_BIT);
|
|
||||||
self.assert_gl_framebuffer_complete();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the viewport background based on prefs.
|
// Set the viewport background based on prefs.
|
||||||
let viewport = self.embedder_coordinates.get_flipped_viewport();
|
let viewport = self.embedder_coordinates.get_flipped_viewport();
|
||||||
gl.scissor(
|
gl.scissor(
|
||||||
|
@ -2109,8 +2094,4 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
None => eprintln!("Unable to locate path to save captures"),
|
None => eprintln!("Unable to locate path to save captures"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_external_present(&mut self, value: bool) {
|
|
||||||
self.external_present = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -761,10 +761,6 @@ where
|
||||||
self.compositor.deinit();
|
self.compositor.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_external_present(&mut self, value: bool) {
|
|
||||||
self.compositor.set_external_present(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn present(&mut self) {
|
pub fn present(&mut self) {
|
||||||
self.compositor.present();
|
self.compositor.present();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,15 @@ pub struct App {
|
||||||
|
|
||||||
/// Action to be taken by the caller of [`App::handle_events`].
|
/// Action to be taken by the caller of [`App::handle_events`].
|
||||||
enum PumpResult {
|
enum PumpResult {
|
||||||
|
/// The caller should shut down Servo and its related context.
|
||||||
Shutdown,
|
Shutdown,
|
||||||
|
/// A new frame is ready to present. The caller can paint other things themselves during this
|
||||||
|
/// period, but has to call [`Servo::present`] to perform page flip and tell Servo compositor
|
||||||
|
/// to continue rendering.
|
||||||
ReadyToPresent,
|
ReadyToPresent,
|
||||||
|
/// The size has changed. The caller can paint other things themselves during this
|
||||||
|
/// period, but has to call [`Servo::present`] to perform page flip and tell Servo compositor
|
||||||
|
/// to continue rendering.
|
||||||
Resize,
|
Resize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,10 +124,6 @@ impl App {
|
||||||
// frame, set this to false, so we can avoid an unnecessary recomposite.
|
// frame, set this to false, so we can avoid an unnecessary recomposite.
|
||||||
let mut need_recomposite = true;
|
let mut need_recomposite = true;
|
||||||
|
|
||||||
// If we have a minibrowser, ask the compositor to notify us when a new frame
|
|
||||||
// is ready to present, so that we can paint the minibrowser then present.
|
|
||||||
let external_present = app.minibrowser.is_some();
|
|
||||||
|
|
||||||
let t_start = Instant::now();
|
let t_start = Instant::now();
|
||||||
let mut t = t_start;
|
let mut t = t_start;
|
||||||
let ev_waker = events_loop.create_event_loop_waker();
|
let ev_waker = events_loop.create_event_loop_waker();
|
||||||
|
@ -175,7 +178,6 @@ impl App {
|
||||||
|
|
||||||
let servo_data = Servo::new(embedder, window.clone(), user_agent.clone());
|
let servo_data = Servo::new(embedder, window.clone(), user_agent.clone());
|
||||||
let mut servo = servo_data.servo;
|
let mut servo = servo_data.servo;
|
||||||
servo.set_external_present(external_present);
|
|
||||||
|
|
||||||
servo.handle_events(vec![EmbedderEvent::NewBrowser(
|
servo.handle_events(vec![EmbedderEvent::NewBrowser(
|
||||||
initial_url.to_owned(),
|
initial_url.to_owned(),
|
||||||
|
@ -209,9 +211,7 @@ impl App {
|
||||||
minibrowser.update(window.winit_window().unwrap(), "RedrawRequested");
|
minibrowser.update(window.winit_window().unwrap(), "RedrawRequested");
|
||||||
minibrowser.paint(window.winit_window().unwrap());
|
minibrowser.paint(window.winit_window().unwrap());
|
||||||
}
|
}
|
||||||
if external_present {
|
|
||||||
app.servo.as_mut().unwrap().present();
|
app.servo.as_mut().unwrap().present();
|
||||||
}
|
|
||||||
|
|
||||||
// By default, the next RedrawRequested event will need to recomposite.
|
// By default, the next RedrawRequested event will need to recomposite.
|
||||||
need_recomposite = true;
|
need_recomposite = true;
|
||||||
|
@ -296,7 +296,12 @@ impl App {
|
||||||
trace!("PumpResult::ReadyToPresent");
|
trace!("PumpResult::ReadyToPresent");
|
||||||
|
|
||||||
// Request a winit redraw event, so we can paint the minibrowser and present.
|
// Request a winit redraw event, so we can paint the minibrowser and present.
|
||||||
window.winit_window().unwrap().request_redraw();
|
// Otherwise, it's in headless mode and we present directly.
|
||||||
|
if let Some(window) = window.winit_window() {
|
||||||
|
window.request_redraw();
|
||||||
|
} else {
|
||||||
|
app.servo.as_mut().unwrap().present();
|
||||||
|
}
|
||||||
|
|
||||||
// We don’t need the compositor to paint to this frame during the redraw event.
|
// We don’t need the compositor to paint to this frame during the redraw event.
|
||||||
// TODO(servo#30331) broken on macOS?
|
// TODO(servo#30331) broken on macOS?
|
||||||
|
@ -314,9 +319,7 @@ impl App {
|
||||||
minibrowser.update(window.winit_window().unwrap(), "PumpResult::Resize");
|
minibrowser.update(window.winit_window().unwrap(), "PumpResult::Resize");
|
||||||
minibrowser.paint(window.winit_window().unwrap());
|
minibrowser.paint(window.winit_window().unwrap());
|
||||||
}
|
}
|
||||||
if external_present {
|
|
||||||
app.servo.as_mut().unwrap().present();
|
app.servo.as_mut().unwrap().present();
|
||||||
}
|
|
||||||
},
|
},
|
||||||
None => {},
|
None => {},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue