script: Use ScriptEventLoopSender for Runtime event loop callbacks (#40590)

Instead of using a task source for SpiderMonkey runtime callbacks, use a
`ScriptEventLoopSender`. Task sources are associated with a particular
Pipeline, but the runtime callback is run indepenently of any particular
Pipeline and could theoretically happen when no Pipeline exists at all.
This reduces the dependency of the `ScriptThread` on the existence of
the first Pipeline.

Testing: This should not change observable behavior, so is covered by
existing tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson
2025-11-12 19:16:59 +01:00
committed by GitHub
parent 5ba40ece66
commit 0a1061d8d7
3 changed files with 27 additions and 32 deletions

View File

@@ -154,7 +154,6 @@ use crate::script_runtime::{
};
use crate::script_window_proxies::ScriptWindowProxies;
use crate::task_queue::TaskQueue;
use crate::task_source::{SendableTaskSource, TaskSourceName};
use crate::webdriver_handlers::jsval_to_webdriver;
use crate::{devtools, webdriver_handlers};
@@ -844,14 +843,9 @@ impl ScriptThread {
pipeline_id: PipelineId,
) -> ScriptThread {
let (self_sender, self_receiver) = unbounded();
let mut runtime = Runtime::new(Some(SendableTaskSource {
sender: ScriptEventLoopSender::MainThread(self_sender.clone()),
// TODO: We shouldn't rely on this Pipeline as a ScriptThread can have multiple
// Pipelines and any of them might disappear at any time.
pipeline_id,
name: TaskSourceName::Networking,
canceller: Default::default(),
}));
let mut runtime =
Runtime::new(Some(ScriptEventLoopSender::MainThread(self_sender.clone())));
let cx = runtime.cx();
unsafe {