firebase / quickstart-unity

Firebase Quickstart Samples for Unity
https://firebase.google.com/games
Apache License 2.0
819 stars 424 forks source link

[Bug] ANR traces are not symbolicated #1280

Open AntonPetrov83 opened 2 years ago

AntonPetrov83 commented 2 years ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the issue here:

I can see my ANR in the Crashlytics but it is not symbolicated: image

As a text: image

Steps to reproduce:

It is 100% reproducible.

  1. I am building the game locally;
  2. Then I upload symbols using Firebase CLI and it works as expected: Crashlytics symbol file uploaded successfully;
  3. Then I run the game and generate an ANR making an infinite loop in the main thread.
  4. I see my ANR report in the Firebase Crashlytics but it is not symbolicated.

The interesting part:

I used Unity's Stacktrace Utility (comes with Android Logcat package) to symbolicate this stack trace using the same symbols I uploaded earlier to Crashlytics and it works as expected: image

Under the hood this utility uses addr2line so I guess this proves that this trace definitely can be symbolicated!

paulinon commented 2 years ago

Hi @AntonPetrov83,

Thanks for reporting this issue. Version 9.0.0 of the SDK has been released recently. Could you verify if this version makes any difference? Otherwise, please provide a minimal, reproducible example of your implementation along with the complete steps to reproduce the issue so that we can identify what's causing this behavior.

AntonPetrov83 commented 2 years ago

Hi @paulinon,

I have upgraded Firebase Crashlytics to 9.0.0, I have upgraded Firebase CLI to 11.0.0, I have successfully uploaded symbols and triggered an ANR - still nothing :(

image

UPDATE:

So, it is 100% reproducible.

  1. Take the test app quickstart-unity/crashlytics/testapp and open it with Unity 2020.3.32f1 (LTS);
  2. Follow general setup instructions to enable Crashlytics in Firebase Console;
  3. Modify UIHandler.cs to add new "Trigger ANR" button like this:

    public void TriggerAnr() {
      DebugLog("Triggering an ANR. Wait for system popup and Close the App");
      AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
      AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
      activity.Call("runOnUiThread", new AndroidJavaRunnable(InfiniteLoopOnMainThread));
    }
    
    void InfiniteLoopOnMainThread() {
      while (true) ;
    }
    
    void GUIDisplayControls() {
      ...
        if (GUILayout.Button("Trigger ANR")) {
          TriggerAnr();
        }
      ...
    }
  4. Build Android build with "Create symbols.zip" enabled;
  5. Upload symbols using Firebase CLI;
  6. Run the app, trigger an ANR, wait for ANR dialog and close the app;
  7. Run again to send crashlytics;
  8. See the bug: image
paulinon commented 2 years ago

Thanks for the additional information, @AntonPetrov83. I've replicated the issue using the steps you provided, and I'll relay this to the team. I also noticed that the ANR isn't reported when it's coming from a device with a lower Android version (in my case, Android 9).

I'll be marking this as a bug for now, but you may refer to this thread for updates.

samedson commented 2 years ago

Hey @AntonPetrov83, right now Crashlytics isn't able to symbolicate ANRs, but we are working on it. I don't have a TBD yet but will update here when we get it released.

khambadkone commented 1 year ago

@paulinon There was an announcement at the Games Developer Summit that symbolication of native Android ANRs is now supported. Wouldn't it solve this issue ? What version of Crashlytics has this support?