atteneder / KtxUnity

Load KTX and Basis Universal textures at runtime
Apache License 2.0
221 stars 42 forks source link

Android arm64-v8a release build crashes when loading KTX files #11

Closed atteneder closed 3 years ago

atteneder commented 4 years ago

basis files work development builds work

atteneder commented 4 years ago

Couldn't reproduce in 0.8.0

ruben-ivre commented 3 years ago

I know this issue is closed, but we are having the exact same issue on 1.0.0, arm64, KTX files only, release only, using your example project.

atteneder commented 3 years ago

Hi @ruben-ivre ,

sorry to hear that. I'll re-open the issue and investigate if you give me a bit more info:

thanks!

ruben-ivre commented 3 years ago

Thanks for the quick response. I've just used your example project and published it to android, no changes other than that.

  • Which Unity version are you using? 2019.4.21
  • Is it reproducible 100% Yes. Publish your example project to android, run it, choose "Format Test scene", pick any image and then any format in the right column, that should make it crash.
  • Does it happen with a any KTX file or a particular one? If latter, can you provide it? I've used the ones included in your example project, and it crashed with all I tested with.
  • Does it crash with single files or only in conjunction with loading a bunch of files? A single KTX file is enough to crash it.
mmusial commented 3 years ago

It's crashing at: /lib/arm64/libktx_unity.so (ktxTexture2_TranscodeBasis) from `KTX-Software/lib/basis_transcode.cpp'

something's wrong with uint32_t* BDB = This->pDfd + 1; line. Accessing BDB later is crashing.

EDIT: I found the issue. It's not above. Unfortunately Unity (2019.4f20) support for async/await is let say not the best. At least for me, this is summary what works and what doesn't:

Not crashing:

Crashing:

So I guess solution will be to add methods for Coroutines at least this is what I plan to do for now in my fork.

EDIT: Branch with coroutines instead of async/await https://github.com/mmusial/KtxUnity/tree/coroutines

atteneder commented 3 years ago

I found two bugs in the C binding that are likely the real reason for those crashes. I just tested KtxUnity 1.1.0 successfully on Android.