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)
Iām sorry, I couldnāt find a response but notified the team 
Hi, thanks for the report, weāll look into it. Are you using Canvas UI elements (e.g. the Unity Canvas button? "...and am implementing a 3D UI"
)
It seems to be an error in three.js WebXRManager.
- Could you first try to update Needle Engine to the latest version (4.5.x)?
- If the error persists please upload a minimal reproducible bugreport (e.g. via Unity āNeedle Engine/Report a bugā)
The UI is instantiated during runtime and is implemented using ThreeMeshUI.
Do you think you could provide a example that reproduces the error? I could not reproduce it here locally so far
Where could I upload this reproducible bugreport?
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 have uploaded the report sadly twice because the first one was exported using the invalid scene and linked this thread.
Hello @Gilderko123 thanks for the bugreport.
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)
this.iconButton.addComponent(Button, {
onClick: EventList.from(() => {
this.handleButtonClick();
})
});
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)
1 Like
That seems to have done it I will do some more testing tomorrow but so far so good.
Please let me know how it goes.
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
1 Like
Hi I did some extra testing today and I no longer have the issue. Thanks for the assistance.