-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Cannot perform Construct on a detached ArrayBuffer" error when using msc_basis_transcoder #371
Comments
@bghgary you have stated in another forum that this problem is "due to the browser cache. Can you try running it in a incognito (in-private) browser window or clear the browser cache?". People have reported success after doing so. Did you discover this after you thumbed-up this issue or is there still something I need to understand and fix? |
Update: It seems I can't make it fail anymore with the first PG I have provided (where size of worker pool = 1). What changed is that we now use the latest version of the msc transcoder. However, if using a pool of worker threads > 1, it's still failing sometimes. Here's the corresponding PG: https://playground.babylonjs.com/#CF7E5Q#18 Even in incognito mode, the PG above fails sometimes. |
I was telling people this because we updated the KTX decoder and the way we set up our CDN, it doesn't automatically update immediately. I ran into an issue also and clearing the cache also "fixed" it. It could be that clearing the cache didn't actually do anything and we just got lucky that it worked afterwards. I haven't investigated specifically the call stack for this failure. |
Please try just released Release Candidate 1. The web modules in this release have been built with the latest emsdk (2.0.16). |
Still the same error:
or:
|
Thanks. I'll try to investigate but my knowledge in this area is limited. Any help you can offer will be very welcome. |
Some questions:
I think I have not yet managed to reproduce the error. Both of the failing functions have code like the following, but so does decode_tables which isn't failing, to create a view into the memory allocated on the Emscripten heap for the incoming slices (in the case of transcodeImage) or the incoming endpoints and selectors (in the case of decode_palettes):
|
ArrayBuffer becomes "detached" when the underlying let m = new WebAssembly.Memory({initial: 1});
let b = m.buffer;
m.grow(1);
b == m.buffer; // false
new Uint8Array(b) // TypeError: Cannot perform Construct on a detached ArrayBuffer |
In the C++ code above, it may be possible that |
Thanks @lexaknyazev. @Popov72 please try moving the line
and the equivalent in decodePalettes and decodeTables to after the resize and see if that fixes your problem. |
@Popov72 I've made a new branch, issue371, with a potential fix. Please give it a try. You can now easily build the web modules using Docker. See the instructions in BUILDING.md. |
@MarkCallow Sorry, I haven't been able to generate the files myself (on Windows). docker is not installed in my virtual ubuntu:
Would you mind generating the two files for me so that I can test? I'm not sure I will be able to generate those files in a timely fashion (meaning in the remaining of my lifetime, as each time I try to build something from sources it fails miserably). Thanks! |
Here are the files packaged in a .zip to keep GitHub happy. Ignore the KTX-Software-4.0.0-rc1-Web-msc_basis_transcoder.zip The first error you got is either because the line
in the script didn't work, i.e. $(pwd) returned something strange, or because your KTX-Software directory is not populated, i.e. does not have a CMakeLists.txt. The latter seems unlikely as you have the script in this workarea. I'm surprised you have to change docker to docker.exe. I thought the various unix-like shells on Windows would automatically try foo.exe when not finding foo. What shell were you using? I know nothing about docker on Ubuntu so I can't help with that error. |
I'm using the ubuntu package from the Microsoft Store. Anyway, thanks for the files, it seems to have fixed the bug! With the old files, I had 3 crashes over 16 runs, with the new files no crash over 20 runs. Can I use those files to replace the old ones in the Babylon distrib or are you going to create a new official release with the fix? |
I'm glad the issue is fixed. I'll be releasing v4.0.0 with this in a few minutes. I suggest you use the files from that release. |
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 thetranscodeImage
ordecodePalettes
call:(transcodeImage):
or (decodePalettes):
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!
The text was updated successfully, but these errors were encountered: