diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-05-20 20:01:32 -0500 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-05-20 20:01:32 -0500 |
commit | 1060cfde68c8d355b54a271923c9682721c5ed19 (patch) | |
tree | 1e912151d626d51af90834c5e8eaf43cf9f7719a | |
parent | 7ae5d1129f9fd1227678db9ad26471727dc9fa27 (diff) | |
parent | b84c6fa5db6d7930a6340ed05fd453f7a91aaed8 (diff) | |
download | servo-1060cfde68c8d355b54a271923c9682721c5ed19.tar.gz servo-1060cfde68c8d355b54a271923c9682721c5ed19.zip |
Auto merge of #6152 - glennw:runnable-panic, r=jdm
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6152)
<!-- Reviewable:end -->
-rw-r--r-- | components/gfx/paint_task.rs | 2 | ||||
-rw-r--r-- | components/script/dom/document.rs | 18 | ||||
-rw-r--r-- | components/script/dom/window.rs | 21 |
3 files changed, 32 insertions, 9 deletions
diff --git a/components/gfx/paint_task.rs b/components/gfx/paint_task.rs index 10f748e7b5c..007668ad709 100644 --- a/components/gfx/paint_task.rs +++ b/components/gfx/paint_task.rs @@ -308,7 +308,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static { // If we own buffers in the compositor and we are not exiting completely, wait // for the compositor to return buffers, so that we can release them properly. // When doing a complete exit, the compositor lets all buffers leak. - println!("PaintTask {:?}: Saw ExitMsg, {} buffers in use", self.id, self.used_buffer_count); + debug!("PaintTask {:?}: Saw ExitMsg, {} buffers in use", self.id, self.used_buffer_count); waiting_for_compositor_buffers_to_exit = true; exit_response_channel = response_channel; } diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 19901c43796..9fabde71dd9 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -1830,13 +1830,17 @@ impl DocumentProgressHandler { impl Runnable for DocumentProgressHandler { fn handler(self: Box<DocumentProgressHandler>) { - match self.task { - DocumentProgressTask::DOMContentLoaded => { - self.dispatch_dom_content_loaded(); - } - DocumentProgressTask::Load => { - self.set_ready_state_complete(); - self.dispatch_load(); + let document = self.addr.to_temporary().root(); + let window = document.r().window().root(); + if window.r().is_alive() { + match self.task { + DocumentProgressTask::DOMContentLoaded => { + self.dispatch_dom_content_loaded(); + } + DocumentProgressTask::Load => { + self.set_ready_state_complete(); + self.dispatch_load(); + } } } } diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index f791464366d..b8e0ffb86e7 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -69,6 +69,14 @@ use std::sync::mpsc::{channel, Receiver, Sender}; use std::sync::mpsc::TryRecvError::{Empty, Disconnected}; use time; +/// Current state of the window object +#[derive(Copy, Clone, Debug, PartialEq)] +#[jstraceable] +enum WindowState { + Alive, + Zombie, // Pipeline is closed, but the window hasn't been GCed yet. +} + /// Extra information concerning the reason for reflowing. #[derive(Debug)] pub enum ReflowReason { @@ -170,7 +178,10 @@ pub struct Window { pending_reflow_count: Cell<u32>, /// A channel for communicating results of async scripts back to the webdriver server - webdriver_script_chan: RefCell<Option<Sender<WebDriverJSResult>>> + webdriver_script_chan: RefCell<Option<Sender<WebDriverJSResult>>>, + + /// The current state of the window object + current_state: Cell<WindowState>, } impl Window { @@ -179,6 +190,7 @@ impl Window { unsafe { *self.js_runtime.borrow_for_script_deallocation() = None; *self.browser_context.borrow_for_script_deallocation() = None; + self.current_state.set(WindowState::Zombie); } } @@ -544,6 +556,7 @@ pub trait WindowHelpers { fn set_devtools_timeline_marker(self, marker: TimelineMarkerType, reply: Sender<TimelineMarker>); fn drop_devtools_timeline_markers(self); fn set_webdriver_script_chan(self, chan: Option<Sender<WebDriverJSResult>>); + fn is_alive(self) -> bool; } pub trait ScriptHelpers { @@ -595,6 +608,7 @@ impl<'a> WindowHelpers for JSRef<'a, Window> { // which causes a panic! self.Gc(); + self.current_state.set(WindowState::Zombie); *self.js_runtime.borrow_mut() = None; *self.browser_context.borrow_mut() = None; } @@ -916,6 +930,10 @@ impl<'a> WindowHelpers for JSRef<'a, Window> { fn set_webdriver_script_chan(self, chan: Option<Sender<WebDriverJSResult>>) { *self.webdriver_script_chan.borrow_mut() = chan; } + + fn is_alive(self) -> bool { + self.current_state.get() == WindowState::Alive + } } impl Window { @@ -979,6 +997,7 @@ impl Window { layout_join_port: DOMRefCell::new(None), window_size: Cell::new(window_size), pending_reflow_count: Cell::new(0), + current_state: Cell::new(WindowState::Alive), devtools_marker_sender: RefCell::new(None), devtools_markers: RefCell::new(HashSet::new()), |