---
title: "Replay"
description: "Box2D's new Replay system records a full binary snapshot of world state followed by opcodes and arguments for every API call, including steps, forces, impulses, body creation and queries with their callback results."
url: "https://swe.quest/articles/replay-cd1e00a39568cbbd"
canonical: "https://box2d.org/posts/2026/06/replay/"
source: "Box2D"
published: "2026-06-07"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 6
tags: ["gaming","debugging","c-cpp","data-structures"]
---

# Replay

A post on [Box2D](https://swe.quest/sources/box2d.md), published 2026-06-07, 6 min read, Deep dive. Original: [https://box2d.org/posts/2026/06/replay/](https://box2d.org/posts/2026/06/replay/)

## Summary

Box2D's new Replay system records a full binary snapshot of world state followed by opcodes and arguments for every API call, including steps, forces, impulses, body creation and queries with their callback results. Because the engine is deterministic across platforms and thread counts, a single snapshot plus the call log is enough to reproduce a user's bug in a live simulation. Per-step transform hashes validate that determinism. The Replay Viewer generates key frames at load time within a memory budget for fast scrubbing, and the snapshot/restore API is now exposed for rollback. Index-based handles, POD data in arrays and events instead of callbacks make serialization cheap, though friction mixing, filter and pre-solve callbacks are not yet recorded.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Games](https://swe.quest/tags/gaming.md) (Domains)
- [Debugging](https://swe.quest/tags/debugging.md) (Engineering practices)
- [C & C++](https://swe.quest/tags/c-cpp.md) (Languages)
- [Data structures](https://swe.quest/tags/data-structures.md) (Architecture & design)

## Prerequisites

- physics engine basics
- C programming
- deterministic simulation ([easy posts on Formal methods](https://swe.quest/tags/formal-methods.md?difficulty=easy))

## Keywords

Box2D, b2World\_Snapshot, Replay Viewer, b2Recording

## Related posts

- [Box2D 3.2](https://swe.quest/articles/box2d-3-2-6bf0b6359f7de39c.md): Box2D · 2026-10-18 · Easy · 2 min read · Games, Performance engineering, C & C++
  Box2D 3.2 runs roughly three times faster than 3.1, with the speedup broken down by source: contact recycling (~40%), solver algorithm refinement (~20%), AVX2 runtime dispatch (~15%), solver optimization (~10%) and broad-phase optimization (~10%), which compound multiplicatively.
- [We Put a Distributed Database In the Browser – And Made a Game of It!](https://swe.quest/articles/we-put-a-distributed-database-in-the-browser-and-made-a-game-of-it-0b24aa4c3e59c84b.md): TigerBeetle · 2023-07-11 · Easy · 5 min read · Formal methods, Consensus, Testing, WebAssembly, Zig
  TigerBeetle's deterministic simulator, the VOPR, is compiled to WebAssembly via Zig and wrapped in a playable browser game that runs real TigerBeetle replicas across three levels.
- [Memory snapshots: Checkpoint/restore for sub-second startup](https://swe.quest/articles/memory-snapshots-checkpoint-restore-for-sub-second-startup-543b0ee4c645204a.md): Modal · 2025-01-28 · Medium · 9 min read · Serverless, Containers, Sandboxing & isolation, Performance engineering, Linux
  Modal cuts serverless container cold starts roughly 2.5x by checkpointing a gVisor container's full process tree and filesystem mutations just before it accepts a request, then restoring it instead of re-running Python's syscall-heavy import path (import torch alone makes 26,000 syscalls through OverlayFS and a FUSE lazy-loading server).
- [GPU Memory Snapshots: Supercharging sub-second startup](https://swe.quest/articles/gpu-memory-snapshots-supercharging-sub-second-startup-14c07f765f85f384.md): Modal · 2025-07-30 · Medium · 6 min read · Serverless, Inference & serving, Hardware, Performance engineering
  Modal's GPU memory snapshots extend its gVisor-based checkpoint/restore to capture GPU state, using NVIDIA's new CUDA checkpoint API (driver branches 570/575) to lock CUDA processes, copy device memory, kernels, streams, contexts and memory mappings to host memory, then snapshot CPU and GPU state together.
- [Protocol-Aware Deterministic Simulation Testing](https://swe.quest/articles/protocol-aware-deterministic-simulation-testing-7f3b613be8faf2a6.md): TigerBeetle · 2026-08-20 · Hard · 10 min read · Formal methods, Testing, Consensus, Replication, Storage engines
  TigerBeetle's deterministic simulator (the VOPR) has full visibility into each replica's consensus and storage state, so it can check invariants that black-box tools like Jepsen or Antithesis cannot see through user-facing APIs.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
