Thread names are overridden by JavaVM::AttachCurrentThread
Categories
(GeckoView :: General, defect)
Tracking
(firefox127 fixed)
Tracking | Status | |
---|---|---|
firefox127 | --- | fixed |
People
(Reporter: jnicol, Assigned: jnicol)
Details
Attachments
(1 file)
This has been a minor annoyance of mine for years, but never enough for me to track down the cause, until today. Some thread names appear in the Android Studio debugger as "Thread-<n>". eg the "Renderer" thread always appears as "Thread-3". We set the thread names when the threads are spawned, but they are getting overwritten, and today I captured the place this happens in a debugger:
prctl 0x0000758b0f5e8400
pthread_setname_np 0x0000758b0f5e71af
art::SetThreadName(const char *) 0x0000758b0ce379a7
art::Thread::CreatePeer(const char *, bool, _jobject *) 0x0000758b0ce08954
art::Thread::Attach(const char *, bool, _jobject *, bool) 0x0000758b0ce073a2
art::Runtime::AttachCurrentThread(const char *, bool, _jobject *, bool) 0x0000758b0cde8a17
art::JII::AttachCurrentThreadInternal(_JavaVM *, _JNIEnv **, void *, bool) 0x0000758b0cc8fb59
art::CheckJII::AttachCurrentThread(_JavaVM *, _JNIEnv **, void *) 0x0000758b0ca7e8e5
[Inlined] _JavaVM::AttachCurrentThread(_JNIEnv **, void *) jni.h:1058
mozilla::jni::GetEnvForThread() Utils.cpp:170
mozilla::gl::CreateSurfaceFromNativeWindow(mozilla::gl::EglDisplay &, void *, void *) GLContextProviderEGL.cpp:184
It seems the JVM overwrites it when we first attach a thread. That was enough information to easily find the chromium bug when they encountered this issue.
Seems we can easily fix this by supplying the thread name as an arg to AttachCurrentThread()
Assignee | ||
Comment 1•6 months ago
|
||
By default, AttachCurrentThread() overwrites the existing thread name
with "Thread-<n>", making it hard to identify these threads in a
debugger. By supplying the existing thread name as an argument to
AttachCurrentThread, we ensure that the thread keeps its name as
desired.
Comment 2•6 months ago
|
||
Oh, nice, Denis and I were confused by this when we looked at a perfetto trace yesterday.
Comment 3•6 months ago
|
||
I was curious where the actual Thread-<n> was coming from and it seems to be here: https://cs.android.com/android/platform/superproject/+/master:libcore/ojluni/src/main/java/java/lang/Thread.java;l=705;drc=9a73823472955a225341bbd7905200b46b280a79
Assignee | ||
Comment 4•6 months ago
|
||
(In reply to Jeff Muizelaar [:jrmuizel] from comment #3)
I was curious where the actual Thread-<n> was coming from and it seems to be here: https://cs.android.com/android/platform/superproject/+/master:libcore/ojluni/src/main/java/java/lang/Thread.java;l=705;drc=9a73823472955a225341bbd7905200b46b280a79
The comment directly underneath that is amusing
Comment 6•6 months ago
|
||
bugherder |
Updated•5 months ago
|
Description
•