mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Stall PaintTask exit until it can release all buffers
It is possible for a PaintTask to start exiting soon after sending new buffers to the compositor. In that case, the compositor should return the now unnecessary buffers to the PaintTask so that it can properly free them. To accomplish this, the compositor now keeps a hash map of paint task channels per pipeline id. When a PaintTask exists, the constellation informs the compositor that it can forget about it. Additionally, the PaintTask should not wait for any buffers when the engine is doing a complete shutdown. In that case, the compositor is already halted and has simply let all buffers leak. We pipe through the shutdown type when destroying the pipeline to make this decision. Fixes #2641.
This commit is contained in:
parent
141b5d038f
commit
c0b397322f
13 changed files with 180 additions and 103 deletions
|
@ -3,15 +3,16 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use CompositorProxy;
|
||||
use layout_traits::{LayoutTaskFactory, LayoutControlChan};
|
||||
use layout_traits::{ExitNowMsg, LayoutTaskFactory, LayoutControlChan};
|
||||
use script_traits::{ScriptControlChan, ScriptTaskFactory};
|
||||
use script_traits::{AttachLayoutMsg, LoadMsg, NewLayoutInfo, ExitPipelineMsg};
|
||||
|
||||
use devtools_traits::DevtoolsControlChan;
|
||||
use gfx::paint_task;
|
||||
use gfx::paint_task::{PaintPermissionGranted, PaintPermissionRevoked};
|
||||
use gfx::paint_task::{PaintChan, PaintTask};
|
||||
use servo_msg::constellation_msg::{ConstellationChan, Failure, PipelineId, SubpageId};
|
||||
use servo_msg::constellation_msg::{LoadData, WindowSizeData};
|
||||
use servo_msg::constellation_msg::{ConstellationChan, ExitMsg, Failure, PipelineId, SubpageId};
|
||||
use servo_msg::constellation_msg::{LoadData, WindowSizeData, PipelineExitType};
|
||||
use servo_net::image_cache_task::ImageCacheTask;
|
||||
use gfx::font_cache_task::FontCacheTask;
|
||||
use servo_net::resource_task::ResourceTask;
|
||||
|
@ -173,18 +174,27 @@ impl Pipeline {
|
|||
let _ = self.paint_chan.send_opt(PaintPermissionRevoked);
|
||||
}
|
||||
|
||||
pub fn exit(&self) {
|
||||
pub fn exit(&self, exit_type: PipelineExitType) {
|
||||
debug!("pipeline {} exiting", self.id);
|
||||
|
||||
// Script task handles shutting down layout, and layout handles shutting down the painter.
|
||||
// For now, if the script task has failed, we give up on clean shutdown.
|
||||
let ScriptControlChan(ref chan) = self.script_chan;
|
||||
if chan.send_opt(ExitPipelineMsg(self.id)).is_ok() {
|
||||
if chan.send_opt(ExitPipelineMsg(self.id, exit_type)).is_ok() {
|
||||
// Wait until all slave tasks have terminated and run destructors
|
||||
// NOTE: We don't wait for script task as we don't always own it
|
||||
let _ = self.paint_shutdown_port.recv_opt();
|
||||
let _ = self.layout_shutdown_port.recv_opt();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pub fn force_exit(&self) {
|
||||
let ScriptControlChan(ref script_channel) = self.script_chan;
|
||||
let _ = script_channel.send_opt( ExitPipelineMsg(self.id, PipelineExitType::PipelineOnly));
|
||||
let _ = self.paint_chan.send_opt(paint_task::ExitMsg(None, PipelineExitType::PipelineOnly));
|
||||
let LayoutControlChan(ref layout_channel) = self.layout_chan;
|
||||
let _ = layout_channel.send_opt(ExitNowMsg(PipelineExitType::PipelineOnly));
|
||||
}
|
||||
|
||||
pub fn to_sendable(&self) -> CompositionPipeline {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue