GLB import error - only on Quest or phone

Finally got to try this. Does this make anymore sense to you @bghgary? Maybe it is trying to reference an array of functions after it has been destroyed/nulled??.

Using the falback js decoder the error stack is:

draco_decoder_gltf.js:25 Uncaught TypeError: l[o[((o[(a >> 2)] + 4) >> 2)]] is not a function
at tb (draco_decoder_gltf.js:25)
at Module._emscripten_bind_Mesh___destroy___0 (draco_decoder_gltf.js:35)
at Mesh.destroy.Mesh.destroy (draco_decoder_gltf.js:35)
at Object.destroy (draco_decoder_gltf.js:35)
at fh (b9f22697-73e5-4160-9d2d-79b8badee94d:1)
at b9f22697-73e5-4160-9d2d-79b8badee94d:1
at Object.Module.then (draco_decoder_gltf.js:35)
at onmessage (b9f22697-73e5-4160-9d2d-79b8badee94d:1)
tb @ draco_decoder_gltf.js:25
Module._emscripten_bind_Mesh___destroy___0 @ draco_decoder_gltf.js:35
Mesh.destroy.Mesh.destroy @ draco_decoder_gltf.js:35
destroy @ draco_decoder_gltf.js:35
fh @ b9f22697-73e5-4160-9d2d-79b8badee94d:1
(anonymous) @ b9f22697-73e5-4160-9d2d-79b8badee94d:1
Module.then @ draco_decoder_gltf.js:35
onmessage @ b9f22697-73e5-4160-9d2d-79b8badee94d:1

KHR_draco_mesh_compression.ts:99 Uncaught (in promise) Error: /meshes/2/primitives/0: Uncaught TypeError: l[o[((o[(a >> 2)] + 4) >> 2)]] is not a function
at KHR_draco_mesh_compression.ts:99
at async Promise.all (/WebXR/index 0)
at async Promise.all (/WebXR/index 0)
at async Promise.all (/WebXR/index 2)
at async Promise.all (/WebXR/index 0)
at async Promise.all (/WebXR/index 0)
at async Promise.all (/WebXR/index 0)

Not really :confused:

Are you able to catch the exception at that point? Maybe if you go up the callstack, there will be some code in Babylon.js?

Not sure how to do that. In the code snippet I included above the error is being trapped in KHR_draco_mesh_compression.ts and then rethrown as a new error. I would need to modify my cached version of that code but I don’t know how to.

Ok, I have figured out how to modified the cached version and replaced the throw of a new error with “throw error”, and it seems to be coming from the last line of this snippet - in a (mangled) function called fh(e, t, i, n, r):

try { 
    var l = c.GetEncodedGeometryType(o);
    switch (l) {
    case e.TRIANGULAR_MESH:
        a = new e.Mesh,
        s = c.DecodeBufferToMesh(o, a);
        break;
    case e.POINT_CLOUD:
        a = new e.PointCloud,
        s = c.DecodeBufferToPointCloud(o, a);
        break;
    default:
        throw new Error("Invalid geometry type " + l)
    }
    if (!s.ok() || !a.ptr)
        throw new Error(s.error_msg()); 

At least I am making progress and learning some bits along the way.

You shouldn’t have to modify the code. In the browser, there is usually a way to stop at an exception (even if it is caught). But yeah, this error is from Draco’s code.

I have raised an issue on the Draco github - issue 662 - so I will see if they can suggest anything.

In prepping for that issue I exported the model again from Blender with a lower compression level and without shape keys and skinning (because when I viewed the model in a validator it said it was a valid model but had a warning about empty skinning or some such). This new model works so it might be either the skinning or compression level (previously I used 6 this time I used 3).

Anyway, hopefully that will be enough information for them to suggest something…in any event I have a model that works on mobile albeit without the animation working properly.

A PG with the model working is here https://playground.babylonjs.com/#J61GAR#1
and with the model not working here Babylon.js Playground

1 Like

Another thing you can try is to open the model in Don’s glTF viewer which also uses Draco and see if the same thing happens.

Yeah it loads fine in Don’s viewer. It does give the same 3 warnings about NODE_SKINNED_MESH_NON_ROOT. I saw these warnings in the GLTF Validation block in the Inspector in the BJS sandbox which is what led me to export without skinning which gave me a model that would load on mobile without the error but without the animations having an effect. I have detailed this in the draco issue and I am pretty sure it must be something to do with the animation/skinning.

Which one works? The original one or the one without the animation/skinning?

This is weird. I don’t expect animation/skinning to be related since Draco doesn’t do compression on animation or skinning AFAIK.

Sorry I should have been more specific. The model with the skinning. But I could only triy it on PC, I couldn’t get Don’s viewer to load the model on mobile, it just wouldn’t give me the option to upload it, the Upload button does nothing and I couldn’t work out drag/drop on the phone.

It may not have been the skinning. The other option I changed was compression level from 6 to 3. What I should do is turn on skinning again and try with compression level 3.

I just tried with a model exported with compression level 3 and skinning - it fails. It does seem to be related to the skinning.