Obsolete
Status Update
Comments
[Deleted User] <[Deleted User]> #2
I've tested this out on API 16, 19, 21-28, and can confirm that this behaviour is reproducible on API 24 and 25, using the following code snippet:
Map<Thread, StackTraceElement[]> stackTraces = Thread.getAllStackTraces();
Thread t = Thread.currentThread();
boolean b = stackTraces.containsKey(t); // value is false on API 24 + 25
On API 25, it appears that an entry is only added to the map if the thread is waiting for a monitor, which means only a small subset of Threads are collected. I've attached a thread trace and screenshot of the thread traces for both API 25 + 27. The IntelliJ monitor picks up all the threads for both API levels, but API 25 does not capture all the available info.
This is resolved in API 26+ as far as I can tell.
Map<Thread, StackTraceElement[]> stackTraces = Thread.getAllStackTraces();
Thread t = Thread.currentThread();
boolean b = stackTraces.containsKey(t); // value is false on API 24 + 25
On API 25, it appears that an entry is only added to the map if the thread is waiting for a monitor, which means only a small subset of Threads are collected. I've attached a thread trace and screenshot of the thread traces for both API 25 + 27. The IntelliJ monitor picks up all the threads for both API levels, but API 25 does not capture all the available info.
This is resolved in API 26+ as far as I can tell.
ib...@gmail.com <ib...@gmail.com> #3
Fixed
sa...@google.com <sa...@google.com> #4
Thank you for your feedback. We assure you that we are doing our best to address the issue reported, however our product team has shifted work priority that doesn't include this issue. For now, we will be closing the issue as won't fix obsolete. If this issue currently still exists, we request that you log a new issue along with latest bug report here https://goo.gl/TbMiIO .
Description
Thread mainThread = Looper.getMainLooper().getThread();
ThreadGroup mainThreadGroup = mainThread.getThreadGroup();
Thread[] mainGroupThreads = new Thread[mainThreadGroup.activeCount + 5];
int mainGroupThreadCount = mainThreadGroup.enumerate(mainGroupThreads, false);
The mainThread will not exist in mainGroupThreads.
I reproduced the problem stated above on a Nexus 5X running Android 7.1.2. Our error logs show that this is almost unique in Android 7+, and occurs across a huge variety of device models. Is it a bug, or an application-specific issue due to configuration? Is there a robust way to programmatically retrieve stack traces from all threads in Android 7+?