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

.basis and .ktx2 textures working intermittently on Safari #19717

Closed
5 of 11 tasks
igghera opened this issue Jun 23, 2020 · 20 comments
Closed
5 of 11 tasks

.basis and .ktx2 textures working intermittently on Safari #19717

igghera opened this issue Jun 23, 2020 · 20 comments

Comments

@igghera
Copy link

igghera commented Jun 23, 2020

Description of the problem

While testing the official example for the BasisTextureLoader on my devices (iPhone X, MacBook Pro 16) I noticed that sometimes the texture did not appear and the cube remained white.

At first I thought of a network error or similar, so I started digging.

  • No error happens on the Network, no error in the console.
  • The loading progress is logged in the console and it's ok.

I have uploaded a screen capture of the whole thing here.

The link to the official example is this: https://threejs.org/examples/?q=basis#webgl_loader_texture_basis

Not sure if it helps, but these guys here use the .basis format in this demo and that seems to work fine on Safari even after 50 page reloads: https://demo.shapespark.com/naniby-apartment-basis/
Maybe it's just a bug that has been introduced in a recent version?

I really hope so :) I've just discovered the basis format and I'm looking forward to using it into my projects.

I'll try to go through the source code of the BasisTextureLoader myself and see if I can debug it. Being intermittent makes it really hard.

Thanks for the great work to everyone!

Three.js version
  • Dev
  • r117
  • ...
Browser
  • Safari
  • iOS Safari
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
@mrdoob
Copy link
Owner

mrdoob commented Jun 23, 2020

It may be worth reporting the issue to basis directly:
https://github.com/BinomialLLC/basis_universal

@igghera
Copy link
Author

igghera commented Jun 23, 2020

I thought about it, then I went to their examples page and I could not reproduce the bug even after refreshing the page 100 times, hence I thought it could be an issue with the three.js loader.

But I'm not sure whether my logic makes sense or not.

The thing that baffles me the most is this one:

Not sure if it helps, but these guys here use the .basis format in this demo and that seems to work fine on Safari even after 50 page reloads: https://demo.shapespark.com/naniby-apartment-basis/

If their version works fine, what is the difference there? The version of three.js?
Although if I log THREE.revision it says "71" and I don't understand how that's possible.

Anyhow, @mrdoob if you think it makes sense I can open an issue on basis' repo

@JordyvanDortmont
Copy link
Contributor

JordyvanDortmont commented Jun 24, 2020

We're currently having an issue with loading our own recently compressed basis textures as well. Our (probably separate) issue occurs on Chromebooks Google Chrome OS, Version 83.0.4103.119. The basis texture does not load anymore and loading the same basis texture worked on a previous Chrome OS build.

This is relevant, because we discovered that the three.js example loads a basis texture that hasn't been re-compressed since June 2019. The basis texture example still works for the Chrome OS build that does not load our recently compressed basis texture. It might be a good idea to re-compress the basis texture of the example and check if it works consistently for Safari.

@igghera
Copy link
Author

igghera commented Jun 29, 2020

@JordyvanDortmont I don't have any machine to run Chrome OS, but I'd be curious to see if the issue with Safari happens with your textures, both the recently compressed and the old ones.

I have looked into the three.js BasisTextureLoader but I have no idea how to solve the problem. It doesn't throw an error, it only happens sometimes... I'm stuck.

Out of curiosity, do you guys use any special parameter when using the basis universal codec? I simply run basisu image.jpg with no special inputs

@JordyvanDortmont
Copy link
Contributor

Out of curiosity, do you guys use any special parameter when using the basis universal codec? I simply run basisu image.jpg with no special inputs

@igghera it might be the mipmaps! Maybe you can try basisu -mipmap image.jpg.

@JohannesDeml
Copy link
Contributor

JohannesDeml commented Jun 29, 2020

@JordyvanDortmont @igghera I'm using basis textures with mipmaps which are created with version 1.12 (latest version as of now). I didn't find the described problems. Tested on Chrom+Firefox on Windows and Safari on iOS. Here is a simple example scene with the latest threejs version: https://rawcdn.githack.com/JohannesDeml/three.js/2ac64131c77a82a86b0726845e5d83450b2f7898/examples/webgl_loader_gltf_basis.html
Can you reproduce your problem in this minimal setup?

Edit: Changed the link to the fixed version that should also work in Chrome.

@donmccurdy
Copy link
Collaborator

donmccurdy commented Jun 29, 2020

^This example is working consistently in Safari 13.1.1 on macOS 10.15.5 for me.

@JordyvanDortmont
Copy link
Contributor

JordyvanDortmont commented Jun 30, 2020

Can confirm this works consistently on Safari on iOS 12.4.6 @JohannesDeml.

@igghera the issue that the textures only load intermittently and the cube remains white also occurs on Windows 10 Chrome for this example. Although I can't reproduce it on my own device. Maybe it has something to do with #19541?

The example of @JohannesDeml turns black on Windows 10 Chrome, because of the ImageBitmapLoader bug that was fixed in r118.3 (#19738).

@JohannesDeml
Copy link
Contributor

The example of @JohannesDeml turns black on Windows 10 Chrome, because of the ImageBitmapLoader bug that was fixed in r118.3 (#19738).

Oh, you're right, I posted the link I used for the bug report, here is the new one that works in chrome as well: https://rawcdn.githack.com/JohannesDeml/three.js/2ac64131c77a82a86b0726845e5d83450b2f7898/examples/webgl_loader_gltf_basis.html

@JordyvanDortmont
Copy link
Contributor

Alright that works on Windows 10 Chrome! Thanks for updating your example. I checked our example again and the issue was that we didn't use the rawcdn, so I fixed the link in my previous comment.

@JordyvanDortmont
Copy link
Contributor

Update on the issue I mentioned here #19717 (comment):
https://bugs.chromium.org/p/chromium/issues/detail?id=1100834

@wrr
Copy link
Contributor

wrr commented Jul 3, 2020

https://demo.shapespark.com/naniby-apartment-basis/

We had a similar problem on Safari with a code that runs this demo. We've managed to figure out that workers on Safari were for some reason breaking: post messages from workers were sent, but did not reach the main thread. We haven't managed to figure out what is causing this and added a workaround to disable decoding in workers on Safari. Our code doesn't use examples/jsm/loaders/BasisTextureLoader.js, but because this loader also uses workers, this can be the same issue.

@donmccurdy
Copy link
Collaborator

donmccurdy commented Mar 18, 2021

Seeing the same issue with KTX (which relies on BasisTextureLoader) too apparently. :(

https://threejs.org/examples/?q=ktx#webgl_loader_texture_ktx2

EDIT: OTOH, I can't reproduce the issue on this demo at all: https://modelviewer.dev/examples/loading/index.html#ktx2Support, and it uses the same loaders. I'm not sure how to debug this...

@donmccurdy donmccurdy changed the title Basis textures working intermittently on Safari .basis and .ktx2 textures working intermittently on Safari Mar 18, 2021
@lexaknyazev
Copy link
Contributor

@donmccurdy

https://threejs.org/examples/?q=ktx#webgl_loader_texture_ktx2

That demo works for me in Safari 14.0.3 / macOS 11.2.3

@donmccurdy
Copy link
Collaborator

Same versions and OS here (Safari 14.0.3 / macOS 11.2.3) but still broken. Note that it does work most of the time, but within a few page reloads will fail.

Additional details: MacBook Pro (15-inch, 2018), Radeon Pro 555X 4 GB.

@lexaknyazev
Copy link
Contributor

I can confirm that the demo fails after the page is reloaded on Safari 14.0.3 as well as on Safari Technology Preview 122 (Safari 14.2, WebKit 16612.1.6.2).

MacBook Air (M1, 2020).

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 31, 2021

I've tested this issue today on an iPad (8th generation) and iPadOS 14.7.1. The bug still appears with webgl_loader_texture_basis. In approx. 1 out of 10 reloads, the plane is white and no texture is applied.

I was not able to reproduce the problem on Windows or Android with Chrome and FF. On macOS, it only happens in Safari but not with Chrome/FF.

Considering this and #19717 (comment), it clearly looks like a WebKit issue. Probably best to report it at: https://bugs.webkit.org/.

@mrdoob mrdoob closed this as completed Aug 31, 2021
@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 31, 2021

I've filed https://bugs.webkit.org/show_bug.cgi?id=229706

@blasco
Copy link

blasco commented Oct 26, 2021

https://threejs.org/examples/?q=ktx#webgl_loader_texture_ktx2

That demo works for me in Safari 14.0.3 / macOS 11.2.3

I can also confirm that the demo fails about 1 out of 5 times

@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 26, 2021

@blasco Please bump the webkit issue since we can't fix the problem in three.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants