script: Make timers per-process (#34581)

Before all timers were managed by the Constellation process, meaning
that they had to trigger IPC calls to be scheduled and fired. Currently,
timers are only used in the `ScriptThread`, so it makes sense that they
are per-process.

This change restores the timer thread functionality that existed before
avoided entirely. Completion is done using a callback that is sent to
the timer thread similarly to how fetch is done. This allows reusing the
existing task queue without making any new channels.

Fixes #15219.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2024-12-24 10:53:35 +01:00 committed by GitHub
parent ff7626bfc6
commit 226299380d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 366 additions and 324 deletions

View file

@ -15,7 +15,7 @@ use js::rust::Runtime;
use net_traits::image_cache::ImageCache;
use net_traits::ResourceThreads;
use profile_traits::{mem, time};
use script_traits::{Painter, ScriptMsg, ScriptToConstellationChan, TimerSchedulerMsg};
use script_traits::{Painter, ScriptMsg, ScriptToConstellationChan};
use servo_atoms::Atom;
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
@ -93,7 +93,6 @@ impl WorkletGlobalScope {
init.mem_profiler_chan.clone(),
init.time_profiler_chan.clone(),
script_to_constellation_chan,
init.scheduler_chan.clone(),
init.resource_threads.clone(),
MutableOrigin::new(ImmutableOrigin::new_opaque()),
None,
@ -186,8 +185,6 @@ pub struct WorkletGlobalScopeInit {
pub devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
/// Messages to send to constellation
pub to_constellation_sender: IpcSender<(PipelineId, ScriptMsg)>,
/// Message to send to the scheduler
pub scheduler_chan: IpcSender<TimerSchedulerMsg>,
/// The image cache
pub image_cache: Arc<dyn ImageCache>,
/// True if in headless mode