firebase / firebase-unity-sdk

The Firebase SDK for Unity
http://firebase.google.com
Apache License 2.0
234 stars 38 forks source link

[Bug] Crashlytics stack traces containing async method frames are parsed with information loss #1132

Closed battleroy closed 1 month ago

battleroy commented 1 month ago

Description

Hello! Seems that there is an issue in Crashlytics stack trace capture.

Unity log prints stack traces like this: UnityEngine.StackTraceUtility:ExtractStackTrace () (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/StackTrace.cs:37) UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[]) UnityEngine.Logger:Log (UnityEngine.LogType,object) UnityEngine.Debug:Log (object) Logging.UnityLogHandler:HandleLog (Logging.LogLevel,string) (at Assets/_Scripts/Lib/Portable/Logging/UnityLogHandler.cs:62) Logging.Logger`1<Editor.IosBuildProcess>:Log (Logging.LogLevel,string) (at Assets/_Scripts/Lib/Portable/Logging/Logger.cs:21) Editor.IosBuildProcess:LogInfo (string) (at Assets/_Scripts/Editor/Build/IosBuildProcess.cs:180) Editor.IosBuildProcess/<RunAsync>d__9:MoveNext () (at Assets/_Scripts/Editor/Build/IosBuildProcess.cs:62) Editor.IosBuildProcess:RunAsync () Editor.IosBuildProcess/<RunVoidAsync>d__8:MoveNext () (at Assets/_Scripts/Editor/Build/IosBuildProcess.cs:54) Cysharphreading.Tasks.CompilerServices.AsyncUniTaskVoidMethodBuilder:Start<Editor.IosBuildProcess/<RunVoidAsync>d__8> (Editor.IosBuildProcess/<RunVoidAsync>d__8&) (at ./Library/PackageCache/com.cysharp.unitask@7c0f199fe0/Runtime/CompilerServices/AsyncUniTaskVoidMethodBuilder.cs:110) Editor.IosBuildProcess:RunVoidAsync () Editor.JenkinsBuild:PerformIosBuild () (at Assets/_Scripts/Editor/Build/JenkinsBuild.cs:31)

But when a crash from error/exception log appears in the console it looks like: ``<>c__DisplayClass17_0:b__0 (Project) Lib.ResultExtensions:TryHandleFailures (Lib)

d__15:MoveNext (Project) Cysharp.Threading.Tasks.UniTaskCompletionSourceCore`1:TrySetResult (Cysharp.Threading.Tasks) d__18:MoveNext (Project) Cysharp.Threading.Tasks.UniTaskCompletionSourceCore`1:TrySetResult (Cysharp.Threading.Tasks) Cysharp.Threading.Tasks.d__5:MoveNext (Cysharp.Threading.Tasks) Cysharp.Threading.Tasks.UniTaskCompletionSource`1:TrySignalCompletion (Cysharp.Threading.Tasks) GooglePlayGames.OurUtils.PlayGamesHelperObject:Update (GooglePlayGames.OurUtils)`` It seems like the Crashlytics stack trace exporter doesn't handle slashes from the original Unity stack trace. Unity version is 2022.3.15f1, Crashlytics version is 11.9.0. Looking forward to the conversation regarding the bug. Thanks ### Reproducing the issue _No response_ ### Firebase Unity SDK Version 11.9.0 ### Unity editor version 2022.3.15f1 ### Installation Method Unity Package Manager ### Problematic Firebase Component(s) Crashlytics ### Other Firebase Component(s) in use _No response_ ### Additional SDKs you are using _No response_ ### Targeted Platform(s) Android ### Unity editor platform Mac ### Scripting Runtime IL2CPP ### Release Distribution Type Pre-built SDK from https://firebase.google.com/download/unity ### Relevant Log Output _No response_ ### If using CocoaPods for Apple platforms, the project's Podfile.lock _No response_
google-oss-bot commented 1 month ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

argzdev commented 1 month ago

Hey @battleroy, thanks for reaching out. I noticed that you're using an older version of our SDK 11.9.0. Our latest version is currently 12.3.0, could you try upgrading to the latest version and see if you're still able to reproduce the same behavior? We normally recommend this in order to avoid issues that might've been fixed in the most recent updates. Also please note that there's a breaking change with versions 12+, this will require using Unity Editor versions 2022.3.43f1 or higher.

From your stacktrace, what I can see is that both Crashlytics and console provided different outputs. Could you explain more what you mean by:

It seems like the Crashlytics stack trace exporter doesn't handle slashes from the original Unity stack trace.

UnityEngine.StackTraceUtility:ExtractStackTrace () (
at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/StackTrace.cs:37) UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[]) UnityEngine.Logger:Log (UnityEngine.LogType,object) UnityEngine.Debug:Log (object) Logging.UnityLogHandler:HandleLog (Logging.LogLevel,string) (
at Assets/_Scripts/Lib/Portable/Logging/UnityLogHandler.cs:62) Logging.Logger`1<Editor.IosBuildProcess>:Log (Logging.LogLevel,string) (
at Assets/_Scripts/Lib/Portable/Logging/Logger.cs:21) Editor.IosBuildProcess:LogInfo (string) (
at Assets/_Scripts/Editor/Build/IosBuildProcess.cs:180) Editor.IosBuildProcess/<RunAsync>d__9:MoveNext () (
at Assets/_Scripts/Editor/Build/IosBuildProcess.cs:62) Editor.IosBuildProcess:RunAsync () Editor.IosBuildProcess/<RunVoidAsync>d__8:MoveNext () (
at Assets/_Scripts/Editor/Build/IosBuildProcess.cs:54) Cysharphreading.Tasks.CompilerServices.AsyncUniTaskVoidMethodBuilder:Start<Editor.IosBuildProcess/<RunVoidAsync>d__8> (Editor.IosBuildProcess/<RunVoidAsync>d__8&) (
at ./Library/PackageCache/com.cysharp.unitask@7c0f199fe0/Runtime/CompilerServices/AsyncUniTaskVoidMethodBuilder.cs:110) Editor.IosBuildProcess:RunVoidAsync () Editor.JenkinsBuild:PerformIosBuild () (
at Assets/_Scripts/Editor/Build/JenkinsBuild.cs:31)
<>c__DisplayClass17_0:<TryHandleFailures>b__0 (Project) Lib.ResultExtensions:TryHandleFailures (Lib) <RunInitIterationAsync>d__15:MoveNext (Project) 
Cysharp.Threading.Tasks.UniTaskCompletionSourceCore`1:TrySetResult 
(Cysharp.Threading.Tasks) <AuthenticateAsync>d__18:MoveNext (Project) Cysharp.Threading.Tasks.UniTaskCompletionSourceCore`1:TrySetResult 
(Cysharp.Threading.Tasks) Cysharp.Threading.Tasks.<RunTask>d__5:MoveNext 
(Cysharp.Threading.Tasks) Cysharp.Threading.Tasks.UniTaskCompletionSource`1:TrySignalCompletion 
(Cysharp.Threading.Tasks) GooglePlayGames.OurUtils.PlayGamesHelperObject:Update (GooglePlayGames.OurUtils)
battleroy commented 1 month ago

Hi! Thanks for reaching me out! In the sample that I've provided there are two different stack traces. The first one is just a random example from debug log in the editor, and the second is from the production issue from the Crashlytics console. This was my bad that I've not provided you with logs from the same place.

In the nearest time I'll try to log an exception to the editor console and to the Crashlytics to show the difference of stack traces that are provided in both cases.

But now you may that the difference between the console log stack trace (first one) and the Crashlytics stack trace that in the latter seems that class names are missing (e.g. d18:MoveNext instead of NameSpace.ClassName/d18:MoveNext like it was in the console log stack trace: Editor.IosBuildProcess/d__9:MoveNext).

And additionally I'll try to provide you with samples from the same place in code to show you the exact difference asap.

Thanks for the response. I'm always available to continue the discussion 🙏

battleroy commented 1 month ago

And surely I'll try to reproduce the issue with the latest library version.

battleroy commented 1 month ago

Hello again! I've just double checked if there a difference between the stack traces from the debug console output and from the Crashlytics dashboard, and turned out that the stack trace is wrong on the Unity console log side already 🥴 Sorry for confusion. I think that I should try to find the Unity version where IL2CPP stack traces are better than in my current version.

argzdev commented 1 month ago

No worries, @battleroy. Thanks for getting back to us with these details, and we're glad you were able to figure out the problem.