[SOLVED] Error exiting XR

When exiting XR I get the following error. I tried running the tutorial examples, but they give a similar error. Is there anyway to work around these?

I tested running https://playcanvas.com/project/460449/overview/webvr-ray-input with the WebXR device emulator browser extension (with emulated devices that have a least 1 controller) and running the code on the Oculus Quest. Both give the same result.

TypeError: Cannot read property ‘parent’ of null
at XrInputSource._updateTransforms (playcanvas-stable.dbg.js:23840)
at XrInputSource.getPosition (playcanvas-stable.dbg.js:23876)
at script.Controller.update (controller.js?id=30505832&branchId=87c5dc0c-00a1-4cec-9211-6c6a8b44b83c:39)
at ScriptComponent._scriptMethod (playcanvas-stable.dbg.js:29892)
at ScriptComponent._onUpdate (playcanvas-stable.dbg.js:29928)
at ScriptComponentSystem._callComponentMethod (playcanvas-stable.dbg.js:30343)
at ScriptComponentSystem._onUpdate (playcanvas-stable.dbg.js:30352)
at Function._helper (playcanvas-stable.dbg.js:26801)
at Function.update (playcanvas-stable.dbg.js:26809)
at Application.update (playcanvas-stable.dbg.js:26224)

And this one in the minified version:

playcanvas-stable.min.js:1004 Uncaught TypeError: Cannot read property ‘parent’ of null
at a._updateRayTransforms (playcanvas-stable.min.js:1004)
at a.getOrigin (playcanvas-stable.min.js:1006)
at c.Controller.update (__game-scripts.js:1)
at e._scriptMethod (playcanvas-stable.min.js:1225)
at e._onUpdate (playcanvas-stable.min.js:1226)
at b._callComponentMethod (playcanvas-stable.min.js:1240)
at b._onUpdate (playcanvas-stable.min.js:1241)
at Function._helper (playcanvas-stable.min.js:1110)
at Function.update (playcanvas-stable.min.js:1111)
at e.update (playcanvas-stable.min.js:1086)

@max Can you help with this please? :slight_smile:

Actually, I can too! This was fixed here:

This fix went out with Engine 1.27.1 yesterday.

But the examples on https://playcanvas.github.io are still based on 1.27.0.

Great! N00b question: Do I need to do anything to get this version in my project?

Well, I just ran your project in Chrome using the WebXR Emulator extension and it enters and exits VR just fine. Can you try again please?

Unfortunately, I still experience the error. With the emulator and on the Quest. I checked and it’s using version 1.27.1 Revision. So it might be my code in this case.

But I don’t see how I can exit VR fine in my version of Chrome though. What version of Chrome are you using?

I actually tried a few.

Chrome: 81.0.4044.138
Edge: 81.0.416.68
Oculus Browser uses Chromium version: 81.0.4044.117

All having the same issue.

@Sorskoot can you post your project for one of us to try?

Sure.

Debug: https://launch.playcanvas.com/912200?debug=true
Release: https://playcanv.as/p/liJPmJE0/

Or do you want just the project link? https://playcanvas.com/project/681835/overview/ravr

Hi @Sorskoot. So it’s a bit hard to debug the published app. When I look at your project, I notice that it’s based on the now deprecated WebVR API. The crash in your published app seemed to be in code managing WebXR input sources. So maybe there’s a clash there between the WebVR and WebXR code inside the engine.

I went to debug your game by launching from the Editor. I see it’s changed a bit from the published build. The script ‘controller’ no longer exists. And when I launch the scene, there’s immediately an error:

[web-vr-ui.js?id=30344978&branchId=97f609e8-c89e-45b7-8df8-261db7c3acd4:76]: Uncaught TypeError: Cannot read property 'isSupported' of null

TypeError: Cannot read property 'isSupported' of null
    at HTMLDivElement.onEnterVrPressedEvent (https://launch.playcanvas.com/api/assets/files/scripts/web-vr-ui.js?id=30344978&branchId=97f609e8-c89e-45b7-8df8-261db7c3acd4:76:33)

If you can get the main scene in a state where it’s debuggable, let me know. :smile:

Hi @will, I’m not sure what happened, but I’m not using web-vr-ui.js anymore. I removed the file my project earlier this week. But you gave me some ideas to try. This is the project. There are a few branches in there as well.

Ah, as read only users, we can only see the master branch :sweat_smile:

I don’t want to mess with the branches a few hours before the deadline of the game jam the game is for.

But, I’ve been testing with this project as well and it has the same exact issue: https://playcanvas.com/project/683093/overview/webxr-lab-temp

That was mine that I quickly hacked together to get you going :stuck_out_tongue:

Does this happen with Max’s projects? https://playcanvas.com/project/457917/overview/webvr-tracked-controllers

Yes. Even worse actually. With this one the error comes up every tick.

What I did:

  • Click the VR Button.
  • Click Exit Immersive (or hit Escape on the keyboard)

Result:

@Sorskoot

With the latest version of the engine and some of Max’s changes in the controller.js controller, you should be able to exit cleanly in that temp project: https://playcanvas.com/project/683093/overview/webxr-lab-temp

(Note: It’s a private project that I very quickly hacked together to get working. There’s lots of new features from the XR integration from Max that isn’t used and should be used in there :slight_smile: )

Yes!! No error. :+1:

1 Like