diff options
author | Martin Robinson <mrobinson@igalia.com> | 2024-07-26 15:53:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-26 13:53:34 +0000 |
commit | f7448b5d6121339508a5cbc31e1da2db704da371 (patch) | |
tree | 06ba1edd7d134fbb9c2679f363fc4d0201e8a9b6 | |
parent | eac54183c154ca044f98e9d74aa51892f73c0085 (diff) | |
download | servo-f7448b5d6121339508a5cbc31e1da2db704da371.tar.gz servo-f7448b5d6121339508a5cbc31e1da2db704da371.zip |
Remove the WebXR dependency on ancient `time@0.1` crate (#32862)
`webxr` depends on a very old verison of `time`, which allowed serializing
monotonic clock output. This isn't possible on all platforms, so newer
versions of `time` do not allow this. In order to stop using the old
0.1 versions of `time` we have to stop relying on times passed from `webxr`
to Servo. This change does that, at the cost of removing the XR
profiling feature. It has to be rewritten in another way in the `webxr`
crate.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
-rw-r--r-- | Cargo.lock | 3 | ||||
-rw-r--r-- | components/canvas/Cargo.toml | 2 | ||||
-rw-r--r-- | components/canvas/webgl_thread.rs | 13 | ||||
-rw-r--r-- | components/script/Cargo.toml | 1 | ||||
-rw-r--r-- | components/script/dom/document.rs | 4 | ||||
-rw-r--r-- | components/script/dom/xrsession.rs | 32 | ||||
-rw-r--r-- | components/servo/Cargo.toml | 1 | ||||
-rw-r--r-- | components/shared/canvas/Cargo.toml | 2 | ||||
-rw-r--r-- | ports/servoshell/Cargo.toml | 1 |
9 files changed, 5 insertions, 54 deletions
diff --git a/Cargo.lock b/Cargo.lock index 3039e50844a..1f9b44f915c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -644,7 +644,6 @@ dependencies = [ "style", "style_traits", "surfman", - "time 0.1.45", "unicode-script", "webrender", "webrender_api", @@ -670,7 +669,6 @@ dependencies = [ "servo_config", "sparkle", "style", - "time 0.1.45", "webrender_api", "webxr-api", ] @@ -7382,7 +7380,6 @@ dependencies = [ "ipc-channel", "log", "serde", - "time 0.1.45", ] [[package]] diff --git a/components/canvas/Cargo.toml b/components/canvas/Cargo.toml index ff0b28af0cb..ea2f496f63f 100644 --- a/components/canvas/Cargo.toml +++ b/components/canvas/Cargo.toml @@ -12,7 +12,6 @@ path = "lib.rs" [features] webgl_backtrace = ["canvas_traits/webgl_backtrace"] -xr-profile = ["webxr-api/profile", "time"] [dependencies] app_units = { workspace = true } @@ -41,7 +40,6 @@ sparkle = { workspace = true } style = { workspace = true } style_traits = { workspace = true } surfman = { workspace = true } -time = { workspace = true, optional = true } unicode-script = { workspace = true } webrender = { workspace = true } webrender_api = { workspace = true } diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs index c6ecb4b6d90..f0dd3da3705 100644 --- a/components/canvas/webgl_thread.rs +++ b/components/canvas/webgl_thread.rs @@ -51,11 +51,6 @@ use webxr_api::{ use crate::webgl_limits::GLLimitsDetect; -#[cfg(feature = "xr-profile")] -fn to_ms(ns: u64) -> f64 { - ns as f64 / 1_000_000. -} - struct GLContextData { ctx: Context, gl: Rc<Gl>, @@ -831,14 +826,6 @@ impl WebGLThread { #[allow(unused)] let mut end_swap = 0; - #[cfg(feature = "xr-profile")] - { - end_swap = time::precise_time_ns(); - println!( - "WEBXR PROFILING [swap buffer]:\t{}ms", - to_ms(end_swap - start_swap) - ); - } completed_sender.send(end_swap).unwrap(); } diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 524fe423c45..7dc5bba9e07 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -18,7 +18,6 @@ profilemozjs = ['js/profilemozjs'] webgl_backtrace = ["canvas_traits/webgl_backtrace"] js_backtrace = [] refcell_backtrace = ["accountable-refcell"] -xr-profile = ["webxr-api/profile"] [build-dependencies] phf_codegen = "0.11" diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 64c4b2eed7f..920834039d4 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -2912,10 +2912,6 @@ impl Document { #[allow(unused)] let mut time = 0; - #[cfg(feature = "xr-profile")] - { - time = time::precise_time_ns(); - } let (sender, receiver) = webgl::webgl_channel().unwrap(); self.window .webgl_chan() diff --git a/components/script/dom/xrsession.rs b/components/script/dom/xrsession.rs index 054fee49c87..9be375d3e00 100644 --- a/components/script/dom/xrsession.rs +++ b/components/script/dom/xrsession.rs @@ -182,21 +182,12 @@ impl XRSession { ROUTER.add_route( frame_receiver.to_opaque(), Box::new(move |message| { - #[allow(unused)] - let mut frame: Frame = message.to().unwrap(); - #[cfg(feature = "xr-profile")] - { - let received = time::precise_time_ns(); - println!( - "WEBXR PROFILING [raf receive]:\t{}ms", - (received - frame.sent_time) as f64 / 1_000_000. - ); - frame.sent_time = received; - } + let frame: Frame = message.to().unwrap(); + let time = time::precise_time_ns(); let this = this.clone(); let _ = task_source.queue_with_canceller( task!(xr_raf_callback: move || { - this.root().raf_callback(frame); + this.root().raf_callback(frame, time); }), &canceller, ); @@ -363,15 +354,8 @@ impl XRSession { } /// <https://immersive-web.github.io/webxr/#xr-animation-frame> - fn raf_callback(&self, mut frame: Frame) { + fn raf_callback(&self, mut frame: Frame, time: u64) { debug!("WebXR RAF callback {:?}", frame); - #[cfg(feature = "xr-profile")] - let raf_start = time::precise_time_ns(); - #[cfg(feature = "xr-profile")] - println!( - "WEBXR PROFILING [raf queued]:\t{}ms", - (raf_start - frame.sent_time) as f64 / 1_000_000. - ); // Step 1-2 happen in the xebxr device thread @@ -421,7 +405,7 @@ impl XRSession { mem::swap(&mut *self.raf_callback_list.borrow_mut(), &mut current); } let start = self.global().as_window().get_navigation_start(); - let time = reduce_timing_resolution((frame.time_ns - start).to_ms()); + let time = reduce_timing_resolution((time - start).to_ms()); let frame = XRFrame::new(&self.global(), self, frame); // Step 8-9 @@ -454,12 +438,6 @@ impl XRSession { // TODO: how does this fit the webxr spec? self.session.borrow_mut().render_animation_frame(); - - #[cfg(feature = "xr-profile")] - println!( - "WEBXR PROFILING [raf execute]:\t{}ms", - (time::precise_time_ns() - raf_start) as f64 / 1_000_000. - ); } fn update_inline_projection_matrix(&self) { diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index 950eed9aae4..3107e8c74ba 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -30,7 +30,6 @@ webgl_backtrace = [ "canvas/webgl_backtrace", "canvas_traits/webgl_backtrace", ] -xr-profile = ["canvas/xr-profile", "canvas_traits/xr-profile", "script/xr-profile", "webxr/profile"] [dependencies] background_hang_monitor = { path = "../background_hang_monitor" } diff --git a/components/shared/canvas/Cargo.toml b/components/shared/canvas/Cargo.toml index 663e831d419..f62f48c73a7 100644 --- a/components/shared/canvas/Cargo.toml +++ b/components/shared/canvas/Cargo.toml @@ -12,7 +12,6 @@ path = "lib.rs" [features] webgl_backtrace = [] -xr-profile = ["webxr-api/profile", "time"] [dependencies] base = { workspace = true } @@ -28,6 +27,5 @@ serde_bytes = { workspace = true } servo_config = { path = "../../config" } sparkle = { workspace = true } style = { workspace = true } -time = { workspace = true, optional = true } webrender_api = { workspace = true } webxr-api = { git = "https://github.com/servo/webxr", features = ["ipc"] } diff --git a/ports/servoshell/Cargo.toml b/ports/servoshell/Cargo.toml index cac71664fac..2e7bf1fe8e2 100644 --- a/ports/servoshell/Cargo.toml +++ b/ports/servoshell/Cargo.toml @@ -50,7 +50,6 @@ profilemozjs = ["libservo/profilemozjs"] refcell_backtrace = ["libservo/refcell_backtrace"] webdriver = ["libservo/webdriver"] webgl_backtrace = ["libservo/webgl_backtrace"] -xr-profile = ["libservo/xr-profile"] [dependencies] libc = { workspace = true } |