Load ktx2 decoder only once - if multiple ktx2 textures are requested

When I request multiple ktx2 textures, it downloads the decoders for me multiple times. How can I avoid this? Is there a preloader or something that I can reuse?

ThreeJS has the same problem, but fixed:

The decoders will be downloaded only once per worker thread, not each time a texture must be transcoded.

There are usually 4 worker threads by default (that’s something you can change), so a decoder will be loaded 4 times at most. And generally they will be loaded only once thanks to the browser cache.

The decoders can’t be preloaded because we don’t know in advance which one(s) will be needed as it depends on the source format and the capabilities of the target device. And we don’t want to preload all of them as generally a single one will be used at runtime.

The decoders are quite small (10-20K - the msc transcoder is a bit bigger but new small transcoders will come in the next months that will make msc used only in edge cases), so even if they ended up being downloaded 3 or 4 times it should not really matter.

(note that the issue you linked for 3js is not the same than the current one)

1 Like

Thank you :slight_smile: