TExcelTAD
Home › Assets, Tools & Shipping › Crash Reporting

Crash Reporting

Most players who hit a crash don't report it; they quit and leave a review. A crash reporter inside the game sends you the report instead: the stack trace, the build version, the platform, and what the player was doing just before. With a few hundred players, crash reports turn "some people say it crashes" into "crash #3 affects 4% of sessions on build 1.4.2, in Inventory.Equip, mostly on AMD drivers".

What a crash reporter does

  1. Captures unhandled exceptions (managed C#, GDScript errors) and native crashes (a minidump: the threads' stacks and some memory at the moment of the crash).
  2. Adds context: build version, OS, GPU, memory, and breadcrumbs (the last log lines, scene loads, button presses).
  3. Uploads it on the next start or immediately, respecting the player's consent setting.
  4. Symbolicates native stacks: turns addresses like 0x7ff6a1c2e3f0 into Inventory::Equip (Inventory.cpp:212) using debug symbols you uploaded for that exact build (PDB files on Windows, dSYM on Apple platforms, IL2CPP line mapping for Unity).
  5. Groups reports with the same cause into one issue, by a stack signature (fingerprint), and counts them per version.

The options

Service Engines Notes
Sentry Unity (official SDK), Unreal (official plugin), Godot (official SDK), native C/C++ hosted or self-hosted; errors, crashes, performance
Backtrace (now part of Sauce Labs) Unreal (via Unreal's Crash Report Client), Unity, native, consoles strong on native crashes and minidumps
Unity Diagnostics Unity crash and exception reporting in the Unity Dashboard; in Unity 6.2+ it replaces the older Cloud Diagnostics, which Unity has deprecated
Unreal Crash Report Client Unreal collects crashes; send them to your own endpoint or a service via DataRouterUrl
Store dashboards Google Play Console (Android vitals), App Store Connect (Xcode Organizer) crashes and ANRs from the store's own reporting; no setup needed

Pricing and free tiers vary by event volume; check current plans.

Sentry in Unity

Install the package through the Package Manager with the Git URL https://github.com/getsentry/unity.git (append #<version> to pin a release). A Tools → Sentry window asks for your project's DSN and stores the options in Assets/Resources/Sentry/SentryOptions.asset; unhandled exceptions, native crashes and Debug.LogError calls are then captured automatically. You can add context and capture handled errors yourself:

csharp
using Sentry;
using UnityEngine;

public class LevelLoader : MonoBehaviour
{
    public void Load(string levelId)
    {
        SentrySdk.AddBreadcrumb(
quot;Loading level {levelId}"); SentrySdk.ConfigureScope(scope => scope.SetTag("level", levelId)); try { LoadInternal(levelId); } catch (System.IO.InvalidDataException e) { SentrySdk.CaptureException(e); // report it, then recover LoadInternal("hub"); } } void LoadInternal(string id) { /* ... */ } }

Backtrace with Unreal's crash reporter

Unreal's Crash Report Client can post to any compatible endpoint. Backtrace's documentation configures it with a [CrashReportClient] section in the engine config (a copy of DefaultEngine.ini placed in the crash reporter's config folder for packaged builds), using your Backtrace subdomain and submission token:

ini
[CrashReportClient]
CrashReportClientVersion=1.0
DataRouterUrl="https://unreal.backtrace.io/post/{subdomain}/{submission-token}"

Enable Include Crash Reporter in the project's packaging settings, and upload the build's symbol files to the service for every release (most services provide a CLI for this, which belongs in CI).

A runnable model: grouping by stack signature

The core of every crash service is grouping. Raw stack traces differ in addresses, line numbers, and engine frames above and below your code, so the service normalises each trace and hashes the result. Here is that idea on a handful of crash logs:

python · try it yourself
import hashlib
import re
from collections import defaultdict

LOGS = [
    ("1.4.2", "win", """NullReferenceException: Object reference not set to an instance of an object
  at Inventory.Equip (Item item) [0x00012] in Inventory.cs:212
  at InventoryUI.OnSlotClicked (int slot) [0x0003a] in InventoryUI.cs:88
  at UnityEngine.Events.InvokableCall.Invoke () [0x00010]"""),
    ("1.4.2", "linux", """NullReferenceException: Object reference not set to an instance of an object
  at Inventory.Equip (Item item) [0x00012] in Inventory.cs:214
  at InventoryUI.OnSlotClicked (int slot) [0x0003a] in InventoryUI.cs:88
  at UnityEngine.Events.InvokableCall.Invoke () [0x00010]"""),
    ("1.4.2", "win", """IndexOutOfRangeException: Index was outside the bounds of the array.
  at Spawner.NextWave () [0x00044] in Spawner.cs:57
  at Spawner.Update () [0x0001c] in Spawner.cs:31"""),
    ("1.4.1", "win", """NullReferenceException: Object reference not set to an instance of an object
  at Inventory.Equip (Item item) [0x00010] in Inventory.cs:209
  at InventoryUI.OnSlotClicked (int slot) [0x0003a] in InventoryUI.cs:85
  at UnityEngine.Events.InvokableCall.Invoke () [0x00010]"""),
    ("1.4.2", "mac", """NullReferenceException: Object reference not set to an instance of an object
  at SaveSystem.Write (SaveData data) [0x00002] in SaveSystem.cs:40
  at PauseMenu.OnQuit () [0x00008] in PauseMenu.cs:66"""),
]

FRAME = re.compile(r"^\s*at (?P<method>[\w.<>`]+) \(")
ENGINE_PREFIXES = ("UnityEngine.", "System.")

def signature(text, depth=2):
    lines = text.strip().splitlines()
    exc_type = lines[0].split(":")[0]
    frames = [m["method"] for m in map(FRAME.match, lines[1:]) if m]
    ours = [f for f in frames if not f.startswith(ENGINE_PREFIXES)][:depth]
    key = exc_type + "|" + "|".join(ours)        # no line numbers, offsets or engine frames
    return hashlib.sha1(key.encode()).hexdigest()[:8], exc_type, ours

groups = defaultdict(list)
for version, platform, text in LOGS:
    sig, exc, frames = signature(text)
    groups[(sig, exc, tuple(frames))].append((version, platform))

ranked = sorted(groups.items(), key=lambda kv: (-len(kv[1]), kv[0][0]))
for (sig, exc, frames), hits in ranked:
    versions = sorted({v for v, _ in hits})
    platforms = sorted({p for _, p in hits})
    print(f"[{sig}] {len(hits)}x {exc}")
    print(f"           in {' <- '.join(frames)}")
    print(f"           versions {', '.join(versions)}; platforms {', '.join(platforms)}")
[96e30f3f] 3x NullReferenceException
           in Inventory.Equip <- InventoryUI.OnSlotClicked
           versions 1.4.1, 1.4.2; platforms linux, win
[102b6ba1] 1x IndexOutOfRangeException
           in Spawner.NextWave <- Spawner.Update
           versions 1.4.2; platforms win
[22e49ed4] 1x NullReferenceException
           in SaveSystem.Write <- PauseMenu.OnQuit
           versions 1.4.2; platforms mac

Three of the five reports are one bug, even though their line numbers differ between builds and platforms, and the issue already existed in 1.4.1. The NullReferenceException in SaveSystem.Write has the same exception type but different frames, so it stays a separate issue. Real services add much more (symbolication, merging rules you can edit, regression detection when a "resolved" issue reappears in a new version), but the core is this function.

Rules for shipping with a crash reporter

  • Ask for consent where the law or platform requires it, and say in the privacy policy what you collect (Age Ratings & Privacy). Don't attach personal data, save files or screenshots without consent.
  • Upload symbols for every build in CI; a crash from a build without symbols is a list of hex addresses. Keep symbols out of the player download.
  • Tag every report with the full version string (Version & Build Numbers).
  • Watch the crash-free session rate per version after each release, and roll back or hotfix quickly if it drops.

Test yourself

What is symbolication?

  1. Compressing a minidump
  2. Turning raw addresses in a native stack into function names and lines using the build's debug symbols
  3. Grouping crashes
  4. Encrypting reports

Why does the grouping function drop line numbers and engine frames?

  1. To save space
  2. They differ between builds and platforms for the same bug, which would split one issue into many
  3. Engines hide them
  4. They are inaccurate

What does Unity's Diagnostics service replace in Unity 6.2 and later?

  1. The Profiler
  2. The deprecated Cloud Diagnostics crash and exception reporting
  3. Unity Analytics
  4. The Test Framework