From 4f621f3950adb8af96f04644f3094fc6f9eebc76 Mon Sep 17 00:00:00 2001 From: Greg Fodor <gfodor@gmail.com> Date: Thu, 26 Jul 2018 23:14:14 +0000 Subject: [PATCH] Fix check for FxR and false positive for VR onboarding on Mac/Linux FF --- src/utils/vr-caps-detect.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/utils/vr-caps-detect.js b/src/utils/vr-caps-detect.js index 3cea1c2e3..5ebce0b33 100644 --- a/src/utils/vr-caps-detect.js +++ b/src/utils/vr-caps-detect.js @@ -50,8 +50,6 @@ export async function getAvailableVREntryTypes() { // This needs to be kept up-to-date with the latest browsers that can support VR and Hubs. // Checking for navigator.getVRDisplays always passes b/c of polyfill. const isWebVRCapableBrowser = window.hasNativeWebVRImplementation; - const isFirefoxReality = window.orientation === 0 && "buildID" in navigator && isWebVRCapableBrowser; - const isInHMD = isOculusBrowser || isFirefoxReality; const isDaydreamCapableBrowser = !!(isWebVRCapableBrowser && browser.name === "chrome" && !isSamsungBrowser); const isIDevice = AFRAME.utils.device.isIOS(); @@ -64,13 +62,28 @@ export async function getAvailableVREntryTypes() { : VR_DEVICE_AVAILABILITY.maybe : VR_DEVICE_AVAILABILITY.no; + let displays = []; + + if (isWebVRCapableBrowser) { + displays = await navigator.getVRDisplays(); + } + + const isFirefoxReality = window.orientation === 0 && "buildID" in navigator && displays.length > 0; + const isInHMD = isOculusBrowser || isFirefoxReality; + const screen = isInHMD ? VR_DEVICE_AVAILABILITY.no : isIDevice && isUIWebView ? VR_DEVICE_AVAILABILITY.maybe : VR_DEVICE_AVAILABILITY.yes; - let generic = AFRAME.utils.device.isMobile() ? VR_DEVICE_AVAILABILITY.no : VR_DEVICE_AVAILABILITY.maybe; + // HACK -- we prompt the user to install firefox if they click the VR button on a non-WebVR compatible + // browser. once we change this (ie when Chrome has VR support) then this check can be removed. Currently + // if you have FF on Mac/Linux you get the confusing flow of having a VR button but then being asked to + // download FF. + const isNonWebVRFirefox = !isWebVRCapableBrowser && isFirefoxBrowser; + let generic = + AFRAME.utils.device.isMobile() || isNonWebVRFirefox ? VR_DEVICE_AVAILABILITY.no : VR_DEVICE_AVAILABILITY.maybe; let cardboard = VR_DEVICE_AVAILABILITY.no; // We only consider GearVR support as "maybe" and never "yes". The only browser @@ -89,8 +102,6 @@ export async function getAvailableVREntryTypes() { isMaybeDaydreamCompatibleDevice(ua) && !isInHMD ? VR_DEVICE_AVAILABILITY.maybe : VR_DEVICE_AVAILABILITY.no; if (isWebVRCapableBrowser) { - const displays = await navigator.getVRDisplays(); - // Generic is supported for non-blacklisted devices and presentable HMDs. generic = displays.find( d => d.capabilities.canPresent && !GENERIC_ENTRY_TYPE_DEVICE_BLACKLIST.find(r => r.test(d.displayName)) -- GitLab