firebase / firebase/firebase-unity-sdk

[Bug] Unity App freezes for several seconds to minutes when an exception with a large stacktrace occurs with Crashlytics running

Open
#864 8 comments 0 reactions 0 assignees View on GitHub
api: crashlytics needs-attention type: question
Dominant language
C#
Stars
320
Forks
60
Avg merge
13h 32m
Merged PRs (30d)
13

Description

### [REQUIRED] Please fill in the following fields:

* Unity editor version: 2021.3.21f1
* Firebase Unity SDK version: 11.4.0
* Source you installed the SDK: .unitypackage
* Problematic Firebase Component: Crashlytics
* Other Firebase Components in use: Analytics
* Additional SDKs you are using: None
* Platform you are using the Unity editor on: Windows
* Platform you are targeting: iOS, Android
* Scripting Runtime: il2cpp
* Pre-built SDK from the [website](https://firebase.google.com/download/unity)

### [REQUIRED] Please describe the issue here:

I would like to re-open issue #563. We appear to be encountering the issue described there, which appears to have been closed without any resolution. As described in that ticket:

> Crashlytics increases the time a Unity app freezes when handling an uncaught exception by several orders of magnitude.

I could retype and redescribe everything in that ticket but it feels a bit wasteful to do so.

I cloned the repo mentioned in the original ticket and updated Firebase to v11.4.0. I also modified the scene and added a button that does a try/catch to see how handled exceptions that still log the error behaves. The only additional information I can add is that even the TryCatch causes the freeze even though I am not explicitly logging it to Crashlytics. It does, however, only behave this way when Crashlytics is initialized which would seem to indicate that Crashlytics is still the problem.

#### Steps to reproduce:

The steps described in the original ticket still apply:

1. Open the [crashlytics-issue-repro project](https://github.com/FodderMK/crashlytics-issue-repro) in Unity 2021.3.21f1
2. Import your own `google-services.json`
3. Ensure scripting backend is set to IL2CPP
4. Build and run on any Android phone. The issue is much more visible on slightly older phones.
5. After the app starts, press the "Freeze for 3 Seconds" button as a calibration test. This simply invokes `Thread.Sleep(3000)`, so the resulting text should show a freeze of around 3 seconds.
6. Press the three "Throw" buttons in sequence. "Throw (Simple Stack)" and "Throw (Many Threads)" should be very fast, while "Throw (Async Stack)" could lead to a short freeze.
7. Press the "Initialize Firebase" button. Crashlytics is now running.
8. Press the three "Throw" buttons in sequence. "Throw (Simple Stack)" and "Throw (Many Threads)" should now take several seconds (depending on device), while "Throw (Async Stack)" and "Throw (Async Stack TryCatch)" should lead to a very long freeze (almost 30 minutes on the Huawei device).

Downloadable Repro Project: https://github.com/FodderMK/crashlytics-issue-repro

Contributor guide

Open the contributing guide

Research direction

Start with the downloadable crashlytics-issue-repro project in Unity 2021.3.21f1, using IL2CPP and an imported google-services.json. Run the listed calibration and Throw-button sequence before and after pressing Initialize Firebase, comparing freeze durations on Android. Done means the reported long freezes are reproduced, explained, and no longer occur with Crashlytics initialized.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, csharp, ios, unity
Domain
game-dev, mobile-dev, observability-sre
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.