-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Description
Description:
- A-Frame Version: master 1899930
https://cdn.jsdelivr.net/gh/aframevr/aframe@3a633d512b90724d856040676e575b7e190110a8/dist/aframe-master.min.js - Platform / Device: iPad
- Reproducible Code Snippet or URL: https://aframe-is-mobile-vr.glitch.me
AFRAME.utils.device.isMobileVR() erroneously return true on iPad (probably also on iPhone) since the changes to support Apple Vision Pro in c590f85. It returned false on aframe 1.6.0
I'm not sure how to fix it on aframe side.
Currently in my solidjs project I'm using a headsetConnected variable/signal that I set like this:
const [headsetConnected, setHeadsetConnected] = createSignal(false);
const [supportsVRSession, setSupportsVRSession] = createSignal(false);
createEffect(() => {
const errorHandler = function (err: Error) {
console.error("WebXR session support error: " + err.message);
};
if (navigator.xr !== undefined && navigator.xr.isSessionSupported) {
// Current WebXR spec uses a boolean-returning isSessionSupported promise
navigator.xr
.isSessionSupported("immersive-vr")
.then(function (supported) {
setSupportsVRSession(supported);
})
.catch(errorHandler);
}
});
createEffect(() => {
// We don't use AFRAME.utils.device.checkHeadsetConnected() because it set supportsVRSession internally after
// the promise is resolved so the checkHeadsetConnected() call may be done before the promise is resolved.
setHeadsetConnected(supportsVRSession() && AFRAME.utils.device.isMobileVR());
});where I add an additional check to see if the browser supports a vr session.
I don't use AFRAME.utils.device.checkHeadsetConnected() or checkVRSupport() because those are not reliable if you call it too early, the navigator.xr.isSessionSupported promise may not have been resolved yet, I actually had that issue.
Maybe we should expose checkVRSupportAsync that return a promise? Just a thought.
Metadata
Metadata
Assignees
Labels
No labels