atteneder / glTFast

Efficient glTF 3D import / export package for Unity
Other
1.24k stars 251 forks source link

Could not allocate memory/ Memory access out of bounds on Android #132

Closed M4kHack closed 3 years ago

M4kHack commented 3 years ago

Great lib!

I only have one small issue, 1 in 10 models that I try to load crashes on android and it is always the same models, It is not related to the size of the model since it is not the biggest models that fail. They are sometimes only 5-6 mb and still have this issue.

it is one specific part of the model that crashes and if I remove it the model loads, then I can load only the failing part and it will work.

How ever I don't want to devide these models up into 2 and host both of them in order to load them. Is there any known issue causing this?

How to I catch the exceptions?

Thank you! //M4k

atteneder commented 3 years ago

Hi @M4kHack ,

Sorry for the inconvenience and thanks for reaching out!

It's hard to say without looking at the data. Could you provide the file in question? If it's sensible data, send it in a private message.

Does it work in the Editor?

M4kHack commented 3 years ago

Hi @M4kHack ,

Sorry for the inconvenience and thanks for reaching out!

It's hard to say without looking at the data. Could you provide the file in question? If it's sensible data, send it in a private message.

Does it work in the Editor?

Thanks for quick reply! I emailed you the details.

//M4k

atteneder commented 3 years ago

I just had a look on your models and I'm afraid they need to be optimized.

When Unity loads the Jpeg and PNG textures that are in your glTF, it decompresses them to RGBA bitmaps. So it doesn't matter how small your glb file is/was, it'll use a LOT more memory once unpacked.

If you take a look at the Unity Profiler and look at the scene memory, you'll see that your model (with lens) requires .85 GB of texture RAM.

image

I can imagine that mobile devices struggle to handle this amount of data.

Steps to solve this:

I hope that helps.

DerrickBarra commented 3 years ago

@M4kHack @atteneder in case you're not aware, there's also a memory limitation/bug with chrome 32-bit devices that in practice limits you to use less than 256mb total ram. So if android chrome is your target you should aim to use less than that to prevent the memory growth allocation error.

https://forum.unity.com/threads/android-chromium-unable-to-grow-allocated-memory-above-256mb-confirmed.1014475/

M4kHack commented 3 years ago

Thank you so much. That's all I need to know!

Legend =)