Mirror
Mirror copied to clipboard
ThreadLog captures and writes out non-mirror related logs
We're seeing debug-error messages coming from our app code that have Mirror at the bottom of the stack-trace.
eg.
<correct stack trace begins here>
Mirror.ThreadLog:OnLateUpdate()
Mirror.NetworkLoop:NetworkLateUpdate()
The messages are also duplicated, we'll also get another one with correct stack trace. eg.
Test Thread Log
UnityEngine.Debug:LogError (object)
UniTaskMirrorTest/<>c:<Test>b__0_0 () (at Assets/#Project/Scripts/UniTaskMirrorTest.cs:11)
System.Threading._ThreadPoolWaitCallback:PerformWaitCallback ()
And mirror will produce
[T3029] Test Thread Log
UnityEngine.Debug:LogError (object)
UniTaskMirrorTest/<>c:<Test>b__0_0 () (at Assets/#Project/Scripts/UniTaskMirrorTest.cs:11)
System.Threading._ThreadPoolWaitCallback:PerformWaitCallback ()
UnityEngine.Debug:LogError (object)
Mirror.ThreadLog:OnLateUpdate () (at Assets/Mirror/Core/Threading/ThreadLog.cs:97)
Mirror.NetworkLoop:NetworkLateUpdate () (at Assets/Mirror/Core/NetworkLoop.cs:206)
It seems to be down to how ThreadLog
attaches itself as a log-handler for threaded messages in Mirror.ThreadLog.Initialize
via
Application.logMessageReceivedThreaded += OnLog;
And then pumps the logs out in Mirror.ThreadLog.OnLateUpdate
- which is why we're seeing them with Mirror stack-trace alongside out normal threaded logging.
Repro
- Create app logger that attaches to
Application.logMessageReceivedThreaded += HandleLog;
- Add following behaviour
public class UniTaskMirrorTest : MonoBehaviour
{
void Start()
{
Task.Run(() =>
{
Debug.LogError("Test Thread Log");
});
}
}
- Build and run
- Mirror logger and custom-app logger will print error
Expected behavior I'd expect Mirror ThreadLog to only log its own messages
Desktop (please complete the following information):
- OS: Windows
- Build target: Standalone
- Unity version: 2022.1.23
- Mirror branch: v83.2.1