godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.79k stars 20.13k forks source link

Embedding Godot in existing Android projects memory leaks #95060

Open hardikbhalodi opened 1 month ago

hardikbhalodi commented 1 month ago

Tested versions

version: 4.2.2.stable

Device: Samsung S10 Lite (Android 13)

System information

Ubuntu 22.04.4 LTS, GODOT ENGINE version: 4.2.2.stable, Device: Samsung S10 Lite (Android 13)

Issue description

I just tried the official demo GLTF viewer https://github.com/m4gr3d/Godot-Android-Samples/tree/master/apps/gltf_viewer

When i close the app with back button of device below error came in log and also sometime app crashing

**Object::Destroy(0xb4000079e9dc7f00) for engine ignored; 2 total active objects
16:55:00.866 libOpenSLES              E  Object::Destroy(0xb4000079e9dc7f00) for engine ignored; active object ID 2 at 0xb4000079e9c08e00
16:55:00.866 libOpenSLES              E  Object::Destroy(0xb4000079e9dc7f00) for engine ignored; active object ID 3 at 0xb4000079e9c4c400
16:55:00.914 godot                    E  USER WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
16:55:00.914 godot                    E     at: cleanup (core/object/object.cpp:2209)
16:55:00.935 libc                     A  FORTIFY: pthread_mutex_trylock called on a destroyed mutex (0xb400007a6573c66c)
16:55:00.936 libc                     A  Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 28395 (AudioTrack), pid 28260 (com.gododemo3)
16:55:01.245 DEBUG                    A  Cmdline: com.gododemo3
16:55:01.245 DEBUG                    A  pid: 28260, tid: 28395, name: AudioTrack  >>> com.gododemo3 <<<
16:55:01.245 DEBUG                    A        #04 pc 00000000000c2d7c  /data/app/~~RGYPDDw01I0KEmkQOkUWMw==/com.gododemo3-EfB8SEs8A_rvRlWxX7KLPw==/base.apk!libc++_shared.so (std::__ndk1::recursive_mutex::try_lock()+12) (BuildId: 25b13e08a3a359bf0ac835176dfbc89a7b30c1c4)
16:55:01.245 DEBUG                    A        #05 pc 0000000000d6e620  /data/app/~~RGYPDDw01I0KEmkQOkUWMw==/com.gododemo3-EfB8SEs8A_rvRlWxX7KLPw==/base.apk!libgodot_android.so**

i also made the Node2D hello world demo both have same issue.

Steps to reproduce

Load the demo app in android phone and press back button.

Minimal reproduction project (MRP)

GodotoDemo3_App.zip TestEmbedded_GODOT_PROJECT.zip

kus04e4ek commented 1 month ago

Can you check Godot 4.3 RC 2? There were some issues about memory leaks and crashes fixed on Android. ObjectDB instances leaked at exit is definetly a weird one, could have been fixed in 4.3 too though.

hardikbhalodi commented 3 weeks ago

Tested with 4.3 , issue persist and seems now app not quite on mobile back press just hang on embedded view screen.

USER WARNING: 2 RIDs of type "CanvasItem" were leaked. 16:53:28.118 godot E at: _free_rids (servers/rendering/renderer_canvas_cull.cpp:2485) 16:53:28.123 godot E ERROR: 2 RID allocations of type 'PN18TextServerAdvanced22ShapedTextDataAdvancedE' were leaked at exit. 16:53:28.126 godot E USER WARNING: ObjectDB instances leaked at exit (run with --verbose for details). 16:53:28.126 godot E at: cleanup (core/object/object.cpp:2284)