gltfFileLoader: Array length out of bounds

Env: Windows 10 x64 / Firefox 115

Code:

Manually running new Uint8Array(arrayBufferView.buffer, (arrayBufferView).byteOffset + byteOffset, byteLength) can get correct result.

Here is runtime vars in devtools.
vars

It looks like the check (arrayBufferView as Uint8Array).byteOffset + byteLength > arrayBufferView.byteLength is incorrect.
The model is loaded using loadAssetContainerAsync.

ping @bghgary . Itā€™s Thanksgiving so he may take a few days to answer.

I think the correct check should be:

3 Likes

@kzhsw Can you send the asset that was causing the issue originally? I donā€™t believe the fix from @Evgeni_Popov is the original intention for the code and will cause the code to read bytes that it shouldnā€™t.

1 Like

Itā€™s fixed by the linked pr.
To compare:
before

after

It may not be the right/full fix, thatā€™s why we would need access to the source asset to investigate the issue more.

Iā€™ve updated the range check to be what was intended. @kzhsw I made sure the PG you sent works, but can you make sure it is working for your full scenario?

Fix incorrect range check when reading glTF buffer by bghgary Ā· Pull Request #14557 Ā· BabylonJS/Babylon.js (github.com)

2 Likes

I patched node_modules like this and it works.

1 Like