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

Always request new XR frames #24452

Merged
merged 2 commits into from Oct 17, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Unconditionally set up rAF loop on initialization

  • Loading branch information
Manishearth committed Oct 15, 2019
commit 5e098e3a2a1f73afd245b2dfb707ab81342274da
@@ -119,6 +119,7 @@ impl XRSession {
);
input_sources.set_initial_inputs(&ret);
ret.attach_event_handler();
ret.setup_raf_loop();
ret
}

@@ -131,6 +132,33 @@ impl XRSession {
self.ended.get()
}

fn setup_raf_loop(&self) {
assert!(
self.raf_sender.borrow().is_none(),
"RAF loop already set up"
);
let this = Trusted::new(self);
let global = self.global();
let window = global.as_window();
let (task_source, canceller) = window
.task_manager()
.dom_manipulation_task_source_with_canceller();
let (sender, receiver) = ipc::channel(global.time_profiler_chan().clone()).unwrap();
*self.raf_sender.borrow_mut() = Some(sender);
ROUTER.add_route(
receiver.to_opaque(),
Box::new(move |message| {
let this = this.clone();
let _ = task_source.queue_with_canceller(
task!(xr_raf_callback: move || {
this.root().raf_callback(message.to().unwrap());
}),
&canceller,
);
}),
);
}

fn attach_event_handler(&self) {
let this = Trusted::new(self);
let global = self.global();
@@ -378,29 +406,6 @@ impl XRSessionMethods for XRSession {
.borrow_mut()
.push((raf_id, Some(callback)));

// set up listener for response, if necessary
if self.raf_sender.borrow().is_none() {
let this = Trusted::new(self);
let global = self.global();
let window = global.as_window();
let (task_source, canceller) = window
.task_manager()
.dom_manipulation_task_source_with_canceller();
let (sender, receiver) = ipc::channel(global.time_profiler_chan().clone()).unwrap();
*self.raf_sender.borrow_mut() = Some(sender);
ROUTER.add_route(
receiver.to_opaque(),
Box::new(move |message| {
let this = this.clone();
let _ = task_source.queue_with_canceller(
task!(xr_raf_callback: move || {
this.root().raf_callback(message.to().unwrap());
}),
&canceller,
);
}),
);
}

if should_send {
// If our callback list is empty, it either means this is the first request,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.