KTX2 transcoder getting redownloaded for every texture


I’m adding .ktx2 textures at runtime. I used toktx to compress them with --uastc. Now when I add them at runtime, the transcoders are getting downloaded multiple times:

When I add another texture like 2 transcoders are getting downloaded again. I use the asset manager to add them.

This also happens when I add the scripts in the head.

What is going on here?

@bghgary might have some ideas ?

@Regit Do you mind creating a playground with an example? Then I can debug it more quickly.

The KTX files are being decoded in web workers by default. Since they are separate scopes, the top level JS decoder files will be imported multiple times (hopefully the browser is smart enough to not actually redownload the files). The WASM ideally could be downloaded only once and copied into each worker. I’m not sure if the code is done this way though.

I transfered my local project to the playground, but here it doesn’t seem to download the decoders at all? (as shown in the Network tab).
There’s something off here still right? :sweat_smile:

The ktx2 decoder as well as the transcoders are not downloaded because they are taken from the disk cache:

(note that by default there are 4 worker threads)

If clearing the cache before browsing the page:

We can see the 3 files are downloaded a single time as the 3 other times the size is 0 bytes.


Nice, thank you for clarifying!

1 Like