pmndrs / xr

🤳 VR/AR for react-three-fiber
https://pmndrs.github.io/xr/docs/
Other
2.12k stars 152 forks source link

createXRStore fails on WebXR Viewer for iOS #337

Open valado opened 3 weeks ago

valado commented 3 weeks ago

Description

With the previous version it used to work running WebXR on iOS using one of the XR-ready web browsers available, such as: WebXR Viewer XR Browser

Error

The new version of @react-three/xr throws the following error: ` Shim: We don't expect user adds event before stating session.

addEventListener@user-script:28:33:28 setupSessionGrantedListener vendors-node_modules_react-three_drei_core_Text_js-node_modules_react-three_fiber_dist_react--33db12.js:18208:35 createXRStore vendors-node_modules_react-three_drei_core_Text_js-node_modules_react-three_fiber_dist_react--33db12.js:17972:70 `

How to reproduce

  1. install one of the WebXR-ready browsers (links above)
  2. Run the AR example project
bbohlender commented 3 weeks ago

you can disable the feature that is causing the error enterGrantedSession: false

I assume these apps are rather outdated and thus are not aware of https://github.com/immersive-web/navigation and I cannot detect if they support this feature.

Since they might also not support other features, it might also be required to disable others, to have them work

cyango commented 3 weeks ago

Is there a way to know if the device supports any of the react xr store properties? like mesh detection and stuff

bbohlender commented 3 weeks ago

@cyango WebXR operates by allowing developers to request optional features. Therefore you can always request a feature and If its not available, it will not be enabled, which is basically checking for support.

valado commented 3 weeks ago

Thanks @bbohlender !

you can disable the feature that is causing the error enterGrantedSession: false

This solved the error I was getting.

Nevertheless, now I have an issue with <Interactive onSelect={...}>...</> and <group onClick={...}/>...</> (migrated to group after I saw that Interactive is deprecated). The onSelect/onClick are not getting called. This is again only reproducible on iOS using one of the two mentioned browsers supporting WebXR.

Is this a separate issue? Thanks in advance!

bbohlender commented 1 week ago

@valado sorry for the delay. I'd love to help you out on this but I dont own a iOS device and I also would not want to put effort into supporting unsupported browsers that are most likely not spec complaint. If you can identify a bug in this library I'll happily fix it asap, but I suspect the inability to click/interact with things is due to the outdated browser implementation not emitting the correct events. This is only a suspicion I unfortunately cannot test right now :)

valado commented 1 week ago

@bbohlender the fact that it works in Chrome on Android kind of points towards the browser. Nevertheless, it is weird that it used to work with the previous major version of the lib.

Do you have any pointers on how can I dig a bit deeper short of adding some console.log calls within the lib (inside node_modules) and figuring out how to get the console stream out of the WebXR Viewer?

bbohlender commented 1 week ago

this new major version uses more WebXR features that are in the spec but not supported (specifically, computing the difference between any two WebXR spaces). I assume the error is the same as for the old WebXR API Emulator, which will happen for the controller implementation, so it might start to work if you start to disable certain features, such as the controllers createXRStore({ controller:false }).