mirror of
https://github.com/servo/servo.git
synced 2025-07-25 16:20:36 +01:00
Move legacy layout behind a feature flag (#32759)
* Move legacy layout behind a feature flag For now the new feature flag would still be enabled by default, but disabling the `layout_2013` feature, gives the following binary size improvements for servoshell on Linux: - in debug mode from 1278MB -> 1201 MB - in release mode from 144MB -> 140MB - in production mode from 108MB -> 106MB Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com> * Update components/servo/lib.rs Co-authored-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com> --------- Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com> Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
4907e89656
commit
496ce717c5
4 changed files with 30 additions and 16 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -3619,6 +3619,7 @@ dependencies = [
|
||||||
"bluetooth_traits",
|
"bluetooth_traits",
|
||||||
"canvas",
|
"canvas",
|
||||||
"canvas_traits",
|
"canvas_traits",
|
||||||
|
"cfg-if",
|
||||||
"compositing",
|
"compositing",
|
||||||
"compositing_traits",
|
"compositing_traits",
|
||||||
"constellation",
|
"constellation",
|
||||||
|
|
|
@ -16,6 +16,7 @@ debugmozjs = ["script/debugmozjs"]
|
||||||
googlevr = ["webxr/googlevr"]
|
googlevr = ["webxr/googlevr"]
|
||||||
jitspew = ["script/jitspew"]
|
jitspew = ["script/jitspew"]
|
||||||
js_backtrace = ["script/js_backtrace"]
|
js_backtrace = ["script/js_backtrace"]
|
||||||
|
layout_2013 = ["dep:layout_thread_2013"]
|
||||||
max_log_level = ["log/release_max_level_info"]
|
max_log_level = ["log/release_max_level_info"]
|
||||||
media-gstreamer = ["servo-media-gstreamer", "gstreamer"]
|
media-gstreamer = ["servo-media-gstreamer", "gstreamer"]
|
||||||
multiview = ["compositing/multiview", "constellation/multiview"]
|
multiview = ["compositing/multiview", "constellation/multiview"]
|
||||||
|
@ -39,6 +40,7 @@ bluetooth = { path = "../bluetooth" }
|
||||||
bluetooth_traits = { workspace = true }
|
bluetooth_traits = { workspace = true }
|
||||||
canvas = { path = "../canvas", default-features = false }
|
canvas = { path = "../canvas", default-features = false }
|
||||||
canvas_traits = { workspace = true }
|
canvas_traits = { workspace = true }
|
||||||
|
cfg-if = { workspace = true }
|
||||||
compositing = { path = "../compositing" }
|
compositing = { path = "../compositing" }
|
||||||
compositing_traits = { workspace = true }
|
compositing_traits = { workspace = true }
|
||||||
constellation = { path = "../constellation" }
|
constellation = { path = "../constellation" }
|
||||||
|
@ -54,7 +56,7 @@ gleam = { workspace = true }
|
||||||
gstreamer = { workspace = true, optional = true }
|
gstreamer = { workspace = true, optional = true }
|
||||||
ipc-channel = { workspace = true }
|
ipc-channel = { workspace = true }
|
||||||
keyboard-types = { workspace = true }
|
keyboard-types = { workspace = true }
|
||||||
layout_thread_2013 = { path = "../layout_thread" }
|
layout_thread_2013 = { path = "../layout_thread", optional = true }
|
||||||
layout_thread_2020 = { path = "../layout_thread_2020" }
|
layout_thread_2020 = { path = "../layout_thread_2020" }
|
||||||
log = { workspace = true }
|
log = { workspace = true }
|
||||||
media = { path = "../media" }
|
media = { path = "../media" }
|
||||||
|
|
|
@ -67,6 +67,8 @@ use fonts::FontCacheThread;
|
||||||
use gaol::sandbox::{ChildSandbox, ChildSandboxMethods};
|
use gaol::sandbox::{ChildSandbox, ChildSandboxMethods};
|
||||||
pub use gleam::gl;
|
pub use gleam::gl;
|
||||||
use ipc_channel::ipc::{self, IpcSender};
|
use ipc_channel::ipc::{self, IpcSender};
|
||||||
|
#[cfg(feature = "layout_2013")]
|
||||||
|
pub use layout_thread_2013;
|
||||||
use log::{error, trace, warn, Log, Metadata, Record};
|
use log::{error, trace, warn, Log, Metadata, Record};
|
||||||
use media::{GLPlayerThreads, GlApi, NativeDisplay, WindowGLContext};
|
use media::{GLPlayerThreads, GlApi, NativeDisplay, WindowGLContext};
|
||||||
use net::resource_thread::new_resource_threads;
|
use net::resource_thread::new_resource_threads;
|
||||||
|
@ -98,10 +100,9 @@ use webrender_traits::{
|
||||||
pub use {
|
pub use {
|
||||||
background_hang_monitor, base, bluetooth, bluetooth_traits, canvas, canvas_traits, compositing,
|
background_hang_monitor, base, bluetooth, bluetooth_traits, canvas, canvas_traits, compositing,
|
||||||
constellation, devtools, devtools_traits, embedder_traits, euclid, fonts, ipc_channel,
|
constellation, devtools, devtools_traits, embedder_traits, euclid, fonts, ipc_channel,
|
||||||
keyboard_types, layout_thread_2013, layout_thread_2020, media, net, net_traits, profile,
|
keyboard_types, layout_thread_2020, media, net, net_traits, profile, profile_traits, script,
|
||||||
profile_traits, script, script_layout_interface, script_traits, servo_config as config,
|
script_layout_interface, script_traits, servo_config as config, servo_config, servo_geometry,
|
||||||
servo_config, servo_geometry, servo_url as url, servo_url, style, style_traits, webgpu,
|
servo_url as url, servo_url, style, style_traits, webgpu, webrender_api, webrender_traits,
|
||||||
webrender_api, webrender_traits,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "webdriver")]
|
#[cfg(feature = "webdriver")]
|
||||||
|
@ -968,6 +969,22 @@ fn create_compositor_channel(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_layout_factory(legacy_layout: bool) -> Arc<dyn LayoutFactory> {
|
||||||
|
cfg_if::cfg_if! {
|
||||||
|
if #[cfg(feature = "layout_2013")] {
|
||||||
|
if legacy_layout {
|
||||||
|
return Arc::new(layout_thread_2013::LayoutFactoryImpl());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if legacy_layout {
|
||||||
|
warn!("Runtime option `legacy_layout` was enabled, but the `layout_2013` \
|
||||||
|
feature was not enabled at compile time. Falling back to layout 2020! ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Arc::new(layout_thread_2020::LayoutFactoryImpl())
|
||||||
|
}
|
||||||
|
|
||||||
fn create_constellation(
|
fn create_constellation(
|
||||||
user_agent: Cow<'static, str>,
|
user_agent: Cow<'static, str>,
|
||||||
config_dir: Option<PathBuf>,
|
config_dir: Option<PathBuf>,
|
||||||
|
@ -1034,11 +1051,7 @@ fn create_constellation(
|
||||||
wgpu_image_map,
|
wgpu_image_map,
|
||||||
};
|
};
|
||||||
|
|
||||||
let layout_factory: Arc<dyn LayoutFactory> = if opts::get().legacy_layout {
|
let layout_factory: Arc<dyn LayoutFactory> = get_layout_factory(opts::get().legacy_layout);
|
||||||
Arc::new(layout_thread_2013::LayoutFactoryImpl())
|
|
||||||
} else {
|
|
||||||
Arc::new(layout_thread_2020::LayoutFactoryImpl())
|
|
||||||
};
|
|
||||||
|
|
||||||
Constellation::<
|
Constellation::<
|
||||||
script::script_thread::ScriptThread,
|
script::script_thread::ScriptThread,
|
||||||
|
@ -1213,11 +1226,8 @@ pub fn run_content_process(token: String) {
|
||||||
set_logger(content.script_to_constellation_chan().clone());
|
set_logger(content.script_to_constellation_chan().clone());
|
||||||
|
|
||||||
let background_hang_monitor_register = content.register_with_background_hang_monitor();
|
let background_hang_monitor_register = content.register_with_background_hang_monitor();
|
||||||
let layout_factory: Arc<dyn LayoutFactory> = if opts::get().legacy_layout {
|
let layout_factory: Arc<dyn LayoutFactory> =
|
||||||
Arc::new(layout_thread_2013::LayoutFactoryImpl())
|
get_layout_factory(opts::get().legacy_layout);
|
||||||
} else {
|
|
||||||
Arc::new(layout_thread_2020::LayoutFactoryImpl())
|
|
||||||
};
|
|
||||||
|
|
||||||
content.start_all::<script::script_thread::ScriptThread>(
|
content.start_all::<script::script_thread::ScriptThread>(
|
||||||
true,
|
true,
|
||||||
|
|
|
@ -38,9 +38,10 @@ ProductName = "Servo"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
debugmozjs = ["libservo/debugmozjs"]
|
debugmozjs = ["libservo/debugmozjs"]
|
||||||
default = ["max_log_level", "webdriver"]
|
default = ["layout_2013", "max_log_level", "webdriver"]
|
||||||
jitspew = ["libservo/jitspew"]
|
jitspew = ["libservo/jitspew"]
|
||||||
js_backtrace = ["libservo/js_backtrace"]
|
js_backtrace = ["libservo/js_backtrace"]
|
||||||
|
layout_2013 = ["libservo/layout_2013"]
|
||||||
max_log_level = ["log/release_max_level_info"]
|
max_log_level = ["log/release_max_level_info"]
|
||||||
media-gstreamer = ["libservo/media-gstreamer"]
|
media-gstreamer = ["libservo/media-gstreamer"]
|
||||||
multiview = ["libservo/multiview"]
|
multiview = ["libservo/multiview"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue