Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #7405

Open
xxlwanmm opened this issue May 31, 2024 · 1 comment

Comments

@xxlwanmm
Copy link

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)

@Frosty-J
Copy link
Contributor

You could try G3DB instead - this will be faster and smaller since it doesn't have to parse JSON. But it sounds to me like your model is far too complex for a mobile game. Keep it relatively low-poly for good performance and app size. E.g. the player model in my ghost game is 140KB as G3DJ.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants