script: Unsilence all main thread TaskQueue errors (#34849)

No longer hide errors while queueing tasks on the main thread. This
requires creating two types of `TaskSource`s: one for the main thread
and one that can be sent to other threads. This makes queueing a bit
more efficient on the main thread and more importantly, no longer hides
task queue errors.

Fixes #25688.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This commit is contained in:
Martin Robinson 2025-01-07 04:36:39 +01:00 committed by GitHub
parent d252a631d2
commit fe8a22b72c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
48 changed files with 628 additions and 571 deletions

View file

@ -201,14 +201,17 @@ impl XRSession {
fn setup_raf_loop(&self, frame_receiver: IpcReceiver<Frame>) {
let this = Trusted::new(self);
let global = self.global();
let task_source = global.task_manager().dom_manipulation_task_source();
let task_source = global
.task_manager()
.dom_manipulation_task_source()
.to_sendable();
ROUTER.add_typed_route(
frame_receiver,
Box::new(move |message| {
let frame: Frame = message.unwrap();
let time = CrossProcessInstant::now();
let this = this.clone();
let _ = task_source.queue(task!(xr_raf_callback: move || {
task_source.queue(task!(xr_raf_callback: move || {
this.root().raf_callback(frame, time);
}));
}),
@ -224,14 +227,17 @@ impl XRSession {
fn attach_event_handler(&self) {
let this = Trusted::new(self);
let global = self.global();
let task_source = global.task_manager().dom_manipulation_task_source();
let task_source = global
.task_manager()
.dom_manipulation_task_source()
.to_sendable();
let (sender, receiver) = ipc::channel(global.time_profiler_chan().clone()).unwrap();
ROUTER.add_typed_route(
receiver.to_ipc_receiver(),
Box::new(move |message| {
let this = this.clone();
let _ = task_source.queue(task!(xr_event_callback: move || {
task_source.queue(task!(xr_event_callback: move || {
this.root().event_callback(message.unwrap(), CanGc::note());
}));
}),
@ -254,14 +260,16 @@ impl XRSession {
return;
}
let task_source = self.global().task_manager().dom_manipulation_task_source();
let this = Trusted::new(self);
// Queue a task so that it runs after resolve()'s microtasks complete
// so that content has a chance to attach a listener for inputsourceschange
let _ = task_source.queue(task!(session_initial_inputs: move || {
let this = this.root();
this.input_sources.add_input_sources(&this, &initial_inputs, CanGc::note());
}));
self.global()
.task_manager()
.dom_manipulation_task_source()
.queue(task!(session_initial_inputs: move || {
let this = this.root();
this.input_sources.add_input_sources(&this, &initial_inputs, CanGc::note());
}));
}
fn event_callback(&self, event: XREvent, can_gc: CanGc) {
@ -1036,14 +1044,17 @@ impl XRSessionMethods<crate::DomTypeHolder> for XRSession {
let this = Trusted::new(self);
let global = self.global();
let task_source = global.task_manager().dom_manipulation_task_source();
let task_source = global
.task_manager()
.dom_manipulation_task_source()
.to_sendable();
let (sender, receiver) = ipc::channel(global.time_profiler_chan().clone()).unwrap();
ROUTER.add_typed_route(
receiver.to_ipc_receiver(),
Box::new(move |message| {
let this = this.clone();
let _ = task_source.queue(task!(update_session_framerate: move || {
task_source.queue(task!(update_session_framerate: move || {
let session = this.root();
session.apply_nominal_framerate(message.unwrap(), CanGc::note());
if let Some(promise) = session.update_framerate_promise.borrow_mut().take() {