GLTF model memory usage

I’m trying to understand the memory footprint of a GLTF model. I used gltf-transform’s inspect feature. The model I have is just 2 megabytes in size, the textures are ktx2 encoded and the geometry is draco compressed. Looking in the task manager, I see that whether or not I’m loading the model (I still set up the basic ThreeJS scene in both cases) makes a difference of about 80-100 MBs. Is this normal? The inspect method tells me that textures and geometry makes up for around 20-25 MBs tops. Where does the rest come from, and can I do anything to further optimize this? Textures are already 1k/2k max, and around 200k vertices in total.

The problem is that we’re trying to load a bunch of these together, and while it works on desktop, we get constant crashes on mobile devices. I get that we’re probably pushing the boundaries with such complex scenes anyway, but still, is there something we could do or something we shouldn’t be doing to keep RAM usage down?

model.glb (1.8 MB)

Here’s the model btw.

It is especially annoying because if the device manages to load (all models), it plays rather smoothly even on mid-tier phones.

If this is the entire model - it should most definitely not be crashing mobile devices. Is there a chance you’re in someway just causing a memory leak either on the CPU or the GPU?

No-no, you misunderstand. This is just one of 6-8-10 models that are being loaded at the same time (well, sequentially). Some other models are larger. I just posted this one as a reference.

I’m wondering if it’s not even the sheer amount of RAM that is required, but an issue with Draco?

I’m getting this error on Android

Doing some research I see that others have faced these kind of issues too, but there was no clear cut solution (some suggested it was solved by a later version of Chrome etc.). But it’s clearly still present.

Yeah the memory use in the model above is really modest:

Does the model load on sites like on your devices? I sometimes test on iOS by putting the GLB in the iCloud “Files” app, but not sure how that works on Android.

I’d guess this is a Draco / WASM-related issue, rather than the GPU itself running out of memory.

Sorry for the late reply. Thanks for that link, this site looks interesting. How accurate that gpu memory usage indicator is, I wonder?

We’re facing a situation again where our models are crashing on the phones. Both on Android and iOS. We are specifically using un(draco)compressed files now to avoid any draco/wasm specific errors. We are however using ktx2 texture format.

Here’s the model in question (file is too large to directly upload here). I understand that this is not a small file, but we only have ~30 materials, textures are 2k max and the gltf report site says memory usage is around 114mb. Granted, there are a few other models loaded together with this, but those are much smaller. Overall gpu ram requirement is well below 200mB. So, any clues as to why are we getting the “aw snap” type of errors on phones?

Edit.: I understand that some meshes are far too unnecessarily complex and should be simplified, but unless it’s causing the crashes directly let’s just ignore that for the time being :slight_smile:

How accurate that gpu memory usage indicator is, I wonder?

About as accurate as it can be without knowing details about (1) renderer implementation, and (2) device GPU capabilities, both of which can affect the answer. For example, if your device doesn’t support any compressed formats at all (this is pretty rare) then the textures would be decompressed at runtime and memory consumption will be much higher.

That said — I don’t see anything in this model that should inherently crash phones. Do you get the errors immediately while loading, or only after the application has been running for a bit?

Like I said, we’re loading about 4-5 models but the others are much smaller, so practically just the one I posted and another one with ~10mB filesize (few materials, ktx2 encoding, 2k max). The models are loaded first, one after another and then rendered (added to the scene) one after another yet again.

It seems to crash sometime during the render phase (so definitely not a while later), but unfortunately there is no specific error message…

Btw, I tried loading the model in the gltf-viewer and looking at the task manager under Win10, is that one misleading? Cause it quotes around ~470-ish mBs of RAM…although that should still be fine on better phones, right? I’m testing on an S9 and an iPhone 13…

Edit: tried putting all the models together in one file (can’t share unfortunately due to it’s proprietary nature). File size: ~60mB, RAM usage estimated by is 146mB, and yet it’s a hit & miss on phones. Sometimes (rarely) it loads fine, but most of the time it crashes.

For the sake of comparison – here’s the model running fine in on iPhone 11 Pro. I have an older iPhone SE lying around, I’ll try charging that up for comparison too.

I guess I’m not confident we can attribute the crash to an out-of-memory error. This doesn’t seem like it should be a memory problem on iPhone 13.

I understand you can’t share the models here, but I think my suggestion might be to try omitting one or more models from the group, or loading them and replacing some or all materials with simple MeshBasicMaterial before rendering, to see if we can isolate something that causes the crash.

I had similar experience on phones.
Above 50mB some content refuse to load.
Imo the issue isn’t coming from RAM usage, nor webGL or three.

Seem there is a max size per request/page on some devices/browsers.
So my personal best practice is to split files and always stay under this limit (total assets size < 50mB)

Thanks for both of your suggestions. I’ll make sure to try them all!