Gate all use of tracing behind Cargo feature (#33845)

Signed-off-by: Delan Azabani <dazabani@igalia.com>
This commit is contained in:
Delan Azabani 2024-10-16 18:24:24 +08:00 committed by GitHub
parent 103d3aa7bb
commit fa1f7e5839
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 534 additions and 156 deletions

View file

@ -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 }

View file

@ -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;