godotengine / godotengine/godot
ResourceLoader crash loading CompressedTexture2D on Android
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
Tested versions
This crash is reported to us via sentry.io from a released Godot 4.3 game. The crash only happens on android devices, it does not happen on windows or ios.
We haven't been able to reproduce on our android devices though
System information
Android (12,13,14,15) - Godot 4.3 - Compatibility
Issue description
Application Specific Information:
Segfault
Thread 0 Crashed:
0 libc.so 0x725c11ccf8 <unknown> + 491170942200
1 libutils.so 0x72609255f8 android::FileMap::~FileMap
2 libandroidfw.so 0x72612acdb0 android::incfs::IncFsFileMap::~IncFsFileMap
3 libandroidfw.so 0x726125dcb0 android::_FileAsset::~_FileAsset
4 libandroidfw.so 0x726125dd40 android::_FileAsset::~_FileAsset
5 libandroid.so 0x71a6426424 AAsset_close
6 split_config.arm64_v8a.apk 0x70728fe1a4 [inlined] FileAccessAndroid::_close (file_access_android.cpp:77)
7 split_config.arm64_v8a.apk 0x70728fe1a4 FileAccessAndroid::~FileAccessAndroid (file_access_android.cpp:262)
8 split_config.arm64_v8a.apk 0x7073e6b9bc [inlined] memdelete<T> (memory.h:116)
9 split_config.arm64_v8a.apk 0x7073e6b9bc [inlined] Ref<T>::unref (ref_counted.h:210)
10 split_config.arm64_v8a.apk 0x7073e6b9bc [inlined] Ref<T>::~Ref (ref_counted.h:223)
11 split_config.arm64_v8a.apk 0x7073e6b9bc CompressedTexture2D::_load_data (compressed_texture.cpp:89)
12 split_config.arm64_v8a.apk 0x7073e6c8c4 CompressedTexture2D::load (compressed_texture.cpp:138)
13 split_config.arm64_v8a.apk 0x7073e6d630 ResourceFormatLoaderCompressedTexture2D::load (compressed_texture.cpp:472)
14 split_config.arm64_v8a.apk 0x7074cd0e48 ResourceLoader::_load (resource_loader.cpp:269)
15 split_config.arm64_v8a.apk 0x7074cc93b0 ResourceFormatImporter::load (resource_importer.cpp:151)
16 split_config.arm64_v8a.apk 0x7074cd0e48 ResourceLoader::_load (resource_loader.cpp:269)
17 split_config.arm64_v8a.apk 0x7074cd1748 ResourceLoader::_thread_load_function (resource_loader.cpp:323)
18 split_config.arm64_v8a.apk 0x7074cd2c6c ResourceLoader::_load_start (resource_loader.cpp:543)
19 split_config.arm64_v8a.apk 0x7074cb5b48 ResourceLoaderBinary::load (resource_format_binary.cpp:701)
20 split_config.arm64_v8a.apk 0x7074cba238 ResourceFormatLoaderBinary::load (resource_format_binary.cpp:1240)
21 split_config.arm64_v8a.apk 0x7074cd0e48 ResourceLoader::_load (resource_loader.cpp:269)
22 split_config.arm64_v8a.apk 0x7074cd1748 ResourceLoader::_thread_load_function (resource_loader.cpp:323)
23 split_config.arm64_v8a.apk 0x707503f7d8 WorkerThreadPool::_process_task (worker_thread_pool.cpp:140)
24 split_config.arm64_v8a.apk 0x70750404e8 WorkerThreadPool::_thread_function (worker_thread_pool.cpp:205)
25 split_config.arm64_v8a.apk 0x7074aed1c8 Thread::callback (thread.cpp:64)
26 split_config.arm64_v8a.apk 0x7074aed4f8 [inlined] std::__ndk1::__invoke<T> (type_traits:3874)
27 split_config.arm64_v8a.apk 0x7074aed4f8 [inlined] std::__ndk1::__thread_execute<T> (thread:273)
28 split_config.arm64_v8a.apk 0x7074aed4f8 std::__ndk1::__thread_proxy<T> (thread:284)
29 libc.so 0x725c1c8d5c <unknown> + 491171646812
30 libc.so 0x725c15cbc0 <unknown> + 491171204032
Steps to reproduce
In C++ we call ResourceLoader::load_threaded_request() 5 times in a row to pre-load some simple scenes that contains a few Sprite2D and CPUParticles2D. I haven't been able to reproduce though. I'm assuming it has something to do with the timing of the worker threads calling AAssetManager_open and AAsset_close. I'm hoping maybe it just needs some checks or a mutex to prevent.
Minimal reproduction project (MRP)
Sorry I couldn't come up with a repro project.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with file_access_android.cpp at FileAccessAndroid::_close and its destructor, then trace the CompressedTexture2D::_load_data path in compressed_texture.cpp. Exercise five consecutive ResourceLoader::load_threaded_request() calls on Android and determine whether concurrent AAssetManager_open/AAsset_close activity explains the crash; done means the failure cause and a verified correction are established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, cpp
- Domain
- game-dev, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100