I am using Needle 4.4.3 and Oculus Quest 3 and am implementing a 3D UI which allows user to terminate an XR session. However currently I have an issue when I try to end the session using NeedleXRSession.stop() from the button callback I receive this error. Any Idea what I may be doing incorrectly?
Error in lifecycle method InvalidStateError: Failed to execute 'getViewerPose' on 'XRFrame': XRFrame access outside the callback that produced it is invalid.
at Dt.internalUpdateState (index.js:232:2991)
at Object.<anonymous> (index.js:231:21156)
at uC (index.js:151:919)
at nR (index.js:151:521)
at io (index.js:151:360)
at We.internalOnBeforeRender (index.js:852:2525)
at We.internalStep (index.js:852:287)
at We.update (index.js:851:4898)
at index.js:851:4756
at Qe (three.js:3847:8627)
Uncaught InvalidStateError: Failed to read the 'detectedPlanes' property from 'XRFrame': XRFrame access outside the callback that produced it is invalid.
at Qe (three.js:3847:8640)
at XRSession.i (three.js:44:4307)
If youāre using Unity you can use the bugreport menu item (Needle Engine/Reporta bug), in Blender thereās a bugreporter panel (both of which allow to automatically upload the bugreport to our backend, encrypted) and otherwise please upload to e.g. Drive or some other storage provider and DM or email a link
Iām currently looking at the projectās code. It seems like youāre using the DragControls select state to determine if a button has been clicked during the update() event.
Instead I would suggest you use the onPointerClick callback. You can simply attach a Button component to the iconButton element and use the buttonās onClick event and remove the DragControls usage (line 44) and custom update() method completely (line 85)
Note that all components provide access to common pointer events like onPointerClick - these will be invoked for 3D elements in the scene (so if a component is attached to e.g. a three.js Mesh then this component can receive onPointerEnter or onPointerClick events)
Iāll also look into adding a mechanism to stop the XRSession after the frame has finished so it would also work the way you built it in a future version of the engine