android-3D-model-viewer icon indicating copy to clipboard operation
android-3D-model-viewer copied to clipboard

Crash reloading Big Models

Open MonikaMoon opened this issue 3 years ago • 3 comments

I am creating a 3D model using multiple .stl files. I have updated STLLoaderTask according to my requirement to load multiple .stl files. I also have to add colors, but my model is not rendered correctly with colors. Its getting created for the first time but when I reload the model, my app is crashing with following errors: Caused by: java.lang.OutOfMemoryError: Failed to allocate a 65431423 byte allocation with 25165824 free bytes and 42MB until OOM, max allowed footprint 517468552, growth limit 536870912 at dalvik.system.VMRuntime.newNonMovableArray(Native Method) at java.nio.DirectByteBuffer$MemoryRef.(DirectByteBuffer.java:71) at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:257) at org.andresoviedo.util.io.IOUtils.createNativeByteBuffer(IOUtils.java:64) at org.andresoviedo.util.io.IOUtils.createFloatBuffer(IOUtils.java:43) at org.andresoviedo.android_3d_model_engine.services.collada.entities.MeshData.getVertexBuffer(MeshData.java:714) at com.movechair.modules.main.analysis.ThreeDModel.STLLoaderTask.build(STLLoaderTask.java:213) at org.andresoviedo.android_3d_model_engine.services.LoaderTask.doInBackground(LoaderTask.java:67) at org.andresoviedo.android_3d_model_engine.services.LoaderTask.doInBackground(LoaderTask.java:19) at android.os.AsyncTask$2.call(AsyncTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:246)  at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1187)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)  at java.lang.Thread.run(Thread.java:784) 

Please help me with this error.

MonikaMoon avatar May 20 '21 09:05 MonikaMoon

When debugging, always check the top first.

This one seems pretty simple - your phone ran out of memory. Try reducing model complexity.

jamesbellaero avatar May 20 '21 11:05 jamesbellaero

@jamesbellaero What exactly do you mean by reducing model complexity? My requirement is to render 3D model using multiple .stl file, I can not optimize it more. Is there any way to clear cache or Object3D while reloading the model?

MonikaMoon avatar May 21 '21 06:05 MonikaMoon

Perhaps you need to think about the issue differently. I don't know your use case, but generally when people want to render multiple 3D models they're doing video or game production

For videos and scene rendering, people use computers with 64+ GB of RAM and another TB of swap space.

For games, a lot of optimization is performed to reduce model size and render only the necessary components. I would not use this tool for games because I would not use .stl's for games.

jamesbellaero avatar May 21 '21 11:05 jamesbellaero