mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
compositing: Split Servo up into multiple sandboxed processes.
Multiprocess mode is enabled with the `-M` switch, and sandboxing is enabled with the `-S` switch.
This commit is contained in:
parent
ff4171170d
commit
1c130819ca
33 changed files with 688 additions and 265 deletions
16
components/servo/Cargo.lock
generated
16
components/servo/Cargo.lock
generated
|
@ -11,11 +11,13 @@ dependencies = [
|
|||
"devtools_traits 0.0.1",
|
||||
"env_logger 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gaol 0.0.1 (git+https://github.com/pcwalton/gaol)",
|
||||
"gfx 0.0.1",
|
||||
"gfx_tests 0.0.1",
|
||||
"gleam 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"glutin_app 0.0.1",
|
||||
"image 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)",
|
||||
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
|
||||
"layout 0.0.1",
|
||||
"libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -261,6 +263,7 @@ dependencies = [
|
|||
"core-text 0.1.0 (git+https://github.com/servo/core-text-rs)",
|
||||
"devtools_traits 0.0.1",
|
||||
"euclid 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gaol 0.0.1 (git+https://github.com/pcwalton/gaol)",
|
||||
"gfx 0.0.1",
|
||||
"gfx_traits 0.0.1",
|
||||
"gleam 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -268,6 +271,7 @@ dependencies = [
|
|||
"ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)",
|
||||
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
|
||||
"layout_traits 0.0.1",
|
||||
"libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
"net_traits 0.0.1",
|
||||
|
@ -276,6 +280,8 @@ dependencies = [
|
|||
"plugins 0.0.1",
|
||||
"profile_traits 0.0.1",
|
||||
"script_traits 0.0.1",
|
||||
"serde 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"style_traits 0.0.1",
|
||||
"time 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -600,6 +606,16 @@ dependencies = [
|
|||
"mac 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gaol"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/pcwalton/gaol#71865ff8a1824cbc1cbee4d388d56c5ba1b5ffc2"
|
||||
dependencies = [
|
||||
"libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gcc"
|
||||
version = "0.3.16"
|
||||
|
|
|
@ -129,6 +129,12 @@ features = [ "serde_serialization" ]
|
|||
version = "0.3"
|
||||
features = ["plugins"]
|
||||
|
||||
[dependencies.gaol]
|
||||
git = "https://github.com/pcwalton/gaol"
|
||||
|
||||
[dependencies.ipc-channel]
|
||||
git = "https://github.com/pcwalton/ipc-channel"
|
||||
|
||||
[dependencies.layers]
|
||||
git = "https://github.com/servo/rust-layers"
|
||||
features = ["plugins"]
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
// The `Browser` is fed events from a generic type that implements the
|
||||
// `WindowMethods` trait.
|
||||
|
||||
extern crate gaol;
|
||||
|
||||
#[macro_use]
|
||||
extern crate util as _util;
|
||||
|
||||
|
@ -29,6 +31,7 @@ mod export {
|
|||
extern crate euclid;
|
||||
extern crate gfx;
|
||||
extern crate gleam;
|
||||
extern crate ipc_channel;
|
||||
extern crate layers;
|
||||
extern crate layout;
|
||||
extern crate msg;
|
||||
|
@ -48,22 +51,25 @@ extern crate libc;
|
|||
extern crate webdriver_server;
|
||||
|
||||
#[cfg(feature = "webdriver")]
|
||||
fn webdriver(port: u16, constellation: msg::constellation_msg::ConstellationChan<ConstellationMsg>) {
|
||||
webdriver_server::start_server(port, constellation.clone());
|
||||
fn webdriver(port: u16, constellation: Sender<ConstellationMsg>) {
|
||||
webdriver_server::start_server(port, constellation);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "webdriver"))]
|
||||
fn webdriver(_port: u16, _constellation: msg::constellation_msg::ConstellationChan<ConstellationMsg>) { }
|
||||
fn webdriver(_port: u16, _constellation: Sender<ConstellationMsg>) { }
|
||||
|
||||
use compositing::CompositorEventListener;
|
||||
use compositing::compositor_task::InitialCompositorState;
|
||||
use compositing::constellation::InitialConstellationState;
|
||||
use compositing::pipeline::UnprivilegedPipelineContent;
|
||||
use compositing::sandboxing;
|
||||
use compositing::windowing::WindowEvent;
|
||||
use compositing::windowing::WindowMethods;
|
||||
use compositing::{CompositorProxy, CompositorTask, Constellation};
|
||||
use gaol::sandbox::{ChildSandbox, ChildSandboxMethods};
|
||||
use gfx::font_cache_task::FontCacheTask;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use msg::constellation_msg::CompositorMsg as ConstellationMsg;
|
||||
use msg::constellation_msg::ConstellationChan;
|
||||
use net::image_cache_task::new_image_cache_task;
|
||||
use net::resource_task::new_resource_task;
|
||||
use net::storage_task::StorageTaskFactory;
|
||||
|
@ -86,6 +92,7 @@ pub use export::devtools_traits;
|
|||
pub use export::euclid;
|
||||
pub use export::gfx;
|
||||
pub use export::gleam::gl;
|
||||
pub use export::ipc_channel;
|
||||
pub use export::layers;
|
||||
pub use export::layout;
|
||||
pub use export::msg;
|
||||
|
@ -193,7 +200,7 @@ fn create_constellation(opts: opts::Opts,
|
|||
time_profiler_chan: time::ProfilerChan,
|
||||
mem_profiler_chan: mem::ProfilerChan,
|
||||
devtools_chan: Option<Sender<devtools_traits::DevtoolsControlMsg>>,
|
||||
supports_clipboard: bool) -> ConstellationChan<ConstellationMsg> {
|
||||
supports_clipboard: bool) -> Sender<ConstellationMsg> {
|
||||
let resource_task = new_resource_task(opts.user_agent.clone(), devtools_chan.clone());
|
||||
|
||||
let image_cache_task = new_image_cache_task(resource_task.clone());
|
||||
|
@ -218,11 +225,33 @@ fn create_constellation(opts: opts::Opts,
|
|||
// Send the URL command to the constellation.
|
||||
match opts.url {
|
||||
Some(url) => {
|
||||
let ConstellationChan(ref chan) = constellation_chan;
|
||||
chan.send(ConstellationMsg::InitLoadUrl(url)).unwrap();
|
||||
constellation_chan.send(ConstellationMsg::InitLoadUrl(url)).unwrap();
|
||||
},
|
||||
None => ()
|
||||
};
|
||||
|
||||
constellation_chan
|
||||
}
|
||||
|
||||
/// Content process entry point.
|
||||
pub fn run_content_process(token: String) {
|
||||
let (unprivileged_content_sender, unprivileged_content_receiver) =
|
||||
ipc::channel::<UnprivilegedPipelineContent>().unwrap();
|
||||
let connection_bootstrap: IpcSender<IpcSender<UnprivilegedPipelineContent>> =
|
||||
IpcSender::connect(token).unwrap();
|
||||
connection_bootstrap.send(unprivileged_content_sender).unwrap();
|
||||
|
||||
let unprivileged_content = unprivileged_content_receiver.recv().unwrap();
|
||||
opts::set_defaults(unprivileged_content.opts());
|
||||
|
||||
// Enter the sandbox if necessary.
|
||||
if opts::get().sandbox {
|
||||
ChildSandbox::new(sandboxing::content_process_sandbox_profile()).activate().unwrap();
|
||||
}
|
||||
|
||||
script::init();
|
||||
|
||||
unprivileged_content.start_all::<layout::layout_task::LayoutTask,
|
||||
script::script_task::ScriptTask>(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ use offscreen_gl_context::GLContext;
|
|||
use servo::Browser;
|
||||
use servo::compositing::windowing::WindowEvent;
|
||||
use servo::net_traits::hosts;
|
||||
use servo::util::opts;
|
||||
use servo::util::opts::{self, ArgumentParsingResult};
|
||||
use std::rc::Rc;
|
||||
|
||||
#[cfg(not(target_os = "android"))]
|
||||
|
@ -52,11 +52,17 @@ fn load_gl_when_headless() {}
|
|||
|
||||
fn main() {
|
||||
// Parse the command line options and store them globally
|
||||
opts::from_cmdline_args(&*args());
|
||||
let opts_result = opts::from_cmdline_args(&*args());
|
||||
|
||||
if opts::get().is_running_problem_test && ::std::env::var("RUST_LOG").is_err() {
|
||||
::std::env::set_var("RUST_LOG", "compositing::constellation");
|
||||
}
|
||||
let content_process_token = if let ArgumentParsingResult::ContentProcess(token) = opts_result {
|
||||
Some(token)
|
||||
} else {
|
||||
if opts::get().is_running_problem_test && ::std::env::var("RUST_LOG").is_err() {
|
||||
::std::env::set_var("RUST_LOG", "compositing::constellation");
|
||||
}
|
||||
|
||||
None
|
||||
};
|
||||
|
||||
env_logger::init().unwrap();
|
||||
|
||||
|
@ -65,6 +71,10 @@ fn main() {
|
|||
// Possibly interpret the `HOST_FILE` environment variable
|
||||
hosts::global_init();
|
||||
|
||||
if let Some(token) = content_process_token {
|
||||
return servo::run_content_process(token)
|
||||
}
|
||||
|
||||
let window = if opts::get().headless {
|
||||
// Load gl functions even when in headless mode,
|
||||
// to avoid crashing with webgl
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue