Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle cancelAnimationFrame() when called within a requestAnimationFr… #26491

Merged
merged 1 commit into from May 13, 2020
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Handle cancelAnimationFrame() when called within a requestAnimationFr…

…ame() callback
  • Loading branch information
huangjiahua committed May 13, 2020
commit c253ad83990d2435af3e52d7ba9b9148c48cebcf
@@ -74,6 +74,8 @@ pub struct XRSession {
next_raf_id: Cell<i32>,
#[ignore_malloc_size_of = "closures are hard"]
raf_callback_list: DomRefCell<Vec<(i32, Option<Rc<XRFrameRequestCallback>>)>>,
#[ignore_malloc_size_of = "closures are hard"]
current_raf_callback_list: DomRefCell<Vec<(i32, Option<Rc<XRFrameRequestCallback>>)>>,
input_sources: Dom<XRInputSourceArray>,
// Any promises from calling end()
#[ignore_malloc_size_of = "promises are hard"]
@@ -110,6 +112,7 @@ impl XRSession {

next_raf_id: Cell::new(0),
raf_callback_list: DomRefCell::new(vec![]),
current_raf_callback_list: DomRefCell::new(vec![]),
input_sources: Dom::from_ref(input_sources),
end_promises: DomRefCell::new(vec![]),
ended: Cell::new(false),
@@ -395,7 +398,11 @@ impl XRSession {
// Step 3: XXXManishearth handle inline session

// Step 4-5
let mut callbacks = mem::replace(&mut *self.raf_callback_list.borrow_mut(), vec![]);
{
let mut current = self.current_raf_callback_list.borrow_mut();
assert!(current.is_empty());
mem::swap(&mut *self.raf_callback_list.borrow_mut(), &mut current);
}
let start = self.global().as_window().get_navigation_start();
let time = reduce_timing_resolution((frame.time_ns - start).to_ms());

@@ -406,12 +413,18 @@ impl XRSession {

// Step 8
self.outside_raf.set(false);
for (_, callback) in callbacks.drain(..) {
let len = self.current_raf_callback_list.borrow().len();
for i in 0..len {
let callback = self.current_raf_callback_list.borrow()[i]
.1
.as_ref()
.map(|callback| Rc::clone(callback));
if let Some(callback) = callback {
let _ = callback.Call__(time, &frame, ExceptionHandling::Report);
}
}
self.outside_raf.set(true);
*self.current_raf_callback_list.borrow_mut() = vec![];

frame.set_active(false);
if self.is_immersive() {
@@ -656,6 +669,11 @@ impl XRSessionMethods for XRSession {
if let Some(pair) = list.iter_mut().find(|pair| pair.0 == frame) {
pair.1 = None;
}

let mut list = self.current_raf_callback_list.borrow_mut();
if let Some(pair) = list.iter_mut().find(|pair| pair.0 == frame) {
pair.1 = None;
}
}

/// https://immersive-web.github.io/webxr/#dom-xrsession-environmentblendmode

This file was deleted.

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.