servo/components/script
Martin Robinson 312cf0df08
script: Create a CrossProcessInstant to enable serializable monotonic time (#33282)
Up until now, Servo was using a very old version of time to get a
cross-process monotonic timestamp (using `time::precise_time_ns()`).
This change replaces the usage of old time with a new serializable
monotonic time called `CrossProcessInstant` and uses it where `u64`
timestamps were stored before. The standard library doesn't provide this
functionality because it isn't something you can do reliably on all
platforms. The idea is that we do our best and then fall back
gracefully.

This is a big change, because Servo was using `u64` timestamps all over
the place some as raw values taken from `time::precise_time_ns()` and
some as relative offsets from the "navigation start," which is a concept
similar to DOM's `timeOrigin` (but not exactly the same). It's very
difficult to fix this situation without fixing it everywhere as the
`Instant` concept is supposed to be opaque. The good thing is that this
change clears up all ambiguity when passing times as a `time::Duration`
is unit agnostic and a `CrossProcessInstant` represents an absolute
moment in time.

The `time` version of `Duration` is used because it can both be negative
and is also serializable.

Good things:
 - No need too pass around `time` and `time_precise` any longer.
   `CrossProcessInstant` is also precise and monotonic.
 - The distinction between a time that is unset or at `0` (at some kind
   of timer epoch) is now gone.

There still a lot of work to do to clean up timing, but this is the
first step. In general, I've tried to preserve existing behavior, even
when not spec compliant, as much as possible. I plan to submit followup
PRs fixing some of the issues I've noticed.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-09-05 18:50:09 +00:00
..
docs Update branch name to main (#30877) 2023-12-16 09:32:20 +00:00
dom script: Create a CrossProcessInstant to enable serializable monotonic time (#33282) 2024-09-05 18:50:09 +00:00
layout_dom script: Update list of non-TS pseudo classes supported by Servo (#33165) 2024-08-24 08:43:54 +00:00
task_source Dedupliate syn (#33038) 2024-08-13 21:21:47 +00:00
animation_timeline.rs script: Start replacing time with std::time and chrono (#30639) 2024-01-16 12:23:18 +00:00
animations.rs remove usage of legacy numeric operations in script (#33095) 2024-08-16 21:30:13 +00:00
body.rs clippy: Fix let_and_return warnings (#31964) 2024-04-01 15:43:24 +00:00
build.rs Update python detection in codegen (#31873) 2024-03-26 10:14:06 +00:00
canvas_state.rs enhance: Implement CanvasRenderingContext2D.measureText (#32704) 2024-07-17 19:20:18 +00:00
Cargo.toml script: Create a CrossProcessInstant to enable serializable monotonic time (#33282) 2024-09-05 18:50:09 +00:00
clipboard_provider.rs
devtools.rs jsstring_to_str should accept a NonNull argument for the JS string (#33306) 2024-09-05 03:25:49 +00:00
document_loader.rs clippy: fixed some warnings in components/script (#31888) 2024-03-26 21:25:42 +00:00
fetch.rs Start marking functions that can transitively trigger a GC (#33144) 2024-08-22 11:42:36 +00:00
image_listener.rs Strict import formatting (grouping and granularity) (#30325) 2023-09-11 19:16:54 +00:00
init.rs Fixed some clippy warning by adding default implementations (#31989) 2024-04-04 09:33:30 +00:00
layout_image.rs clippy: Fix some warnings in the script crate (#31719) 2024-03-18 10:05:18 +00:00
lib.rs Use global exports from derives (#33169) 2024-08-25 13:58:09 +00:00
mem.rs Strict import formatting (grouping and granularity) (#30325) 2023-09-11 19:16:54 +00:00
microtask.rs Move non-gfx things out of gfx_traits and create a base crate (#32296) 2024-05-17 12:28:58 +00:00
network_listener.rs clippy: Fix redundant field names warnings (#31793) 2024-03-20 23:05:29 +00:00
realms.rs clippy: components/script/realms (#32859) 2024-07-26 10:15:02 +00:00
script_module.rs jsstring_to_str should accept a NonNull argument for the JS string (#33306) 2024-09-05 03:25:49 +00:00
script_runtime.rs Fix a memory leak in components/script/script_runtime.rs and add more leak suppressions (#33175) 2024-08-26 07:33:23 +00:00
script_thread.rs script: Create a CrossProcessInstant to enable serializable monotonic time (#33282) 2024-09-05 18:50:09 +00:00
security_manager.rs enhance: Add support for unsafe-eval and wasm-unsafe-eval (#32893) 2024-08-01 17:26:44 +00:00
serviceworker_manager.rs Move non-gfx things out of gfx_traits and create a base crate (#32296) 2024-05-17 12:28:58 +00:00
stylesheet_loader.rs Move non-gfx things out of gfx_traits and create a base crate (#32296) 2024-05-17 12:28:58 +00:00
stylesheet_set.rs
task.rs ensure clean shutdown of all threads running JS 2020-06-30 13:22:38 +08:00
task_manager.rs script: Start rework to better match the specification HTML event loop (#31505) 2024-05-13 09:23:03 +00:00
task_queue.rs Move non-gfx things out of gfx_traits and create a base crate (#32296) 2024-05-17 12:28:58 +00:00
test.rs Strict import formatting (grouping and granularity) (#30325) 2023-09-11 19:16:54 +00:00
textinput.rs remove usage of legacy numeric operations in script (#33095) 2024-08-16 21:30:13 +00:00
timers.rs script: Stop using time in DOM timers (#33262) 2024-08-30 15:20:44 +00:00
unpremultiplytable.rs
webdriver_handlers.rs Start marking functions that can transitively trigger a GC (#33144) 2024-08-22 11:42:36 +00:00
window_named_properties.rs Replace the lazy_static crate whth std::sync::LazyLock in components/script (#33004) 2024-08-12 07:30:35 +00:00