Skip to content
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

Model import crashes the Unity Editor #52

Closed
seyfeb opened this issue Apr 8, 2022 · 8 comments
Closed

Model import crashes the Unity Editor #52

seyfeb opened this issue Apr 8, 2022 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@seyfeb
Copy link

seyfeb commented Apr 8, 2022

When importing a glTF model in Unity using glTFast and the KtxUnity package the Unity editor crashes. This is observed when KtxUnity is added via the file system (either the current main branch or the commit tagged 2.0.1. If I add the package via git URL glTFast claims that the KtxUnity package is not even available (see the issue in the glTFast repo atteneder/glTFast#381).

Expected behavior

The model is imported correctly. Addtitionally, a model import should never crash the editor or a runtime application, even for completely broken models.

OS: macOS
Unity editor version: 2021.2.19f1
KtxUnity version: main / 2.0.1
Test model: https://github.com/KhronosGroup/glTF/files/4132437/Avocado.zip

package.json

    "com.atteneder.gltfast": "4.6.0",
    "com.atteneder.ktx": "file:../mypackages/KtxUnity",

editor.log

Start importing Assets/Avocado/Avocado.gltf using Guid(a7299cc32fc4d43a3856f49f0bc3efcf) Importer(-1,00000000000000000000000000000000) Assertion failed: (colorModel == KHR_DF_MODEL_UASTC), function ktxTexture2_TranscodeBasis, file /Users/runner/work/KTX-Software-Unity/KTX-Software-Unity/KTX-Software/lib/basis_transcode.cpp, line 177.
Obtained 0 stack frames.
Launching bug reporter
Assertion failed: (colorModel == KHR_DF_MODEL_UASTC), function ktxTexture2_TranscodeBasis, file /Users/runner/work/KTX-Software-Unity/KTX-Software-Unity/KTX-Software/lib/basis_transcode.cpp, line 177.
Obtained 0 stack frames.
Launching bug reporter
Assertion failed: (colorModel == KHR_DF_MODEL_UASTC), function ktxTexture2_TranscodeBasis, file /Users/runner/work/KTX-Software-Unity/KTX-Software-Unity/KTX-Software/lib/basis_transcode.cpp, line 177.
Obtained 0 stack frames.
@atteneder
Copy link
Owner

@seyfeb Thanks for reporting!

I can reproduce the issue. I tried to view this file in two alternative glTF viewers and they also threw errors.

Looking at the KTX file (via ktxinfo) I can see that it apparently has an incorrect model (KHR_DF_MODEL_RGBSDA). They were created with gltfpack 0.13, which is rather old. Have you tried re-encoding the original glTF with an up-to-date version of gltfpack ?

Where does this file come from? I presume it's an attachment of an older GH thread, right? Is there a link to its context?

@atteneder atteneder self-assigned this Apr 8, 2022
@atteneder atteneder added the bug Something isn't working label Apr 8, 2022
@atteneder
Copy link
Owner

Nevermind, I figured it's from here.

Don't use this asset. It was created during development of KTX-Software and is probably outdated.

@seyfeb
Copy link
Author

seyfeb commented Apr 8, 2022

Thanks for looking into this. Reconverting this with a current version indeed fixes the error, however the result is somewhat strange:

Before conversion (right), and after conversion (left)
Screen Shot 2022-04-08 at 12 40 20

Converted using gltfpack -i Avocado.gltf -o gltfpacked/Avocado.gltf -tc

The textures here in seem okay

Screen Shot 2022-04-08 at 12 42 01

Anyway, I would still be worried using KtxUnity if it crashes the editor (and also any app at Runtime?) only because the input was malformed. Is there a way to prevent this from happening?

@atteneder
Copy link
Owner

This is a known Unity issue. Use gltfpack's -noq parameter to avoid the troublesome quantization.

@seyfeb
Copy link
Author

seyfeb commented Apr 8, 2022

Good to know it’s a different issue. While having the other one I thought it might be related...

So the only thing that remains here is the question how to avoid the crash at all (even for malformed data)!

Btw, thanks for the work you put into these open-source libraries!

@atteneder
Copy link
Owner

@seyfeb You're right about crashes are not a reasonable reaction to corrupt data. Since the assertion is inside the third party code, I forwarded the request in a discussion. Let's see what their answer is.

@MarkCallow
Copy link

@atteneder how come you are using a debug version of libktx in Unity? The encoders, especially ETC1S, are much slower when compiled in debug mode.

@atteneder
Copy link
Owner

@MarkCallow That's a great question! I assumed asserts are active in release builds as well, but that's not true. Turns out my macOS build was misconfigured. After re-building the lib, libktx returns a proper error and does not crash anymore.

Thanks for pointing it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants