Draco decoding errors result in uncaught promise rejections.
See original GitHub issueDescribe the bug
When decoding a GLTF model with Draco compression, in some cases if the decoding process fails a promise in GLTFLoader is rejected but not caught. Thus in my code neither the onError nor the onLoad arguments are ever executed.
I believe I have a fix here: https://github.com/mrdoob/three.js/compare/dev...twastvedt:dracoCatchPromise. Tested with the Draco example. I’m happy to create a PR, but I’m sure I’m ignorant of what all is at play here, so wanted to make sure first. My fix substitutes the current use of decodeDracoFile
, which is marked deprecated in DRACOLoader, with decodeGeometry
, which returns a promise that we can catch.
To Reproduce
Steps to reproduce the behavior:
- Go to https://jsfiddle.net/srq463dg/
- Note that in the console the onError method (line 58) never executes.
- Open developer tools and note that an error has occurred in the Draco loader (“THREE.DRACOLoader: Decoding failed: Failed to decode point attributes”).
Note: The errorModel
data url in the fiddle is a valid gltf model that has been truncated. In my app’s environment there is a string length limit imposed on models, thus this entire investigation.
Code
loader.load(errorModel, function (data) {
console.log("Loaded model");
scene.add(data.scene);
}, null, function (error) {
console.log(`In error handler: ${error}`);
});
Expected behavior
Any error in the Draco loader should cause the onError
argument of GLTFLoader.load
to be executed.
Platform:
- Device: Desktop
- OS: Windows
- Browser: Chrome
- Three.js version: dev
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
I think we may need to overhaul DRACOLoader a bit anyway (see https://github.com/mrdoob/three.js/issues/22445 …) and have it use the new WorkerPool utility. Probably better to resolve this all at the same time, I’ll self-assign it in that case.
I’ve run into a similar unhandled promise rejection error with DRACO decoding in some environments where there isn’t enough memory for the wasm decoder to run properly. I get an unhandled promise rejection with
memory access out of bounds
. I can setup an example that illustrates the problem if needed but it’s similar to what’s described in the issue.It would be great if I could handle the error properly and fallback to something else. Is there an update on this issue?