diff options
author | Delan Azabani <dazabani@igalia.com> | 2024-10-16 18:24:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-16 10:24:24 +0000 |
commit | fa1f7e5839a35019d5ac2f105a45b555292b74fd (patch) | |
tree | 10725cd46d2c49d09cce022f6fda6c50016295f9 | |
parent | 103d3aa7bb6341957c31a1aae4f925068e39e951 (diff) | |
download | servo-fa1f7e5839a35019d5ac2f105a45b555292b74fd.tar.gz servo-fa1f7e5839a35019d5ac2f105a45b555292b74fd.zip |
Gate all use of `tracing` behind Cargo feature (#33845)
Signed-off-by: Delan Azabani <dazabani@igalia.com>
-rw-r--r-- | components/compositing/Cargo.toml | 3 | ||||
-rw-r--r-- | components/compositing/compositor.rs | 44 | ||||
-rw-r--r-- | components/constellation/Cargo.toml | 3 | ||||
-rw-r--r-- | components/constellation/constellation.rs | 447 | ||||
-rw-r--r-- | components/fonts/Cargo.toml | 5 | ||||
-rw-r--r-- | components/fonts/font_context.rs | 6 | ||||
-rw-r--r-- | components/fonts/system_font_service.rs | 37 | ||||
-rw-r--r-- | components/layout_2020/Cargo.toml | 5 | ||||
-rw-r--r-- | components/layout_2020/flexbox/layout.rs | 34 | ||||
-rw-r--r-- | components/layout_2020/table/layout.rs | 17 | ||||
-rw-r--r-- | components/layout_thread_2020/Cargo.toml | 5 | ||||
-rw-r--r-- | components/layout_thread_2020/lib.rs | 74 | ||||
-rw-r--r-- | components/servo/Cargo.toml | 3 | ||||
-rw-r--r-- | components/servo/lib.rs | 5 | ||||
-rw-r--r-- | ports/servoshell/Cargo.toml | 2 |
15 files changed, 534 insertions, 156 deletions
diff --git a/components/compositing/Cargo.toml b/components/compositing/Cargo.toml index 0458f246232..5d39b8294f0 100644 --- a/components/compositing/Cargo.toml +++ b/components/compositing/Cargo.toml @@ -14,6 +14,7 @@ path = "lib.rs" [features] default = [] multiview = [] +tracing = ["dep:tracing"] [dependencies] base = { workspace = true } @@ -41,7 +42,7 @@ servo-media = { workspace = true } servo_geometry = { path = "../geometry" } servo_url = { path = "../url" } style_traits = { workspace = true } -tracing = { workspace = true } +tracing = { workspace = true, optional = true } webrender = { workspace = true } webrender_api = { workspace = true } webrender_traits = { workspace = true } diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index eb0eb08096f..6a20ee72c10 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -35,7 +35,6 @@ use script_traits::{ }; use servo_geometry::{DeviceIndependentPixel, FramebufferUintLength}; use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor}; -use tracing::{instrument, span, Level}; use webrender::{CaptureBits, RenderApi, Transaction}; use webrender_api::units::{ DeviceIntPoint, DeviceIntSize, DevicePoint, DeviceRect, LayoutPoint, LayoutRect, LayoutSize, @@ -661,7 +660,10 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { /// Accept messages from content processes that need to be relayed to the WebRender /// instance in the parent process. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_cross_process_message(&mut self, msg: CrossProcessCompositorMessage) { match msg { CrossProcessCompositorMessage::SendInitialTransaction(pipeline) => { @@ -747,11 +749,13 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { display_list_descriptor, ); - let span = span!( - Level::TRACE, + #[cfg(feature = "tracing")] + let span = tracing::span!( + tracing::Level::TRACE, "ScriptToCompositorMsg::BuiltDisplayList", servo_profiling = true ); + #[cfg(feature = "tracing")] let _enter = span.enter(); let pipeline_id = display_list_info.pipeline_id; let details = self.pipeline_details(pipeline_id.into()); @@ -2006,7 +2010,10 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { /// Returns Ok if composition was performed or Err if it was not possible to composite for some /// reason. When the target is [CompositeTarget::SharedMemory], the image is read back from the /// GPU and returned as Ok(Some(png::Image)), otherwise we return Ok(None). - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn composite_specific_target( &mut self, target: CompositeTarget, @@ -2219,11 +2226,13 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { }, }; - let span = span!( - Level::TRACE, + #[cfg(feature = "tracing")] + let span = tracing::span!( + tracing::Level::TRACE, "ConstellationMsg::ReadyToPresent", servo_profiling = true ); + #[cfg(feature = "tracing")] let _enter = span.enter(); // Notify embedder that servo is ready to present. // Embedder should call `present` to tell compositor to continue rendering. @@ -2249,13 +2258,18 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { .map(|info| info.framebuffer_id()) } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] pub fn present(&mut self) { - let span = span!( - Level::TRACE, + #[cfg(feature = "tracing")] + let span = tracing::span!( + tracing::Level::TRACE, "Compositor Present Surface", servo_profiling = true ); + #[cfg(feature = "tracing")] let _enter = span.enter(); if let Err(err) = self.rendering_context.present() { warn!("Failed to present surface: {:?}", err); @@ -2318,7 +2332,10 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { ); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] pub fn receive_messages(&mut self) -> bool { // Check for new messages coming from the other threads in the system. let mut compositor_messages = vec![]; @@ -2345,7 +2362,10 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { true } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] pub fn perform_updates(&mut self) -> bool { if self.shutdown_state == ShutdownState::FinishedShuttingDown { return false; diff --git a/components/constellation/Cargo.toml b/components/constellation/Cargo.toml index 6d57918c16c..22f07f165f4 100644 --- a/components/constellation/Cargo.toml +++ b/components/constellation/Cargo.toml @@ -14,6 +14,7 @@ path = "lib.rs" [features] default = [] multiview = [] +tracing = ["dep:tracing"] [dependencies] background_hang_monitor_api = { workspace = true } @@ -45,11 +46,11 @@ servo_config = { path = "../config" } servo_rand = { path = "../rand" } servo_url = { path = "../url" } style_traits = { workspace = true } +tracing = { workspace = true, optional = true } webgpu = { path = "../webgpu" } webrender = { workspace = true } webrender_api = { workspace = true } webrender_traits = { workspace = true } -tracing = { workspace = true } webxr-api = { git = "https://github.com/servo/webxr", features = ["ipc"] } [target.'cfg(any(target_os="macos", all(not(target_os = "windows"), not(target_os = "ios"), not(target_os="android"), not(target_arch="arm"), not(target_arch="aarch64"))))'.dependencies] diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index cb2138cc8ac..be5ad7f8163 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -151,7 +151,6 @@ use servo_config::{opts, pref}; use servo_rand::{random, Rng, ServoRng, SliceRandom}; use servo_url::{Host, ImmutableOrigin, ServoUrl}; use style_traits::CSSPixel; -use tracing::{instrument, span, Level}; use webgpu::swapchain::WGPUImageMap; use webgpu::{self, WebGPU, WebGPURequest, WebGPUResponse}; use webrender::{RenderApi, RenderApiSender}; @@ -609,7 +608,10 @@ where { /// Create a new constellation thread. #[allow(clippy::too_many_arguments)] - #[tracing::instrument(skip(state, layout_factory), fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip(state, layout_factory), fields(servo_profiling = true)) + )] pub fn start( state: InitialConstellationState, layout_factory: Arc<dyn LayoutFactory>, @@ -1153,7 +1155,10 @@ where } /// Handles loading pages, navigation, and granting access to the compositor - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_request(&mut self) { #[derive(Debug)] enum Request { @@ -1250,13 +1255,19 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_request_for_pipeline_namespace(&mut self, request: PipelineNamespaceRequest) { let PipelineNamespaceRequest(sender) = request; let _ = sender.send(self.next_pipeline_namespace_id()); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_request_from_background_hang_monitor(&self, message: HangMonitorAlert) { match message { HangMonitorAlert::Profile(bytes) => self @@ -1270,7 +1281,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_request_from_network_listener(&mut self, message: (PipelineId, FetchResponseMsg)) { let (id, message_) = message; let result = match self.pipelines.get(&id) { @@ -1296,7 +1310,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_request_from_compositor(&mut self, message: FromCompositorMsg) { trace_msg_from_compositor!(message, "{message:?}"); match message { @@ -1509,11 +1526,13 @@ where self.set_webview_throttled(webview_id, throttled); }, FromCompositorMsg::ReadyToPresent(webview_ids) => { - let span = span!( - Level::TRACE, + #[cfg(feature = "tracing")] + let span = tracing::span!( + tracing::Level::TRACE, "FromCompositorMsg::ReadyToPresent", servo_profiling = true ); + #[cfg(feature = "tracing")] let _enter = span.enter(); self.embedder_proxy .send((None, EmbedderMsg::ReadyToPresent(webview_ids))); @@ -1524,7 +1543,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_request_from_script(&mut self, message: (PipelineId, FromScriptMsg)) { let (source_pipeline_id, content) = message; trace_script_msg!(content, "{source_pipeline_id}: {content:?}"); @@ -1842,7 +1864,10 @@ where } /// Broadcast a message via routers in various event-loops. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_schedule_broadcast( &self, pipeline_id: PipelineId, @@ -1886,7 +1911,10 @@ where } /// Remove a channel-name for a given broadcast router. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_remove_broadcast_channel_name_in_router( &mut self, pipeline_id: PipelineId, @@ -1922,7 +1950,10 @@ where } /// Note a new channel-name relevant to a given broadcast router. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_new_broadcast_channel_name_in_router( &mut self, pipeline_id: PipelineId, @@ -1944,7 +1975,10 @@ where } /// Remove a broadcast router. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_remove_broadcast_channel_router( &mut self, pipeline_id: PipelineId, @@ -1963,7 +1997,10 @@ where } /// Add a new broadcast router. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_new_broadcast_channel_router( &mut self, pipeline_id: PipelineId, @@ -1986,7 +2023,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_wgpu_request( &mut self, source_pipeline_id: PipelineId, @@ -2064,7 +2104,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_request_from_layout(&mut self, message: FromLayoutMsg) { trace_layout_msg!(message, "{message:?}"); match message { @@ -2079,7 +2122,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_message_port_transfer_completed( &mut self, router_id: Option<MessagePortRouterId>, @@ -2218,7 +2264,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_complete_message_port_transfer( &mut self, router_id: MessagePortRouterId, @@ -2299,7 +2348,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_reroute_messageport(&mut self, port_id: MessagePortId, task: PortMessageTask) { let info = match self.message_ports.get_mut(&port_id) { Some(info) => info, @@ -2331,7 +2383,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_messageport_shipped(&mut self, port_id: MessagePortId) { if let Some(info) = self.message_ports.get_mut(&port_id) { match info.state { @@ -2386,7 +2441,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_remove_messageport(&mut self, port_id: MessagePortId) { let entangled = match self.message_ports.remove(&port_id) { Some(info) => info.entangled_with, @@ -2434,7 +2492,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_entangle_messageports(&mut self, port1: MessagePortId, port2: MessagePortId) { if let Some(info) = self.message_ports.get_mut(&port1) { info.entangled_with = Some(port2); @@ -2460,7 +2521,10 @@ where /// /// The Job Queue is essentially the channel to a SW manager, /// which are scoped per origin. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_schedule_serviceworker_job(&mut self, pipeline_id: PipelineId, job: Job) { let origin = job.scope_url.origin(); @@ -2500,7 +2564,10 @@ where let _ = sw_manager.send(ServiceWorkerMsg::ScheduleJob(job)); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_broadcast_storage_event( &self, pipeline_id: PipelineId, @@ -2531,7 +2598,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_exit(&mut self) { debug!("Handling exit."); @@ -2612,7 +2682,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_shutdown(&mut self) { debug!("Handling shutdown."); @@ -2737,7 +2810,10 @@ where self.pipelines.remove(&pipeline_id); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_send_error(&mut self, pipeline_id: PipelineId, err: IpcError) { // Treat send error the same as receiving a panic message error!("{}: Send error ({})", pipeline_id, err); @@ -2749,7 +2825,10 @@ where self.handle_panic(top_level_browsing_context_id, reason, None); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_panic( &mut self, top_level_browsing_context_id: Option<TopLevelBrowsingContextId>, @@ -2847,7 +2926,10 @@ where }); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_log_entry( &mut self, top_level_browsing_context_id: Option<TopLevelBrowsingContextId>, @@ -2927,7 +3009,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_new_top_level_browsing_context( &mut self, url: ServoUrl, @@ -2994,7 +3079,10 @@ where }); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_close_top_level_browsing_context( &mut self, top_level_browsing_context_id: TopLevelBrowsingContextId, @@ -3041,7 +3129,10 @@ where debug!("{top_level_browsing_context_id}: Closed"); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_iframe_size_msg(&mut self, iframe_sizes: Vec<IFrameSizeMsg>) { for IFrameSizeMsg { browsing_context_id, @@ -3058,7 +3149,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_subframe_loaded(&mut self, pipeline_id: PipelineId) { let browsing_context_id = match self.pipelines.get(&pipeline_id) { Some(pipeline) => pipeline.browsing_context_id, @@ -3099,7 +3193,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_navigate_request( &self, id: PipelineId, @@ -3120,7 +3217,10 @@ where // iframe via script. This will result in a new pipeline being spawned and // a child being added to the parent browsing context. This message is never // the result of a page navigation. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_script_loaded_url_in_iframe_msg(&mut self, load_info: IFrameLoadInfoWithData) { let IFrameLoadInfo { parent_pipeline_id, @@ -3227,7 +3327,10 @@ where }); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_script_new_iframe(&mut self, load_info: IFrameLoadInfoWithData) { let IFrameLoadInfo { parent_pipeline_id, @@ -3288,7 +3391,10 @@ where }); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_script_new_auxiliary(&mut self, load_info: AuxiliaryBrowsingContextLoadInfo) { let AuxiliaryBrowsingContextLoadInfo { load_data, @@ -3374,19 +3480,28 @@ where }); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_pending_paint_metric(&self, pipeline_id: PipelineId, epoch: Epoch) { self.compositor_proxy .send(CompositorMsg::PendingPaintMetric(pipeline_id, epoch)) } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_set_cursor_msg(&mut self, cursor: Cursor) { self.embedder_proxy .send((None, EmbedderMsg::SetCursor(cursor))) } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_change_running_animations_state( &mut self, pipeline_id: PipelineId, @@ -3404,7 +3519,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_tick_animation(&mut self, pipeline_id: PipelineId, tick_type: AnimationTickType) { let pipeline = match self.pipelines.get(&pipeline_id) { Some(pipeline) => pipeline, @@ -3420,7 +3538,10 @@ where /// Schedule a navigation(via load_url). /// 1: Ask the embedder for permission. /// 2: Store the details of the navigation, pending approval from the embedder. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn schedule_navigation( &mut self, top_level_browsing_context_id: TopLevelBrowsingContextId, @@ -3447,7 +3568,10 @@ where self.embedder_proxy.send(msg); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn load_url( &mut self, top_level_browsing_context_id: TopLevelBrowsingContextId, @@ -3576,7 +3700,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_abort_load_url_msg(&mut self, new_pipeline_id: PipelineId) { let pending_index = self .pending_changes @@ -3594,7 +3721,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_load_complete_msg( &mut self, top_level_browsing_context_id: TopLevelBrowsingContextId, @@ -3643,7 +3773,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_navigated_to_fragment( &mut self, pipeline_id: PipelineId, @@ -3675,7 +3808,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_traverse_history_msg( &mut self, top_level_browsing_context_id: TopLevelBrowsingContextId, @@ -3817,7 +3953,10 @@ where self.update_webview_in_compositor(top_level_browsing_context_id); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn update_browsing_context( &mut self, browsing_context_id: BrowsingContextId, @@ -3942,7 +4081,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn update_pipeline( &mut self, pipeline_id: PipelineId, @@ -3969,7 +4111,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_joint_session_history_length( &self, top_level_browsing_context_id: TopLevelBrowsingContextId, @@ -3983,7 +4128,10 @@ where let _ = response_sender.send(length as u32); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_push_history_state_msg( &mut self, pipeline_id: PipelineId, @@ -4023,7 +4171,10 @@ where self.notify_history_changed(top_level_browsing_context_id); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_replace_history_state_msg( &mut self, pipeline_id: PipelineId, @@ -4048,7 +4199,10 @@ where session_history.replace_history_state(pipeline_id, history_state_id, url); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_ime_dismissed(&mut self) { // Send to the focused browsing contexts' current pipeline. let focused_browsing_context_id = self @@ -4079,7 +4233,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_key_msg(&mut self, event: KeyboardEvent) { // Send to the focused browsing contexts' current pipeline. If it // doesn't exist, fall back to sending to the compositor. @@ -4118,7 +4275,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_reload_msg(&mut self, top_level_browsing_context_id: TopLevelBrowsingContextId) { let browsing_context_id = BrowsingContextId::from(top_level_browsing_context_id); let pipeline_id = match self.browsing_contexts.get(&browsing_context_id) { @@ -4137,7 +4297,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_post_message_msg( &mut self, browsing_context_id: BrowsingContextId, @@ -4176,7 +4339,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_get_pipeline( &mut self, browsing_context_id: BrowsingContextId, @@ -4198,7 +4364,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_get_browsing_context( &mut self, pipeline_id: PipelineId, @@ -4213,7 +4382,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_focus_msg(&mut self, pipeline_id: PipelineId) { let (browsing_context_id, top_level_browsing_context_id) = match self.pipelines.get(&pipeline_id) { @@ -4248,7 +4420,10 @@ where self.focus_parent_pipeline(browsing_context_id); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn focus_parent_pipeline(&mut self, browsing_context_id: BrowsingContextId) { let parent_pipeline_id = match self.browsing_contexts.get(&browsing_context_id) { Some(ctx) => ctx.parent_pipeline_id, @@ -4279,7 +4454,10 @@ where self.focus_parent_pipeline(parent_browsing_context_id); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_remove_iframe_msg( &mut self, browsing_context_id: BrowsingContextId, @@ -4292,7 +4470,10 @@ where result } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_set_throttled_complete(&mut self, pipeline_id: PipelineId, throttled: bool) { let browsing_context_id = match self.pipelines.get(&pipeline_id) { Some(pipeline) => pipeline.browsing_context_id, @@ -4327,7 +4508,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_create_canvas_paint_thread_msg( &mut self, size: UntypedSize2D<u64>, @@ -4351,7 +4535,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_webdriver_msg(&mut self, msg: WebDriverCommandMsg) { // Find the script channel for the given parent pipeline, // and pass the event to that script thread. @@ -4482,7 +4669,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn set_webview_throttled(&mut self, webview_id: WebViewId, throttled: bool) { let browsing_context_id = BrowsingContextId::from(webview_id); let pipeline_id = match self.browsing_contexts.get(&browsing_context_id) { @@ -4497,7 +4687,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn notify_history_changed(&self, top_level_browsing_context_id: TopLevelBrowsingContextId) { // Send a flat projection of the history to embedder. // The final vector is a concatenation of the LoadData of the past @@ -4614,7 +4807,10 @@ where self.embedder_proxy.send(msg); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn load_url_for_webdriver( &mut self, top_level_browsing_context_id: TopLevelBrowsingContextId, @@ -4642,7 +4838,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn change_session_history(&mut self, change: SessionHistoryChange) { debug!( "{}: Setting to {}", @@ -4797,7 +4996,10 @@ where self.update_webview_in_compositor(change.top_level_browsing_context_id); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn focused_browsing_context_is_descendant_of( &self, browsing_context_id: BrowsingContextId, @@ -4813,7 +5015,10 @@ where }) } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn trim_history(&mut self, top_level_browsing_context_id: TopLevelBrowsingContextId) { let pipelines_to_evict = { let session_history = self.get_joint_session_history(top_level_browsing_context_id); @@ -4873,7 +5078,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_activate_document_msg(&mut self, pipeline_id: PipelineId) { debug!("{}: Document ready to activate", pipeline_id); @@ -4919,7 +5127,10 @@ where } /// Called when the window is resized. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_window_size_msg( &mut self, top_level_browsing_context_id: TopLevelBrowsingContextId, @@ -4942,7 +5153,10 @@ where } /// Called when the window exits from fullscreen mode - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_exit_fullscreen_msg( &mut self, top_level_browsing_context_id: TopLevelBrowsingContextId, @@ -4956,7 +5170,10 @@ where /// to check if the output image is "stable" and can be written as a screenshot /// for reftests. /// Since this function is only used in reftests, we do not harden it against panic. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_is_ready_to_save_image( &mut self, pipeline_states: HashMap<PipelineId, Epoch>, @@ -5040,7 +5257,10 @@ where } /// Get the current activity of a pipeline. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn get_activity(&self, pipeline_id: PipelineId) -> DocumentActivity { let mut ancestor_id = pipeline_id; loop { @@ -5067,7 +5287,10 @@ where } /// Set the current activity of a pipeline. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn set_activity(&self, pipeline_id: PipelineId, activity: DocumentActivity) { debug!("{}: Setting activity to {:?}", pipeline_id, activity); if let Some(pipeline) = self.pipelines.get(&pipeline_id) { @@ -5086,14 +5309,20 @@ where } /// Update the current activity of a pipeline. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn update_activity(&self, pipeline_id: PipelineId) { self.set_activity(pipeline_id, self.get_activity(pipeline_id)); } /// Handle updating the size of a browsing context. /// This notifies every pipeline in the context of the new size. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn resize_browsing_context( &mut self, new_size: WindowSizeData, @@ -5150,7 +5379,10 @@ where } // Handle switching from fullscreen mode - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn switch_fullscreen_mode(&mut self, browsing_context_id: BrowsingContextId) { if let Some(browsing_context) = self.browsing_contexts.get(&browsing_context_id) { let pipeline_id = browsing_context.pipeline_id; @@ -5170,7 +5402,10 @@ where } // Close and return the browsing context with the given id (and its children), if it exists. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn close_browsing_context( &mut self, browsing_context_id: BrowsingContextId, @@ -5210,7 +5445,10 @@ where } // Close the children of a browsing context - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn close_browsing_context_children( &mut self, browsing_context_id: BrowsingContextId, @@ -5241,7 +5479,10 @@ where } // Discard the pipeline for a given document, udpdate the joint session history. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_discard_document( &mut self, top_level_browsing_context_id: TopLevelBrowsingContextId, @@ -5273,7 +5514,10 @@ where } // Send a message to script requesting the document associated with this pipeline runs the 'unload' algorithm. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn unload_document(&self, pipeline_id: PipelineId) { if let Some(pipeline) = self.pipelines.get(&pipeline_id) { let msg = ConstellationControlMsg::UnloadDocument(pipeline_id); @@ -5282,7 +5526,10 @@ where } // Close all pipelines at and beneath a given browsing context - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn close_pipeline( &mut self, pipeline_id: PipelineId, @@ -5346,7 +5593,10 @@ where } // Randomly close a pipeline -if --random-pipeline-closure-probability is set - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn maybe_close_random_pipeline(&mut self) { match self.random_pipeline_closure { Some((ref mut rng, probability)) => { @@ -5384,7 +5634,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn get_joint_session_history( &mut self, top_level_id: TopLevelBrowsingContextId, @@ -5396,7 +5649,10 @@ where } // Convert a browsing context to a sendable form to pass to the compositor - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn browsing_context_to_sendable( &self, browsing_context_id: BrowsingContextId, @@ -5426,7 +5682,10 @@ where } /// Send the frame tree for the given webview to the compositor. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn update_webview_in_compositor(&mut self, webview_id: WebViewId) { // Note that this function can panic, due to ipc-channel creation failure. // avoiding this panic would require a mechanism for dealing @@ -5439,7 +5698,10 @@ where } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_media_session_action_msg(&mut self, action: MediaSessionActionType) { if let Some(media_session_pipeline_id) = self.active_media_session { let result = match self.pipelines.get(&media_session_pipeline_id) { @@ -5466,7 +5728,10 @@ where } /// Handle GamepadEvents from the embedder and forward them to the script thread - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_gamepad_msg(&mut self, event: GamepadEvent) { // Send to the focused browsing contexts' current pipeline. let focused_browsing_context_id = self diff --git a/components/fonts/Cargo.toml b/components/fonts/Cargo.toml index 67059aef093..fa84e432e17 100644 --- a/components/fonts/Cargo.toml +++ b/components/fonts/Cargo.toml @@ -13,6 +13,9 @@ path = "lib.rs" test = true doctest = false +[features] +tracing = ["dep:tracing"] + [dependencies] app_units = { workspace = true } atomic_refcell = { workspace = true } @@ -44,7 +47,7 @@ servo_url = { path = "../url" } smallvec = { workspace = true, features = ["union"] } surfman = { workspace = true } style = { workspace = true } -tracing = { workspace = true } +tracing = { workspace = true, optional = true } unicode-bidi = { workspace = true, features = ["with_serde"] } unicode-properties = { workspace = true } unicode-script = { workspace = true } diff --git a/components/fonts/font_context.rs b/components/fonts/font_context.rs index b5732d258d2..0c4a5c419b5 100644 --- a/components/fonts/font_context.rs +++ b/components/fonts/font_context.rs @@ -28,7 +28,6 @@ use style::shared_lock::SharedRwLockReadGuard; use style::stylesheets::{CssRule, DocumentStyleSheet, FontFaceRule, StylesheetInDocument}; use style::values::computed::font::{FamilyName, FontFamilyNameSyntax, SingleFontFamily}; use style::Atom; -use tracing::instrument; use url::Url; use webrender_api::{FontInstanceFlags, FontInstanceKey, FontKey}; use webrender_traits::CrossProcessCompositorApi; @@ -279,7 +278,10 @@ impl FontContext { /// Create a `Font` for use in layout calculations, from a `FontTemplateData` returned by the /// cache thread and a `FontDescriptor` which contains the styling parameters. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn create_font( &self, font_template: FontTemplateRef, diff --git a/components/fonts/system_font_service.rs b/components/fonts/system_font_service.rs index c82aa2f2cb4..69b03c6eecc 100644 --- a/components/fonts/system_font_service.rs +++ b/components/fonts/system_font_service.rs @@ -24,7 +24,6 @@ use style::values::computed::font::{ }; use style::values::computed::{FontStretch, FontWeight}; use style::values::specified::FontStretch as SpecifiedFontStretch; -use tracing::{instrument, span, Level}; use webrender_api::{FontInstanceFlags, FontInstanceKey, FontKey}; use webrender_traits::CrossProcessCompositorApi; @@ -146,16 +145,21 @@ impl SystemFontService { SystemFontServiceProxySender(sender) } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn run(&mut self) { loop { let msg = self.port.recv().unwrap(); - let span = span!( - Level::TRACE, + #[cfg(feature = "tracing")] + let span = tracing::span!( + tracing::Level::TRACE, "SystemFontServiceMessage", servo_profiling = true ); + #[cfg(feature = "tracing")] let _enter = span.enter(); match msg { SystemFontServiceMessage::GetFontTemplates( @@ -186,7 +190,10 @@ impl SystemFontService { } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn fetch_new_keys(&mut self) { if !self.free_font_keys.is_empty() && !self.free_font_instance_keys.is_empty() { return; @@ -203,7 +210,10 @@ impl SystemFontService { .append(&mut new_font_instance_keys); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn get_font_templates( &mut self, font_descriptor: Option<FontDescriptor>, @@ -216,7 +226,10 @@ impl SystemFontService { .collect() } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn refresh_local_families(&mut self) { self.local_families.clear(); for_each_available_family(|family_name| { @@ -227,7 +240,10 @@ impl SystemFontService { }); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn find_font_templates( &mut self, descriptor_to_match: Option<&FontDescriptor>, @@ -251,7 +267,10 @@ impl SystemFontService { .unwrap_or_default() } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn get_font_instance( &mut self, identifier: FontIdentifier, diff --git a/components/layout_2020/Cargo.toml b/components/layout_2020/Cargo.toml index b6a4e2ba5b8..bcd04e67f86 100644 --- a/components/layout_2020/Cargo.toml +++ b/components/layout_2020/Cargo.toml @@ -13,6 +13,9 @@ path = "lib.rs" test = true doctest = false +[features] +tracing = ["dep:tracing"] + [dependencies] app_units = { workspace = true } atomic_refcell = { workspace = true } @@ -45,8 +48,8 @@ servo_config = { path = "../config" } servo_geometry = { path = "../geometry" } servo_url = { path = "../url" } style = { workspace = true } -tracing = { workspace = true } style_traits = { workspace = true } +tracing = { workspace = true, optional = true } unicode-bidi = { workspace = true } unicode-script = { workspace = true } url = { workspace = true } diff --git a/components/layout_2020/flexbox/layout.rs b/components/layout_2020/flexbox/layout.rs index 4338e6e93e1..db5517eb552 100644 --- a/components/layout_2020/flexbox/layout.rs +++ b/components/layout_2020/flexbox/layout.rs @@ -19,7 +19,6 @@ use style::values::generics::flex::GenericFlexBasis as FlexBasis; use style::values::generics::length::{GenericLengthPercentageOrAuto, LengthPercentageOrNormal}; use style::values::specified::align::AlignFlags; use style::Zero; -use tracing::instrument; use super::geom::{FlexAxis, FlexRelativeRect, FlexRelativeSides, FlexRelativeVec2}; use super::{FlexContainer, FlexContainerConfig, FlexItemBox, FlexLevelBox}; @@ -340,10 +339,13 @@ struct FlexItemBoxInlineContentSizesInfo { } impl FlexContainer { - #[instrument( - name = "FlexContainer::inline_content_sizes", - skip_all, - fields(servo_profiling = true) + #[cfg_attr( + feature = "tracing", + tracing::instrument( + name = "FlexContainer::inline_content_sizes", + skip_all, + fields(servo_profiling = true) + ) )] pub fn inline_content_sizes( &mut self, @@ -551,10 +553,13 @@ impl FlexContainer { } /// <https://drafts.csswg.org/css-flexbox/#layout-algorithm> - #[instrument( - name = "FlexContainer::layout", - skip_all, - fields(servo_profiling = true) + #[cfg_attr( + feature = "tracing", + tracing::instrument( + name = "FlexContainer::layout", + skip_all, + fields(servo_profiling = true) + ) )] pub(crate) fn layout( &self, @@ -2490,10 +2495,13 @@ impl FlexItemBox { } #[allow(clippy::too_many_arguments)] - #[instrument( - name = "FlexContainer::layout_for_block_content_size", - skip_all, - fields(servo_profiling = true) + #[cfg_attr( + feature = "tracing", + tracing::instrument( + name = "FlexContainer::layout_for_block_content_size", + skip_all, + fields(servo_profiling = true) + ) )] fn layout_for_block_content_size( &mut self, diff --git a/components/layout_2020/table/layout.rs b/components/layout_2020/table/layout.rs index 5ce34111ef7..455e0e3d25d 100644 --- a/components/layout_2020/table/layout.rs +++ b/components/layout_2020/table/layout.rs @@ -24,7 +24,6 @@ use style::values::computed::{ use style::values::generics::box_::{GenericVerticalAlign as VerticalAlign, VerticalAlignKeyword}; use style::values::generics::length::GenericLengthPercentageOrAuto::{Auto, LengthPercentage}; use style::Zero; -use tracing::instrument; use super::{Table, TableCaption, TableSlot, TableSlotCell, TableTrack, TableTrackGroup}; use crate::context::LayoutContext; @@ -1634,7 +1633,10 @@ impl<'a> TableLayout<'a> { /// Lay out the table (grid and captions) of this [`TableLayout`] into fragments. This should /// only be be called after calling [`TableLayout.compute_measures`]. - #[instrument(name = "Table::layout", skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(name = "Table::layout", skip_all, fields(servo_profiling = true)) + )] fn layout( mut self, layout_context: &LayoutContext, @@ -2606,10 +2608,13 @@ impl Table { } } - #[instrument( - name = "Table::inline_content_sizes", - skip_all, - fields(servo_profiling = true) + #[cfg_attr( + feature = "tracing", + tracing::instrument( + name = "Table::inline_content_sizes", + skip_all, + fields(servo_profiling = true) + ) )] pub(crate) fn inline_content_sizes( &mut self, diff --git a/components/layout_thread_2020/Cargo.toml b/components/layout_thread_2020/Cargo.toml index 7bf799b3e48..0d9bdc560a4 100644 --- a/components/layout_thread_2020/Cargo.toml +++ b/components/layout_thread_2020/Cargo.toml @@ -11,6 +11,9 @@ rust-version.workspace = true name = "layout_thread_2020" path = "lib.rs" +[features] +tracing = ["dep:tracing", "layout/tracing"] + [dependencies] app_units = { workspace = true } base = { workspace = true } @@ -38,7 +41,7 @@ servo_config = { path = "../config" } servo_url = { path = "../url" } style = { workspace = true } style_traits = { workspace = true } -tracing = { workspace = true } +tracing = { workspace = true, optional = true } url = { workspace = true } webrender_api = { workspace = true } webrender_traits = { workspace = true } diff --git a/components/layout_thread_2020/lib.rs b/components/layout_thread_2020/lib.rs index 2a730f7deeb..f61dd4d2e76 100644 --- a/components/layout_thread_2020/lib.rs +++ b/components/layout_thread_2020/lib.rs @@ -88,7 +88,6 @@ use style::values::computed::{CSSPixelLength, FontSize, Length, NonNegativeLengt use style::values::specified::font::KeywordInfo; use style::{driver, Zero}; use style_traits::{CSSPixel, DevicePixel, SpeculativePainter}; -use tracing::{instrument, span, Level}; use url::Url; use webrender_api::units::LayoutPixel; use webrender_api::{units, ExternalScrollId, HitTestFlags}; @@ -254,7 +253,10 @@ impl Layout for LayoutThread { ); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn add_stylesheet( &mut self, stylesheet: ServoArc<Stylesheet>, @@ -274,7 +276,10 @@ impl Layout for LayoutThread { } } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn remove_stylesheet(&mut self, stylesheet: ServoArc<Stylesheet>) { let guard = stylesheet.shared_lock.read(); let stylesheet = DocumentStyleSheet(stylesheet.clone()); @@ -283,22 +288,34 @@ impl Layout for LayoutThread { .remove_all_web_fonts_from_stylesheet(&stylesheet); } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn query_content_box(&self, node: OpaqueNode) -> Option<UntypedRect<Au>> { process_content_box_request(node, self.fragment_tree.borrow().clone()) } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn query_content_boxes(&self, node: OpaqueNode) -> Vec<UntypedRect<Au>> { process_content_boxes_request(node, self.fragment_tree.borrow().clone()) } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn query_client_rect(&self, node: OpaqueNode) -> UntypedRect<i32> { process_node_geometry_request(node, self.fragment_tree.borrow().clone()) } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn query_element_inner_outer_text( &self, node: script_layout_interface::TrustedNodeAddress, @@ -316,7 +333,10 @@ impl Layout for LayoutThread { None } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn query_nodes_from_point( &self, point: UntypedPoint2D<f32>, @@ -339,12 +359,18 @@ impl Layout for LayoutThread { results.iter().map(|result| result.node.into()).collect() } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn query_offset_parent(&self, node: OpaqueNode) -> OffsetParentResponse { process_offset_parent_query(node, self.fragment_tree.borrow().clone()) } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn query_resolved_style( &self, node: TrustedNodeAddress, @@ -380,7 +406,10 @@ impl Layout for LayoutThread { ) } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn query_resolved_font_style( &self, node: TrustedNodeAddress, @@ -413,12 +442,18 @@ impl Layout for LayoutThread { ) } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn query_scrolling_area(&self, node: Option<OpaqueNode>) -> UntypedRect<i32> { process_node_scroll_area_request(node, self.fragment_tree.borrow().clone()) } - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn query_text_indext( &self, node: OpaqueNode, @@ -663,7 +698,10 @@ impl LayoutThread { } /// The high-level routine that performs layout. - #[instrument(skip_all, fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip_all, fields(servo_profiling = true)) + )] fn handle_reflow(&mut self, data: &mut ScriptReflowResult) { let document = unsafe { ServoLayoutNode::new(&data.document) }; let document = document.as_document().unwrap(); @@ -783,7 +821,13 @@ impl LayoutThread { }; if token.should_traverse() { - let span = span!(Level::TRACE, "driver::traverse_dom", servo_profiling = true); + #[cfg(feature = "tracing")] + let span = tracing::span!( + tracing::Level::TRACE, + "driver::traverse_dom", + servo_profiling = true + ); + #[cfg(feature = "tracing")] let _enter = span.enter(); let dirty_root: ServoLayoutNode = driver::traverse_dom(&traversal, token, rayon_pool).as_node(); diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index c8e2046411e..1def35ad40b 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -24,6 +24,7 @@ no-wgl = ["mozangle/egl", "mozangle/build_dlls", "surfman/sm-angle-default"] dynamic_freetype = ["webrender/dynamic_freetype"] profilemozjs = ["script/profilemozjs"] refcell_backtrace = ["script/refcell_backtrace"] +tracing = ["dep:tracing", "compositing/tracing", "constellation/tracing", "fonts/tracing", "layout_thread_2020/tracing"] webdriver = ["webdriver_server"] webgl_backtrace = [ "script/webgl_backtrace", @@ -76,12 +77,12 @@ sparkle = { workspace = true } style = { workspace = true } style_traits = { workspace = true } surfman = { workspace = true } +tracing = { workspace = true, optional = true } webdriver_server = { path = "../webdriver_server", optional = true } webgpu = { path = "../webgpu" } webrender = { workspace = true } webrender_api = { workspace = true } webrender_traits = { workspace = true } -tracing = { workspace = true } webxr = { git = "https://github.com/servo/webxr" } webxr-api = { git = "https://github.com/servo/webxr" } diff --git a/components/servo/lib.rs b/components/servo/lib.rs index 50855598af1..0ea81be7274 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -224,7 +224,10 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static + ?Sized, { - #[tracing::instrument(skip(embedder, window), fields(servo_profiling = true))] + #[cfg_attr( + feature = "tracing", + tracing::instrument(skip(embedder, window), fields(servo_profiling = true)) + )] pub fn new( mut embedder: Box<dyn EmbedderMethods>, window: Rc<Window>, diff --git a/ports/servoshell/Cargo.toml b/ports/servoshell/Cargo.toml index 8f2d59c169b..70186e786e1 100644 --- a/ports/servoshell/Cargo.toml +++ b/ports/servoshell/Cargo.toml @@ -49,7 +49,7 @@ multiview = ["libservo/multiview"] native-bluetooth = ["libservo/native-bluetooth"] profilemozjs = ["libservo/profilemozjs"] refcell_backtrace = ["libservo/refcell_backtrace"] -tracing = ["dep:tracing", "dep:tracing-subscriber"] +tracing = ["dep:tracing", "dep:tracing-subscriber", "libservo/tracing"] tracing-hitrace = ["tracing", "dep:hitrace"] tracing-perfetto = ["tracing", "dep:tracing-perfetto"] webdriver = ["libservo/webdriver"] |