Unsafe to reuse a Decoder instance
- Dominant language
- C++
- Stars
- 7.5k
- Forks
- 1.1k
- Avg merge
- 47m
- Merged PRs (30d)
- 1
Description
My code was throwing this error on glTF models containing multiple mesh primitives compressed with Draco:
```
RuntimeError: memory access out of bounds
at wasm-function[79]:226
at wasm-function[76]:207
at wasm-function[314]:48
at wasm-function[313]:439
at wasm-function[312]:893
at wasm-function[186]:303
at wasm-function[346]:20
at wasm-function[460]:7
at k.DecodeBufferToMesh.k.DecodeBufferToMesh (/Users/donmccurdy/Projects/glTF-Transform/node_modules/draco3dgltf/draco_decoder_gltf_nodejs.js:128:54)
at T (/Users/donmccurdy/Projects/glTF-Transform/packages/extensions/dist/extensions.js:1:2157
```
After changing my code to create a new Decoder instance for each mesh, the error was resolved. I didn't pick up on that from the [JS API docs](b.com/google/draco#javascript-decoder-api); I'd assumed that DecoderBuffer instances had to be created for each mesh, given the different Init() data, but didn't make the same assumption for Decoders.
It took me a while to discover the error, since it only affected some models, and the solution wasn't obvious once I found it. Might be worth more specific error or documentation here, if possible, but either way I thought I'd write this up in case someone else hits the same issue.
Contributor guide
Assessment
This issue has not been assessed yet.