Texture Profiles + HTML5 Heap Size question

Hi everyone,

I’ve been experimenting with texture profiles for web build and wanted to get some feedback.

Previously I was just using the default built-in texture profile, but recently I switched to a custom setup (see screenshot). After doing that, I noticed in the Defold Resource Profiler that my peak total resource usage dropped quite a lot, from around ~160MB to ~50MB.

I’ve already read the docs about texture profiles, but I feel like I still don’t fully understand the practical trade-offs.

From what I understand, using compression might involve things like texture quality loss or runtime decompression, but I’m not really sure how significant those are in practice.

So I’m wondering: what are the actual downsides of this setup? Are there noticeable trade-offs in visual quality, performance, or loading time that I should watch out for?

Also, I have a question about HTML5 builds. When setting the Heap Size, should I base it on the peak “Total Resource” I see in the Resource Profiler while the game is running? Or is there something else I should consider when deciding the heap size?

Thanks in advance!

Quick update:

I did some testing on a few devices after switching to this texture profile.

  • iPhone 7 → load time increased by about ~1s
  • iPhone 12 → no noticeable difference
  • Desktop → also no noticeable difference

So it seems like there is a small cost on older devices (maybe due to decompression?), but on newer devices it’s basically unnoticeable.

On the positive side, I’m also seeing lower memory usage, and the build size is smaller as well, which is really nice.

There are many different factors at play here.

  • We mainly use Basis Universal as a platform/GPU agnostic compression format. It decompresses at runtime into a format suitable for the target device.
    • The size of the compressed texture is obviously smaller than an uncompressed image. How much smaller depends on compression settings.
    • Compression is usually lossy, which means that visual quality will be affected. Depending on settings and image the visual difference may be very small or very noticeable.
    • You pay a runtime CPU cost of transcoding from Basis to the target format supported by the GPU. This work is done on a thread and should not be noticeable as visual stutter, although on html5 you generally don’t have any threads and decompression will happen on the main thread which will lead to long frame times during transcoding.
  • Another option is to compress to a specific target format, for instance ASTC, which can be used without any runtime transcoding, since the texture is compressed in a format which the GPU can use.
  • The third option is to not compress textures at all.
    • The size of your build will grow, but you will not pay a CPU cost of transcoding the images. It might also be the case that the uncompressed texture will still compress rather well at least when downloaded gzipped in an html5 build or when compressed in an APK or IPA.

There is some general advice in the Texture Compression manual.

I’m sure @AGulev can provide more advice.

2 Likes

Thanks a lot for the explanation, this really helps me understand things better!

Based on my testing (older vs newer devices), it lines up pretty well with what you described.

I’ll probably keep using BasisU for now, but will keep an eye on potential frame spikes on HTML5 and older devices.

Really appreciate the insight!