Summary
On Web (Wasm) builds, the trace header’s start time and the timestamps of every traced event come from two different clocks. Both run at 1 MHz, but their zero points differ by the Unix time of the run, so Unreal Insights places every event about 1.8 billion seconds before the session starts. Insights crashes on the trace, or, with RenderTraceInsights disabled, shows a multi-year session and drops most CPU scopes.
What Type of Bug are you experiencing?
Foundation (C++ Tools, Profiling, & Pipeline)
Steps to Reproduce
- Package any project for Web, Development configuration.
python Engine/Platforms/Wasm/Build/Tools/web/webrun.py run --stage <stage dir> --fixture idle --out <dir> --insights- Unzip
session.utrace.gzand open it in Unreal Insights 5.9.
Expected Result
A timeline that starts near 0 s, with game thread, render thread and frame events.
Observed Result
- Ensure:
Cycle >= ThreadState.LastCycle(TraceServices, CpuProfilerTraceAnalysis.cpp line 780) - Then a crash in the RenderTraceInsights analyzer:
Assertion failed: Time >= InsertionState.LastTime(MonotonicTimeline.h line 1196),Time=-1795359530.67 LastTime=-1.0 - With
-DisablePlugins=RenderTraceInsights, analysis completes, but the session duration shows as 3286 days, CPU scopes with metadata (SceneRender, the render thread’s Frame, ParallelDraw) are missing, and timer statistics for any time window are dominated by engine startup scopes.
Affects Versions
5.9
Platform(s)
Windows
Additional Notes
Engine/Platforms/Wasm/Source/Runtime/TraceLog/Private/Trace/Detail/Wasm/WasmTrace.cpp:
TRACELOG_API uint64 TimeGetTimestamp()
{
// Must stay in sync with FPlatformTime::Cycles64() (WasmPlatformTime.h) or the timeline breaks
return static_cast<uint64>(emscripten_get_now() * 1000.0);
}
This is microseconds since the Unix epoch. It sets GStartCycle, so the trace’s StartCycle.
Engine/Platforms/Wasm/Source/Runtime/Core/Public/WasmPlatformTime.h:
/** Microseconds since the first time query (SecondsPerCycle64 is 1e-6) */
static inline uint64 Cycles64()
{
return static_cast<uint64>(GetMillisecondsSinceOrigin() * 1000.0);
}
This is microseconds since the engine’s first time query. It stamps CPU profiler scopes, frame events, log messages and RenderTrace timestamps.
The two are no longer in sync, as the comment warns. The offset between them is the Unix time of the run, which matches the -1,795,359,530 s in the assertion.
Suggested fix
Have TimeGetTimestamp use the same zero point as Cycles64 (subtract the same origin, or share one origin between them). We’re on the Launcher build, so we haven’t been able to test this change.
Confirmation
Re-timing the events from a zero base, ignoring StartCycle, gives a consistent timeline in our own trace decoder: 31.5 fps (the page measured 31.25), 2,518 frames in an 80 s window, and log message times that match the browser console at a constant offset of about 1.01 s across the whole 375 s run. No unwrapping or rescaling is needed.
Happy to share a trace on request.