From ee25413c0fe13378e0de4b716915f572e7bbc32a Mon Sep 17 00:00:00 2001 From: Paul Rouget Date: Thu, 8 Feb 2018 08:08:57 +0100 Subject: [PATCH] report panic to embedder --- components/compositing/compositor_thread.rs | 3 +++ components/compositing/windowing.rs | 3 +++ components/constellation/constellation.rs | 4 ++-- components/servo/lib.rs | 5 +++++ ports/servo/glutin_app/window.rs | 4 ++++ 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/components/compositing/compositor_thread.rs b/components/compositing/compositor_thread.rs index 2e3d69f8057..2695970e320 100644 --- a/components/compositing/compositor_thread.rs +++ b/components/compositing/compositor_thread.rs @@ -146,6 +146,8 @@ pub enum EmbedderMsg { LoadStart(TopLevelBrowsingContextId), /// The load of a page has completed LoadComplete(TopLevelBrowsingContextId), + /// A pipeline panicked. First string is the reason, second one is the backtrace. + Panic(TopLevelBrowsingContextId, String, Option), } /// Messages from the painting thread and the constellation thread to the compositor thread. @@ -237,6 +239,7 @@ impl Debug for EmbedderMsg { EmbedderMsg::SetFullscreenState(..) => write!(f, "SetFullscreenState"), EmbedderMsg::LoadStart(..) => write!(f, "LoadStart"), EmbedderMsg::LoadComplete(..) => write!(f, "LoadComplete"), + EmbedderMsg::Panic(..) => write!(f, "Panic"), } } } diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs index a0aff3577dd..473e85fcb07 100644 --- a/components/compositing/windowing.rs +++ b/components/compositing/windowing.rs @@ -189,4 +189,7 @@ pub trait WindowMethods { /// will want to avoid blocking on UI events, and just /// run the event loop at the vsync interval. fn set_animation_state(&self, _state: AnimationState) {} + + /// Called when a pipeline panics. + fn handle_panic(&self, browser_id: TopLevelBrowsingContextId, reason: String, backtrace: Option); } diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index cb6bbb0c7a6..3db4c5c39f2 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -1482,7 +1482,7 @@ impl Constellation fn handle_panic(&mut self, top_level_browsing_context_id: TopLevelBrowsingContextId, reason: String, - _backtrace: Option) + backtrace: Option) { if opts::get().hard_fail { // It's quite difficult to make Servo exit cleanly if some threads have failed. @@ -1495,7 +1495,7 @@ impl Constellation let browsing_context_id = BrowsingContextId::from(top_level_browsing_context_id); - // FIXME: report to embedder: (top_level_browsing_context_id, reason, backtrace); + self.embedder_proxy.send(EmbedderMsg::Panic(top_level_browsing_context_id, reason, backtrace)); let (window_size, pipeline_id) = { let browsing_context = self.browsing_contexts.get(&browsing_context_id); diff --git a/components/servo/lib.rs b/components/servo/lib.rs index 6f9877ff09f..8844625af19 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -457,6 +457,11 @@ impl Servo where Window: WindowMethods + 'static { // TODO(pcwalton): Specify which frame's load completed. self.compositor.window.load_end(top_level_browsing_context); }, + (EmbedderMsg::Panic(top_level_browsing_context, reason, backtrace), + ShutdownState::NotShuttingDown) => { + self.compositor.window.handle_panic(top_level_browsing_context, reason, backtrace); + }, + } } } diff --git a/ports/servo/glutin_app/window.rs b/ports/servo/glutin_app/window.rs index c4d89513f54..88c14873b7d 100644 --- a/ports/servo/glutin_app/window.rs +++ b/ports/servo/glutin_app/window.rs @@ -1354,6 +1354,10 @@ impl WindowMethods for Window { fn supports_clipboard(&self) -> bool { true } + + fn handle_panic(&self, _: BrowserId, _reason: String, _backtrace: Option) { + // Nothing to do here yet. The crash has already been reported on the console. + } } fn glutin_phase_to_touch_event_type(phase: TouchPhase) -> TouchEventType {