From a4a940db2beaded2e9ea3936f1a735687a2cec4b Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Thu, 24 Sep 2026 00:40:35 -0400 Subject: [PATCH] [MG_Remote] (P12): the display geometry up-call attaches the apply thread to the JVM under its own name, so the rest of the session is not logged as the up-call's thread --- MobileGL/MG_Remote/Server/DisplayServerJni.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MobileGL/MG_Remote/Server/DisplayServerJni.cpp b/MobileGL/MG_Remote/Server/DisplayServerJni.cpp index 257353bf..84452236 100644 --- a/MobileGL/MG_Remote/Server/DisplayServerJni.cpp +++ b/MobileGL/MG_Remote/Server/DisplayServerJni.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include @@ -81,7 +82,12 @@ namespace { Bool attached = false; const jint got = vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6); if (got == JNI_EDETACHED) { - JavaVMAttachArgs args{JNI_VERSION_1_6, "mgl-srv-geometry", nullptr}; + // ART RENAMES the thread it attaches (and a detach does not rename it back), so the + // apply thread is attached under its OWN name - otherwise every later log line of the + // session would be tagged with the up-call's name instead of mgl-srv-apply. + char threadName[16] = "mgl-srv-apply"; + (void)pthread_getname_np(pthread_self(), threadName, sizeof(threadName)); + JavaVMAttachArgs args{JNI_VERSION_1_6, threadName, nullptr}; if (vm->AttachCurrentThread(&env, &args) != JNI_OK || env == nullptr) { MGLOG_E("MG_Remote server: could not attach the apply thread to the JVM to request display " "geometry %ux%u; the window keeps its own size",