-
Notifications
You must be signed in to change notification settings - Fork 284
Description
One of our user has occasional problems when loading a .glb file containing .ktx2 pictures:
https://playground.babylonjs.com/#CF7E5Q#17
Open the browser console to see the exception. Sometimes it works, so just hit F5 or the Play button to start it again until it fails. On my computer using Chrome, it fails fairly quickly, either the first time I browse the page or after 2 or 3 F5 refreshes. Note that you won't see the full stack traces I dumped below because I used locally a modified version of our ktx2Decoder component to get the stack traces (I will update the production site so that we can see the full traces in the Playground too).
I tried to dig a bit and the errors are thrown from inside the msc_basis_transcoder component, either from the transcodeImage or decodePalettes call:
(transcodeImage):
TypeError: Cannot perform Construct on a detached ArrayBuffer
at new Uint8Array (<anonymous>)
at emval_allocator_3 (eval at craftEmvalAllocator (http://localhost:1338/dist/preview%20release/ktx2Transcoders/msc_basis_transcoder.js:1:1), <anonymous>:13:11)
at __emval_new (http://localhost:1338/dist/preview%20release/ktx2Transcoders/msc_basis_transcoder.js:8:58552)
at <anonymous>:wasm-function[246]:0x1d2c0
at <anonymous>:wasm-function[488]:0x3585e
at ha (<anonymous>:wasm-function[296]:0x2cc1e)
at Module.dynCall_iiiiiiii (http://localhost:1338/dist/preview%20release/ktx2Transcoders/msc_basis_transcoder.js:8:63561)
at dynCall_iiiiiiii_1 (eval at makeDynCaller (http://localhost:1338/dist/preview%20release/ktx2Transcoders/msc_basis_transcoder.js:1:1), <anonymous>:4:12)
at BasisLzEtc1sImageTranscoder$transcodeImage [as transcodeImage] (eval at new_ (http://localhost:1338/dist/preview%20release/ktx2Transcoders/msc_basis_transcoder.js:1:1), <anonymous>:13:10)
at http://localhost:1338/dist/preview%20release/babylon.ktx2Decoder.js:1:16911
or (decodePalettes):
TypeError: Cannot perform Construct on a detached ArrayBuffer
at new Uint8Array (<anonymous>)
at emval_allocator_3 (eval at craftEmvalAllocator (http://localhost:1338/dist/preview%20release/ktx2Transcoders/msc_basis_transcoder.js:1:1), <anonymous>:13:11)
at __emval_new (http://localhost:1338/dist/preview%20release/ktx2Transcoders/msc_basis_transcoder.js:8:58552)
at <anonymous>:wasm-function[261]:0x2a776
at <anonymous>:wasm-function[503]:0x36857
at ga (<anonymous>:wasm-function[297]:0x2cc39)
at Module.dynCall_iiiiiii (http://localhost:1338/dist/preview%20release/ktx2Transcoders/msc_basis_transcoder.js:8:63452)
at dynCall_iiiiiii_1 (eval at makeDynCaller (http://localhost:1338/dist/preview%20release/ktx2Transcoders/msc_basis_transcoder.js:1:1), <anonymous>:4:12)
at BasisLzEtc1sImageTranscoder$decodePalettes [as decodePalettes] (eval at new_ (http://localhost:1338/dist/preview%20release/ktx2Transcoders/msc_basis_transcoder.js:1:1), <anonymous>:12:10)
at http://localhost:1338/dist/preview%20release/babylon.ktx2Decoder.js:1:16615
Note that those stack traces have been produced using the latest version of the msc component (https://github.com/KhronosGroup/KTX-Software/releases/tag/v4.0.0-beta6). The version used in production in the Playground above is a little older but the exceptions we get are the same.
Also, in the playground above I have set the number of worker threads to 1 to rule out a possible problem coming from multiple threads instancing the msc component.
So, maybe we are not doing the right things when using the component(?), even if I think the implementation is quite straightforward:
https://github.com/BabylonJS/Babylon.js/blob/master/ktx2Decoder/src/Transcoders/mscTranscoder.ts
Note that the .glb file is using only the ETC1S path.
Could you have a look on your side and tell us what you think? One thing that would help I think would be to know what is this buffer that is detached and not valid anymore: is it a buffer from our side (I don't think so, though, as sometimes the error comes from a call to decodePalettes and we don't pass any buffer to this function)?
Thanks in advance!