From a30e7e11518db69a434eb0fbdb8158624ffbe51c Mon Sep 17 00:00:00 2001 From: Lukas Tenbrink Date: Fri, 10 Jul 2026 12:56:50 +0200 Subject: [PATCH] Avoid releasing main thread identity on platforms that don't need to drop it, making it a platform detail. (cherry picked from commit 92cb8246a5b67b36482ea597f23773984f53cf37) --- main/main.cpp | 3 --- platform/android/java_godot_lib_jni.cpp | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index e83574b45f..2fc62fdc54 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2924,9 +2924,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph message_queue = memnew(MessageQueue); - Thread::release_main_thread(); // If setup2() is called from another thread, that one will become main thread, so preventively release this one. - set_current_thread_safe_for_nodes(false); - #if defined(STEAMAPI_ENABLED) if (editor || project_manager) { steam_tracker = memnew(SteamTracker); diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index 212964239c..fe8151698c 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -50,6 +50,8 @@ #include "core/input/input.h" #include "core/os/main_loop.h" #include "core/os/os.h" +#include "core/os/thread.h" +#include "core/os/thread_safe.h" #include "core/profiling/profiling.h" #include "main/main.h" #include "servers/camera/camera_server.h" @@ -230,6 +232,9 @@ JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env return false; } + Thread::release_main_thread(); // setup2 will be called from another thread. + set_current_thread_safe_for_nodes(false); + TTS_Android::setup(p_godot_tts); java_class_wrapper = memnew(JavaClassWrapper);