From 2c0c4fe19022e7abb79076d71c3bb332d36b22bc Mon Sep 17 00:00:00 2001
From: Robert Long <robert@robertlong.me>
Date: Mon, 7 May 2018 16:57:09 -0700
Subject: [PATCH] Added comment to explain Oculus Go hack and additional
 clearTimeout.

---
 src/systems/exit-on-blur.js | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/systems/exit-on-blur.js b/src/systems/exit-on-blur.js
index e0ab0f436..f3b3979aa 100644
--- a/src/systems/exit-on-blur.js
+++ b/src/systems/exit-on-blur.js
@@ -13,6 +13,10 @@ AFRAME.registerSystem("exit-on-blur", {
   },
 
   tick() {
+    // This is a hack to detect when an Oculus Go user has taken off the headset and the headset has
+    // entered standby mode. Currently Oculus Browser is not emitting a blur, vrdisplaydeactivate,
+    // vrdisplayblur, visibilitychange, or vrdisplaypresentchange event, so we wait 15 seconds after
+    // the last requestAnimationFrame callback to determine if the headset has gone into standby mode.
     if (this.isOculusBrowser) {
       clearTimeout(this.exitTimeout);
       this.exitTimeout = setTimeout(this.onTimeout, 15 * 1000);
@@ -21,6 +25,7 @@ AFRAME.registerSystem("exit-on-blur", {
 
   onBlur() {
     if (this.el.isMobile) {
+      clearTimeout(this.exitTimeout);
       this.exitTimeout = setTimeout(this.onTimeout, 30 * 1000);
     }
   },
-- 
GitLab