tinylog icon indicating copy to clipboard operation
tinylog copied to clipboard

Tinylog doesn't seem to log on different thread on android

Open leschbenedikt opened this issue 1 year ago • 3 comments

Describe the bug I am occasionally getting an ANR on Android 13 which is caused by tinylog. The ANR log clearly shows that tinylog tries to write the log on the main thread although i've set the property writingthread to true.

For me this seem like a bug or am I doing something wrong?

Screenshot 2024-09-11 at 14 27 07 Screenshot 2024-09-11 at 14 23 06

To Reproduce Steps to reproduce the behavior: Hard to reproduce, happens randomly

Environment tinylog version: 2.7.0 Android Version: 13 Java version: 8

leschbenedikt avatar Sep 11 '24 12:09 leschbenedikt

The writing thread has to be enabled globally instead on a writer.

Just replace

writer2.writingthread = true

with

writingthread = true

pmwmedia avatar Jan 04 '25 00:01 pmwmedia

I tried this too, and it didn't seem to make any difference.

Therefore I looked into the code and I can't really find any code where an actual thread is created when the flag is set. I only find the part where the flag makes it not synchronized.

if (writingThread) { internalWrite(data); } else { synchronized (writer) { internalWrite(data); } }

Am I missing some code where an actual second thread is created or is that all setting writingThread does?

leschbenedikt avatar Jan 06 '25 09:01 leschbenedikt

The writing thread is created here: tinylog-impl/src/main/java/org/tinylog/core/TinylogLoggingConfiguration.java#L226

To be honest, I have never seen such error before. Is the screenshot everything you got?

pmwmedia avatar Jan 13 '25 18:01 pmwmedia