atteneder / KtxUnity

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

KTX Basis textures fail to load on all iOS browsers #35

Closed DerrickBarra closed 1 year ago

DerrickBarra commented 3 years ago

Hi @atteneder , new bug report for ya.

On WebGL export projects, KTXUnity is loading some textures as black (no error, but not being displayed properly). Happens on our iPhone SE 2020 and iPhone 12 pro max. This happens on Safari, Chrome, and Firefox for iOS.

image image (1)

Using Chrome://inspect on iOS Chrome browser, you can see my OnSuccess messages for KTXUnity are firing off, I also have error debug logs in this project, but Unity thinks everything is fine and I'm only seeing success callbacks.

Built using Unity 2020.1.1f1, WebGL 1.0, uncompressed (no brotli or gzip compression). KTXUnity is set to 1.0.0 from February 03, 2021.

Check out our test Project, loading a bunch of .basis textures from an Amazon S3 bucket.

I'll update this thread if I find out anything else about this. From memory, this wasn't happening on older versions of KTXUnity, but I'll keep investigating. Let me know if you've ever seen this bug or can confirm it on your end!

DerrickBarra commented 3 years ago

@atteneder I've created a new repo for testing this bug, you can access it here.

atteneder commented 3 years ago

Hi @DerrickBarra ,

Thanks for the detailed report plus test repo. I'm still on paternity leave so I won't fix it soon, but I'll have a look in the next weeks.

atteneder commented 3 years ago

I observed that Safari is quite picky when it comes to textures. Is the resolution of the non-working textures by chance:

and do they come with mipmaps?

If not, please try to adhere to those rules and try them again.

DerrickBarra commented 3 years ago

@atteneder so looking at one of the textures that failed to load, the rabbit in the magic hat...

Magic+Rabbit

Here's a link to the .basis version.

This is a 1024x1024 image (divisible by 2, multiple of 4, square, no mipmaps). And it should be working...


So as a sanity test, I retested the project on my iOS SE 2020 and now everything works as expected even after multiple cache clearings, so I guess Apple released a Safari update that fixed it? That's nice!

atteneder commented 3 years ago

Great to hear!

In KtxUnity 1.1.0 I fixed a bug that potentially caused this trouble, but when I tested on my iOS devices, I still ran into troubles (but only on non-square non-multiple-of-four).

I'm waiting on 2021.2 (which will support WebGL mobile) to fix a build/linking error. After that I'll do more tests on iOS 14/15 before I call this one closed.

Thanks for your feedback

kyapp69 commented 2 years ago

Despite the various standards, iOS devices will only support square and power of 2 multiple of four textures, I think this is due to compatibility with metal apis

atteneder commented 2 years ago

Yeah, today I also ran into problems on macOS-metal with non-multiple-of-4 textures and BC7

atteneder commented 1 year ago

I just tested a dev version of the upcoming 2.2.0 release and it worked successfully on iOS 16 and iPadOS 15.7 respectively.

This version chooses formats differently, so that might have solved it (or the iOS updates).

Will close this ticket now. Releases imminent