From 342844ed7b5684d67e16ca74ada6dcdb7bcf92fc Mon Sep 17 00:00:00 2001 From: Lars Bergstrom Date: Wed, 15 Jan 2014 15:26:39 -0600 Subject: When `window.close()` is called, we should just ask the compositor to exit normally. The old code made the mistake of attempting to shutdown the associated pipelines itself, which caused race conditions with the constellation and compositor, as they expect to be able to drain their message queues before exiting. --- src/components/script/script_task.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/components/script/script_task.rs') diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs index 9ca9af2f8a6..8034822e9d9 100644 --- a/src/components/script/script_task.rs +++ b/src/components/script/script_task.rs @@ -531,10 +531,7 @@ impl ScriptTask { ReflowCompleteMsg(id, reflow_id) => self.handle_reflow_complete_msg(id, reflow_id), ResizeInactiveMsg(id, new_size) => self.handle_resize_inactive_msg(id, new_size), ExitPipelineMsg(id) => if self.handle_exit_pipeline_msg(id) { return false }, - ExitWindowMsg(id) => { - self.handle_exit_window_msg(id); - return false - }, + ExitWindowMsg(id) => self.handle_exit_window_msg(id), ResizeMsg(..) => fail!("should have handled ResizeMsg already"), } } @@ -614,9 +611,13 @@ impl ScriptTask { } } - fn handle_exit_window_msg(&mut self, id: PipelineId) { + /// We have gotten a window.close from script, which we pass on to the compositor. + /// We do not shut down the script task now, because the compositor will ask the + /// constellation to shut down the pipeline, which will clean everything up + /// normally. If we do exit, we will tear down the DOM nodes, possibly at a point + /// where layout is still accessing them. + fn handle_exit_window_msg(&mut self, _: PipelineId) { debug!("script task handling exit window msg"); - self.handle_exit_pipeline_msg(id); // TODO(tkuehn): currently there is only one window, // so this can afford to be naive and just shut down the -- cgit v1.2.3