libgdx / libgdx/libgdx

I wanted to load a 200MB g3dj file, but it couldn't be loaded for a long time, and then the memory overflowed. Can anyone tell me what to do when loading a large 3D file? thanks

Open
#7,405 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
25.4k
Forks
6.5k
Avg merge
1d 16h
Merged PRs (30d)
5

Description

2024-05-15 06:25:05.125 10275-10315/com.wh.libgdxdemo E/AndroidRuntime: FATAL EXCEPTION: GLThread 230
Process: com.wh.libgdxdemo, PID: 10275
com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load dependencies of asset: Test/kcmx.g3dj
at com.badlogic.gdx.assets.AssetManager.handleTaskError(AssetManager.java:648)
at com.badlogic.gdx.assets.AssetManager.update(AssetManager.java:426)
at com.badlogic.gdx.assets.AssetManager.finishLoading(AssetManager.java:455)
at com.wh.libgdxdemo.game.WuHongGame5.create(WuHongGame5.java:78)
at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:312)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1557)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load dependencies of asset: Test/kcmx.g3dj
at com.badlogic.gdx.assets.AssetLoadingTask.handleAsyncLoader(AssetLoadingTask.java:119)
at com.badlogic.gdx.assets.AssetLoadingTask.update(AssetLoadingTask.java:91)
at com.badlogic.gdx.assets.AssetManager.updateTask(AssetManager.java:575)
at com.badlogic.gdx.assets.AssetManager.update(AssetManager.java:424)
at com.badlogic.gdx.assets.AssetManager.finishLoading(AssetManager.java:455) 
at com.wh.libgdxdemo.game.WuHongGame5.create(WuHongGame5.java:78) 
at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:312) 
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1557) 
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272) 
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: java.lang.OutOfMemoryError: Failed to allocate a 536870928 byte allocation with 25165824 free bytes and 253MB until OOM, target footprint 296060328, growth limit 536870912
at com.badlogic.gdx.utils.async.AsyncResult.get(AsyncResult.java:46)
at com.badlogic.gdx.assets.AssetLoadingTask.handleAsyncLoader(AssetLoadingTask.java:117)
at com.badlogic.gdx.assets.AssetLoadingTask.update(AssetLoadingTask.java:91) 
at com.badlogic.gdx.assets.AssetManager.updateTask(AssetManager.java:575) 
at com.badlogic.gdx.assets.AssetManager.update(AssetManager.java:424) 
at com.badlogic.gdx.assets.AssetManager.finishLoading(AssetManager.java:455) 
at com.wh.libgdxdemo.game.WuHongGame5.create(WuHongGame5.java:78) 
at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:312) 
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1557) 
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272) 
Caused by: java.lang.OutOfMemoryError: Failed to allocate a 536870928 byte allocation with 25165824 free bytes and 253MB until OOM, target footprint 296060328, growth limit 536870912
at com.badlogic.gdx.utils.JsonReader.parse(JsonReader.java:51)
at com.badlogic.gdx.utils.JsonReader.parse(JsonReader.java:83)
at com.badlogic.gdx.graphics.g3d.loader.G3dModelLoader.parseModel(G3dModelLoader.java:65)
at com.badlogic.gdx.graphics.g3d.loader.G3dModelLoader.loadModelData(G3dModelLoader.java:61)
at com.badlogic.gdx.assets.loaders.ModelLoader.getDependencies(ModelLoader.java:75)
at com.badlogic.gdx.assets.loaders.ModelLoader.getDependencies(ModelLoader.java:35)
at com.badlogic.gdx.assets.AssetLoadingTask.call(AssetLoadingTask.java:65)
at com.badlogic.gdx.assets.AssetLoadingTask.call(AssetLoadingTask.java:35)
at com.badlogic.gdx.utils.async.AsyncExecutor$2.call(AsyncExecutor.java:64)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the failing call at WuHongGame5.java:78 and trace AssetManager through ModelLoader, G3dModelLoader, and JsonReader using the supplied Android stack trace. Reproduce loading Test/kcmx.g3dj on Android and determine whether a supported fix or documented limitation addresses the out-of-memory failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
computer-graphics, mobile-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.