Bug #126
Crash after loading gltf
0%
Description
Found that there is a fatal VR crash just after loading gltf, preventing VR users to enter worlds:
Loaded asset /content/char/male/bruce_lee/scene.gltf
asset-loader.js:44 Error in callback for /content/char/male/bruce_lee/scene.gltf DOMException: Failed to execute 'getViewerPose' on 'XRFrame': XRFrame access outside the callback that produced it is invalid.
at t.get (https://cdn.babylonjs.com/babylon.js:1:2729957)
at VRHelper.trackXrDevices (https://www.vrspace.org/babylon/js/ui/vr-helper.js:154:36)
at c.tracker [as callback] (https://www.vrspace.org/babylon/js/ui/vr-helper.js:46:33)
at e.notifyObservers (https://cdn.babylonjs.com/babylon.js:1:63927)
at t.render (https://cdn.babylonjs.com/babylon.js:1:534623)
at Avatar.headPos (https://www.vrspace.org/babylon/js/ui/avatar.js:515:16)
at Avatar._processContainer (https://www.vrspace.org/babylon/js/ui/avatar.js:248:42)
at https://www.vrspace.org/babylon/js/ui/avatar.js:495:18
at https://www.vrspace.org/babylon/js/ui/asset-loader.js:42:17
at p (https://cdn.babylonjs.com/babylon.js:1:1098457)
While debugging I found that it stops at avatar.js -> headPos()
There is a call:
this.scene.render(); // FIXME workaround
Which is not allowed from inside the callback.
Commenting this line makes the VR load "properly" again.
Related issues
History
Updated by Vander Dias over 2 years ago
- Related to Bug #125: gltf characters with babylon 5 added
Updated by Vander Dias over 2 years ago
- Status changed from New to Resolved
So, if you agree, I'll leave this as fixed.
The bug is in other parts. Babylon.js skeleton is quite finicky, but the solution is not here because calling render from this point won't work anyway.
Updated by Josip Almasi over 2 years ago
But headPos() is called all over the place. Like, it's called from resize(), which is called right after the character loads. (because characters can be of any size)
By default, characters resize to 1.8m, but in VR, they're supposed to resize to real-world of the user.
So do all characters resize properly once they load? IIRC cyclops was one of these, he was too big. Well if that's the case, we can use computeWorldMatrix(true) to enforce recalculation in safe manner. Just need to figure out transform node to recompute, only just :)
I was originally using bounding box for the calculus, but it doesn't work in the general case, as characters may have things attached to their heads, visible or not. E.g. lord_infandum char.