Failed to load GLTF: Invalid typed array length in CesiumJS

Hello,

I’m trying to load a 3D Tileset created with the CDB to 3D Tiles tool. Some of the GLTF models generated from GTModel can’t be read, and I encounter the following error in CesiumJS:

Failed to load glTF
Invalid typed array length: 4302598
Original stack:
Original stack:
RangeError: Invalid typed array length: 4302598
    at new Uint8Array (<anonymous>)
    at ComponentDatatype.createArrayBufferView (http://localhost:8080/Build/CesiumUnminified/index.js:22612:14)
    at new BufferView (http://localhost:8080/Build/CesiumUnminified/index.js:100873:44)
    at new MetadataTableProperty (http://localhost:8080/Build/CesiumUnminified/index.js:100338:18)
    at new MetadataTable (http://localhost:8080/Build/CesiumUnminified/index.js:100908:26)
    at parseFeatureMetadataLegacy (http://localhost:8080/Build/CesiumUnminified/index.js:111839:29)
    at GltfStructuralMetadataLoader.process (http://localhost:8080/Build/CesiumUnminified/index.js:112267:32)
    at processLoaders (http://localhost:8080/Build/CesiumUnminified/index.js:113111:52)
    at GltfLoader._process (http://localhost:8080/Build/CesiumUnminified/index.js:113157:5)
    at GltfLoader.process (http://localhost:8080/Build/CesiumUnminified/index.js:113223:18)
Handler stack:
Error
    at new RuntimeError (http://localhost:8080/Build/CesiumUnminified/index.js:11543:11)
    at ResourceLoader.getError (http://localhost:8080/Build/CesiumUnminified/index.js:101093:24)
    at handleError6 (http://localhost:8080/Build/CesiumUnminified/index.js:113094:20)
    at GltfLoader.process (http://localhost:8080/Build/CesiumUnminified/index.js:113226:5)
    at processLoader (http://localhost:8080/Build/CesiumUnminified/index.js:128722:26)
    at Model.update (http://localhost:8080/Build/CesiumUnminified/index.js:128642:26)
    at Model3DTileContent.update (http://localhost:8080/Build/CesiumUnminified/index.js:129627:9)
    at Cesium3DTile.process (http://localhost:8080/Build/CesiumUnminified/index.js:143904:19)
    at processTiles (http://localhost:8080/Build/CesiumUnminified/index.js:147250:12)
    at Cesium3DTileset.prePassesUpdate (http://localhost:8080/Build/CesiumUnminified/index.js:147115:3)
Handler stack:
Error
    at new RuntimeError (http://localhost:8080/Build/CesiumUnminified/index.js:11543:11)
    at ModelUtility.getError (http://localhost:8080/Build/CesiumUnminified/index.js:105893:24)
    at Model.update (http://localhost:8080/Build/CesiumUnminified/index.js:128647:49)
    at Model3DTileContent.update (http://localhost:8080/Build/CesiumUnminified/index.js:129627:9)
    at Cesium3DTile.process (http://localhost:8080/Build/CesiumUnminified/index.js:143904:19)
    at processTiles (http://localhost:8080/Build/CesiumUnminified/index.js:147250:12)
    at Cesium3DTileset.prePassesUpdate (http://localhost:8080/Build/CesiumUnminified/index.js:147115:3)
    at PrimitiveCollection.prePassesUpdate (http://localhost:8080/Build/CesiumUnminified/index.js:159553:17)
    at prePassesUpdate (http://localhost:8080/Build/CesiumUnminified/index.js:224359:14)
    at tryAndCatchError (http://localhost:8080/Build/CesiumUnminified/index.js:224433:5)

I ran the GLTF Validator, which didn’t return any errors but showed the following warning:

"code": "UNEXPECTED_PROPERTY",
                "message": "Unexpected property.",
                "severity": 1,
                "pointer": "/samplers/0/wrapR"

However, I don’t think this warning is the root cause of the issue.
Additionally, I can open the GLTF model in Blender without any problems. Do you have any idea what might be causing this issue in CesiumJS? Any suggestions on how I could investigate further?

Thanks for your time and support.

The “UNEXPECTED_PROPERTY” may be something to look into. But it should be unrelated to the error that you see.

It sounds like this could be a bug in the CDB-to-3D-Tiles tool, or in CesiumJS. From the stack trace, it looks like the error happens at a point where a “legacy” form of metadata is loaded, which could make it harder to pinpoint the exact reason for the error. Is it possible to share one of the glTF assets that causes this error? (In doubt, sharing it privately could be enough to at least identify the reason and open an issue in the proper GitHub repository…)