Skip to content

Handle cancelAnimationFrame() when called within a requestAnimationFrame() callback #26251

Closed
@Manishearth

Description

@Manishearth

Spec change: immersive-web/webxr#1005 (comment)

Relevant code:

let mut callbacks = mem::replace(&mut *self.raf_callback_list.borrow_mut(), vec![]);
let start = self.global().as_window().get_navigation_start();
let time = reduce_timing_resolution((frame.time_ns - start).to_ms());
let frame = XRFrame::new(&self.global(), self, frame);
// Step 6,7
frame.set_active(true);
frame.set_animation_frame(true);
// Step 8
self.outside_raf.set(false);
for (_, callback) in callbacks.drain(..) {
if let Some(callback) = callback {
let _ = callback.Call__(time, &frame, ExceptionHandling::Report);
}
}
self.outside_raf.set(true);

Currently we take self.raf_callback_list out and put it on the stack, and then iterate through it.

Instead, we should have a second current_raf_callback_list list on the object, move the vector there, and use indexed iteration. Then, in CancelAnimationFrame, we check both lists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-xr-spec-completeThings necessary to support the full WebXR specA-xr-zomgAR/VR/MRC-assignedThere is someone working on resolving the issueE-less-complexStraightforward. Recommended for a new contributor.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions