Quick answer: Unreal has a built-in hang detector, FThreadHeartBeat, and it is switched off by default: the engine ships HangDuration=0.0. Set HangDuration to 5 or more seconds under [Core.System] in Config/DefaultEngine.ini and a watchdog thread logs Hang detected on GameThread with the stuck callstack when the game thread stops sending heartbeats. It runs only in packaged, non-Debug builds with no debugger attached.

A crash leaves a report. A hang leaves a player staring at a frozen frame until they open Task Manager, and you get nothing: the crash handler never ran because nothing crashed. Unreal can catch these itself with a heartbeat watchdog, but the feature is disabled in the stock config and its settings are barely documented. This guide explains the mechanism, the ini keys and command-line switches that control it, the exact log output, how to exempt slow code, and how to investigate a freeze by hand. The details were checked against the UE 5.3 engine source (ThreadHeartBeat.cpp) and the UE 5.4 base config.

Crash, hang and hitch are three different failures

What the player seesWhat you get by default
CrashThe game closes, usually with the crash dialogA report folder with a minidump and log
HangA frozen frame, “Not Responding”, then a force closeNothing. The log stops mid-session
HitchA stall of a fraction of a second to a few seconds, then play continuesNothing, unless you profile

The line between a long hitch and a hang is whether the thread ever comes back. The engine draws it with a timeout.

How the engine’s hang detector works

FThreadHeartBeat is a singleton in the Core module. Once per frame, FEngineLoop::Tick calls FThreadHeartBeat::Get().HeartBeat() on the game thread, which stores a timestamp for that thread. A separate watchdog thread named FHeartBeatThread wakes every half second and compares each registered thread’s last timestamp with the current time. If the gap exceeds the configured hang duration, it captures that thread’s callstack from the outside and reports it.

Any thread that calls HeartBeat() is monitored. In the stock engine that is the game thread, plus the async loading code while it works. The render thread is covered by a separate check: when the game thread waits on a render fence for longer than g.TimeoutForBlockOnRenderFence (120000 ms by default) while the heartbeat is active, the engine raises the fatal error GameThread timed out waiting for RenderThread after N secs. That one is a real crash with a report, and it is how most game/render deadlocks surface.

Turning it on

All settings are read from the [Core.System] section of the engine ini, so they go in your project’s Config/DefaultEngine.ini (or a platform file such as Config/Windows/WindowsEngine.ini):

[Core.System]
HangDuration=25.0
HangsAreFatal=false
KeyStock valueMeaning
HangDuration0.0 in BaseEngine.iniSeconds without a heartbeat before a hang is reported. Zero disables the detector. Values between 0 and 5 are raised to 5 with a log warning.
HangsAreFatalfalseWhen true, the game shows a message box and exits after reporting.
StuckDuration1.0Seconds before a thread counts as “stuck”, which only fires the OnStuck delegate (used with the AttemptStuckThreadResuscitation console variable to boost thread priority). It produces no report.
PresentHangDuration0.0Seconds without a presented frame, on platforms that implement frame-present detection. Minimum 5.

The source has a comment saying the hang duration defaults to 25 seconds “if not overridden in config”, but Engine/Config/BaseEngine.ini does override it, with HangDuration=0.0, in both 5.3 and 5.4. The watchdog thread is only created when the configured value is above zero, so a project that never touched this key has no hang detection. Open that file in your engine version and search for HangDuration to see what you are starting from.

When the detector is inactive

Even with the key set, several conditions switch it off:

What happens when it trips

The watchdog writes the stuck thread’s stack to the log at Error verbosity:

LogCore: Error: Hang detected on GameThread (thread hasn't sent a heartbeat for 25.00 seconds):
LogCore: Error:   0x00007ff6a1b2c3d4 MyGame-Win64-Shipping.exe!UMySaveSubsystem::WaitForUpload() [...]
LogCore: Error:   0x00007ff6a1b2a1f0 MyGame-Win64-Shipping.exe!UMySaveSubsystem::Flush() [...]
...
LogCore: Error: Hang detected on GameThread:
  ...
Check log for full callstack.

On desktop platforms it then builds a crash context of type Hang, captures every thread’s context, and hands it to the Crash Report Client in unattended mode, so no dialog appears. Whether that report is uploaded depends on the same rules as any unattended report (in the 5.3 source the client is skipped in builds the engine flags as licensee versions), so treat the log as the dependable artifact and the report as a bonus. The same hang is reported once: the detector hashes the callstack and stays quiet until the thread or the stack changes.

By default the hang is not fatal. The process stays frozen, or recovers if the thread eventually returns. With HangsAreFatal=true, desktop builds flush the log, send the report, show a message box titled “Application Hang Detected” reading “The application has hung and will now close. We apologize for the inconvenience.” and exit. On other platforms a fatal hang becomes a Fatal log, which is an ordinary crash. Shipping builds have logging compiled out unless the target sets bUseLoggingInShipping; without it there is no log to read, as covered in capturing logs in Shipping builds.

Exempting code that is slow on purpose

Some game-thread work legitimately takes longer than the threshold: a blocking save migration, building a navmesh at load, a debug dump. Wrap it in FSlowHeartBeatScope, which suspends the heartbeat check for the current thread until the scope ends:

#include "HAL/ThreadHeartBeat.h"

void UMySaveSubsystem::MigrateOldSaves()
{
    FSlowHeartBeatScope SuspendHeartBeat;   // this thread only
    // FSlowHeartBeatScope SuspendAll(true); // every monitored thread

    for (const FString& Slot : LegacySlots)
    {
        ConvertSlot(Slot);
    }
}

The engine does this itself around commands such as memreport and obj list. Keep the scope tight; a scope around your whole loading function hides the hang you most want to hear about. FThreadHeartBeat::Get().SetDurationMultiplier() is the gentler tool when a phase is slow but should still time out eventually.

You rarely need a scope for asset loading. While the game thread flushes async loading, the loader sends heartbeats itself, so a twenty-second synchronous load is a terrible hitch but is not reported as a hang.

The hitch detector is a separate system

The same file contains FGameThreadHitchHeartBeat, which logs Hitch detected on gamethread (frame hasn't finished for N ms) when one frame exceeds a threshold. Its settings are GameThreadHeartBeatHitchDuration (-1.0, off), GameThreadHeartBeatStackWalk and GameThreadHeartBeatStartSuspended in [Core.System], or -hitchdetection=<seconds> and -hitchdetectionstackwalk on the command line. FDisableHitchDetectorScope suspends it. It is compiled in only when ALLOW_HITCH_DETECTION is defined as 1, and the default is 0, so in a stock engine those keys do nothing. For hitches, use stat unit, stat hitches and Unreal Insights, as described in catching freezes before your players do.

What causes real hangs in Unreal games

  1. The game thread waits on work that needs the game thread. Calling TFuture::Get(), FEvent::Wait() or waiting on a task graph event for a job that later dispatches back to the game thread. Nothing can ever complete.
  2. Lock ordering deadlocks. Two threads take the same two critical sections in opposite order. The hang stack shows the game thread inside FScopeLock; the other half of the story is on another thread, which is why the all-threads capture matters.
  3. Game and render thread deadlocks. A render command that blocks on game state while the game thread is in FlushRenderingCommands. This usually ends in the render fence fatal error.
  4. Infinite loops in C++. A while whose exit condition can no longer become true, a retry loop without a limit, a linked structure with a cycle. Blueprint loops are stopped separately by the script runaway check; see Blueprint infinite loop crashes.
  5. Blocking network or file calls on the game thread. A synchronous socket read or a wait on an HTTP request with no timeout, hit when the player’s connection drops.
  6. Synchronous loads and shader or PSO compilation. LoadObject, StaticLoadObject and FlushAsyncLoading on the game thread are the classic long hitches. They become true hangs only when the load is stuck on something else, such as a missing package dependency or a starved I/O thread.

Mobile: the OS is the watchdog

On phones the operating system does this job and is less patient. Android declares an ANR when the main thread does not respond to input for about five seconds, and iOS kills an app that blocks its main thread during launch or resume with the exception code 0x8badf00d. Neither goes through Unreal’s detector. See fixing ANRs in mobile games and 0x8badf00d watchdog terminations on iOS.

Investigating a hang without the detector

When you can reproduce the freeze, or a tester has it on screen right now:

  1. Attach a debugger and break. In Visual Studio, Debug > Attach to Process, then Break All, and open Debug > Windows > Parallel Stacks. Find the game thread and read what it is waiting on, then find the thread that holds it.
  2. Take a dump from Task Manager. On the Details tab, right-click the game’s process and choose Create dump file (Create memory dump file on Windows 11). This works on a player’s machine and needs no tools. Open the .dmp with the PDBs from that build.
  3. Use ProcDump for hangs you cannot predict. Sysinternals ProcDump can wait for the window to stop responding and write the dump itself:
    procdump -h -ma MyGame-Win64-Shipping.exe C:\dumps
  4. Record a trace. Run a non-Shipping build with -trace=default and open the session in Unreal Insights to see which scope the game thread entered and never left.

To test your setup, non-Shipping builds have console commands that hang on request: debug softlock (sleeps forever), debug infiniteloop (spins forever) and debug stall 30 (blocks the game thread for 30 seconds, then returns). Run one in a packaged Development build with HangDuration set and confirm the “Hang detected” lines appear in Saved/Logs.

Choosing a threshold

Five seconds is the floor the engine enforces, and it is too low for most games: level travel, first-run shader work and save migration on a slow disk will all trip it. Start at 20 to 30 seconds on desktop, play through every loading path in a packaged build on your slowest test machine, and read the log for false reports. Fix or scope each one before lowering the number.

Leave HangsAreFatal off for players unless you prefer a clean exit to a frozen window; a hang that would have recovered at second 31 becomes a lost session. On dedicated servers the trade is different: a short duration with fatal hangs lets your orchestrator restart a stuck instance without waiting for a human.

What Bugnet sees of a hang

A hard hang is a native freeze, and Bugnet does not capture those as stack traces or process the dump. It is also invisible to the crash-free session rate: a session the player force-closes never reports its end, so it stays open and is not counted as crashed. What does reach Bugnet is a hang the engine turns into a fatal error. The render fence timeout described above goes through FCoreDelegates::OnHandleSystemError, which the Unreal SDK hooks, so it is filed with the engine’s error message and recent log lines, and that session is marked as crashed. For everything else, the player who killed the game can describe what they were doing through the in-game ReportBug form on the next launch, with platform, GPU and game version attached. Setup is in the SDK docs.

Frequently asked questions

Does Unreal Engine detect hangs automatically?

Not with the stock configuration. The hang detector exists, but BaseEngine.ini sets HangDuration to 0.0, which disables it. Set HangDuration to 5 seconds or more in the Core.System section of your project’s DefaultEngine.ini to turn it on in packaged builds.

What does Hang detected on GameThread mean in an Unreal log?

The engine’s heartbeat watchdog saw that the game thread had not completed a frame for the configured HangDuration. The lines that follow are the game thread’s callstack at that moment, which shows the function it was stuck in.

Why is Unreal hang detection not working in the editor?

The hang detection code is compiled out of editor builds and Debug configuration builds, and it is disabled at runtime while a debugger is attached unless you pass -debughangdetection. Test it in a packaged Development or Shipping build.

Is a detected hang fatal in Unreal Engine?

No, not by default. The engine logs the stack and files a Hang report, and the process keeps running or stays frozen. Setting HangsAreFatal=true in Core.System makes the game show a message and exit after reporting.

How do I stop the hang detector firing during a long load?

Wrap the slow code in FSlowHeartBeatScope, which suspends the heartbeat check for the current thread until the scope ends, or raise HangDuration. Asset loading through the async loader already sends heartbeats while it flushes.

Search your engine’s BaseEngine.ini for HangDuration before assuming you have hang detection. In the stock config it is 0.0, which means off.