aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/vrdisplay.rs
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2019-01-15 16:18:02 -0800
committerManish Goregaokar <manishsmail@gmail.com>2019-03-25 09:12:30 -0700
commit0038ddf51ecd04887ab4ac00d2644874c68a3df0 (patch)
treeea765b694b90a5855c622b2f42a301f9ed249b80 /components/script/dom/vrdisplay.rs
parent9ea28c4c63694220d6ac1fd22629087e84caaa1a (diff)
downloadservo-0038ddf51ecd04887ab4ac00d2644874c68a3df0.tar.gz
servo-0038ddf51ecd04887ab4ac00d2644874c68a3df0.zip
Avoid double-spawning RAF thread
Diffstat (limited to 'components/script/dom/vrdisplay.rs')
-rw-r--r--components/script/dom/vrdisplay.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/components/script/dom/vrdisplay.rs b/components/script/dom/vrdisplay.rs
index 02aaeada707..789f0e5936e 100644
--- a/components/script/dom/vrdisplay.rs
+++ b/components/script/dom/vrdisplay.rs
@@ -61,6 +61,7 @@ pub struct VRDisplay {
depth_near: Cell<f64>,
depth_far: Cell<f64>,
presenting: Cell<bool>,
+ has_raf_thread: Cell<bool>,
left_eye_params: MutDom<VREyeParameters>,
right_eye_params: MutDom<VREyeParameters>,
capabilities: MutDom<VRDisplayCapabilities>,
@@ -130,6 +131,7 @@ impl VRDisplay {
depth_near: Cell::new(0.01),
depth_far: Cell::new(10000.0),
presenting: Cell::new(false),
+ has_raf_thread: Cell::new(false),
left_eye_params: MutDom::new(&*VREyeParameters::new(
display.left_eye_parameters.clone(),
&global,
@@ -652,6 +654,10 @@ impl VRDisplay {
let xr = self.global().as_window().Navigator().Xr();
xr.set_active_immersive_session(&self);
self.process_renderstate_queue();
+ if self.has_raf_thread.get() {
+ return;
+ }
+ self.has_raf_thread.set(true);
let (sync_sender, sync_receiver) = webgl_channel().unwrap();
*self.frame_data_receiver.borrow_mut() = Some(sync_receiver);
@@ -760,6 +766,7 @@ impl VRDisplay {
let xr = self.global().as_window().Navigator().Xr();
xr.deactivate_session();
*self.frame_data_receiver.borrow_mut() = None;
+ self.has_raf_thread.set(false);
if let Some(api_sender) = self.api_sender() {
let display_id = self.display.borrow().display_id;
api_sender