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

Android: ANR in Address::Resolve #14646

Open
grorp opened this issue May 13, 2024 · 1 comment
Open

Android: ANR in Address::Resolve #14646

grorp opened this issue May 13, 2024 · 1 comment
Labels
Android Bug Issues that were confirmed to be a bug @ Network @ Startup / Config / Util

Comments

@grorp
Copy link
Member

grorp commented May 13, 2024

Minetest version

5.8.1

Operating system

Android

Summary

I saw this on the Play Console and I'm opening an issue for it since it looks fixable:

Input dispatching timed out

Stacktrace for "MinetestNativeThread":

#00  pc 0x00000000000d77e4  /apex/com.android.runtime/lib64/bionic/libc.so (read+4)
#01  pc 0x00000000000e3ecc  /apex/com.android.runtime/lib64/bionic/libc.so (__sread+52)
#02  pc 0x00000000000e3dbc  /apex/com.android.runtime/lib64/bionic/libc.so (__srefill+268)
#03  pc 0x00000000000e82e0  /apex/com.android.runtime/lib64/bionic/libc.so (fread_unlocked+200)
#04  pc 0x00000000000e81d0  /apex/com.android.runtime/lib64/bionic/libc.so (fread+72)
#05  pc 0x00000000000a45c8  /apex/com.android.runtime/lib64/bionic/libc.so (android_getaddrinfo_proxy+336)
#06  pc 0x00000000000a4290  /apex/com.android.runtime/lib64/bionic/libc.so (android_getaddrinfofornetcontext+1536)
#07  pc 0x00000000000a3c68  /apex/com.android.runtime/lib64/bionic/libc.so (android_getaddrinfofornet+56)
#08  pc 0x00000000006b84a8  /data/app/~~s6S-KxZcxQcWcOCZ8pZDWA==/net.minetest.minetest-KKtd8D2AOieFwzuuxLGpGg==/split_config.arm64_v8a.apk!libminetest.so (Address::Resolve(char const*)+172)
#09  pc 0x000000000055b250  /data/app/~~s6S-KxZcxQcWcOCZ8pZDWA==/net.minetest.minetest-KKtd8D2AOieFwzuuxLGpGg==/split_config.arm64_v8a.apk!libminetest.so (Game::connectToServer(GameStartData const&, bool*, bool*)+200)
#10  pc 0x0000000000553c84  /data/app/~~s6S-KxZcxQcWcOCZ8pZDWA==/net.minetest.minetest-KKtd8D2AOieFwzuuxLGpGg==/split_config.arm64_v8a.apk!libminetest.so (Game::createClient(GameStartData const&)+184)
#11  pc 0x0000000000553994  /data/app/~~s6S-KxZcxQcWcOCZ8pZDWA==/net.minetest.minetest-KKtd8D2AOieFwzuuxLGpGg==/split_config.arm64_v8a.apk!libminetest.so (Game::startup(bool*, InputHandler*, RenderingEngine*, GameStartData const&, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >&, bool*, ChatBackend*)+480)
#12  pc 0x00000000005662d0  /data/app/~~s6S-KxZcxQcWcOCZ8pZDWA==/net.minetest.minetest-KKtd8D2AOieFwzuuxLGpGg==/split_config.arm64_v8a.apk!libminetest.so (the_game(bool*, InputHandler*, RenderingEngine*, GameStartData const&, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >&, ChatBackend&, bool*)+104)
#13  pc 0x000000000051b2b8  /data/app/~~s6S-KxZcxQcWcOCZ8pZDWA==/net.minetest.minetest-KKtd8D2AOieFwzuuxLGpGg==/split_config.arm64_v8a.apk!libminetest.so (ClientLauncher::run(GameStartData&, Settings const&)+4016)
#14  pc 0x00000000007f6c54  /data/app/~~s6S-KxZcxQcWcOCZ8pZDWA==/net.minetest.minetest-KKtd8D2AOieFwzuuxLGpGg==/split_config.arm64_v8a.apk!libminetest.so (main+8228)
#15  pc 0x000000000083e37c  /data/app/~~s6S-KxZcxQcWcOCZ8pZDWA==/net.minetest.minetest-KKtd8D2AOieFwzuuxLGpGg==/split_config.arm64_v8a.apk!libminetest.so (android_main+112)
#16  pc 0x00000000004f4cfc  /data/app/~~s6S-KxZcxQcWcOCZ8pZDWA==/net.minetest.minetest-KKtd8D2AOieFwzuuxLGpGg==/split_config.arm64_v8a.apk!libminetest.so
#17  pc 0x00000000000ecc00  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+64)
#18  pc 0x000000000008c360  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)

Relevant code:

minetest/src/client/game.cpp

Lines 1574 to 1588 in 6303334

bool Game::connectToServer(const GameStartData &start_data,
bool *connect_ok, bool *connection_aborted)
{
*connect_ok = false; // Let's not be overly optimistic
*connection_aborted = false;
bool local_server_mode = false;
const auto &address_name = start_data.address;
showOverlayMessage(N_("Resolving address..."), 0, 15);
Address connect_address(0, 0, 0, 0, start_data.socket_port);
Address fallback_address;
try {
connect_address.Resolve(address_name.c_str(), &fallback_address);

Steps to reproduce

Idea: Have a bad internet connection so that resolving the address takes a long time.

@grorp grorp added Bug Issues that were confirmed to be a bug @ Startup / Config / Util @ Network Android labels May 13, 2024
@savilli
Copy link
Contributor

savilli commented May 16, 2024

It's easy to reproduce even on a PC. You need to try to connect to an address whose DNS server times out requests. A slow unstable mobile network would cause it too.

The fix is not so easy, unfortunately. We should avoid using getaddrinfo on the main thread, therefore we probably need to move it to a dedicated thread and communicate with it somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Bug Issues that were confirmed to be a bug @ Network @ Startup / Config / Util
Projects
None yet
Development

No branches or pull requests

2 participants