DEV Community

DDW-X
DDW-X

Posted on

Decompiling activetheory.net: Zero-GC Memory Management & GPGPU Particle Systems

Architectural deep-dives of high-end WebGL engines rarely surface in production quality due to proprietary bundling and obfuscation. Over the past several months, I conducted an end-to-end systems deconstruction and 1:1 architectural reverse engineering of the runtime driving activetheory.net.

Instead of surface-level de-minification, this research focuses on the mechanics of zero-allocation memory footprints in V8, Eulerian Navier-Stokes particle advection, and offscreen floating-point GPGPU pipelines.


1. Eliminating the V8 Garbage Collector: Zero-GC Runtime

The primary bottleneck in sustained 120 FPS WebGL rendering is JavaScript Heap fragmentation and transient object allocation inside the frame loop. When minor Garbage Collection sweeps trigger, the browser thread drops frames.

Classic WebGL Loop:
Render Frame -> new Vector3() -> Nursery Allocation -> GC Minor Pause (3-8ms) -> Frame Drop

Active Theory Architecture:
Render Frame -> Static Scratchpad Pools (_v1, _v2) -> Mutate in-place -> Flat Heap Line (0 KB churn)

The runtime enforces a strict allocation invariant:

  • Pre-allocated Scratchpads: Scratch math structures (_v1, _m1) handle all coordinate spaces and matrix multiplications without ephemeral instantiations.
  • Monomorphic Shapes: Object structures are populated in fixed constructor orders, preventing V8 hidden class (Map) transitions and de-optimizations.
  • TypedArray Direct Transfer: Uniform buffers and attribute updates bypass JavaScript wrappers entirely, mapping contiguous memory straight to WebGL vertex attributes.

2. Antimatter: Offscreen GPGPU Particle Pipeline

Rather than computing particle physics on the CPU and uploading buffers per-frame, the engine employs the Antimatter GPGPU subsystem:

  • Triple-Buffered FBO Topology: Particles exist entirely as pixels in 32-bit floating-point textures (OES_texture_float).
  • Vertex-Fetch Physics: In the vertex shader pass, point primitives sample their world coordinates directly from the updated FBO render targets using texture2D(u_positionTexture, uv).
  • Zero CPU Overhead: The main thread's only role is binding ping-pong textures and submitting draw commands, decoupling physics overhead from CPU clock availability.

3. Real-Time Fluid Coupling: Eulerian Navier-Stokes

Pointer-driven particle interaction uses an offscreen Eulerian grid to simulate fluid currents:

  1. Velocity Advection: Semi-Lagrangian back-tracing transports velocity across an FBO grid.
  2. Impulse Injection: Pointer deltas are translated into localized directional splats injected directly into the velocity buffer.
  3. Jacobi Pressure Projection: A 6-pass Jacobi relaxation solver computes the pressure Poisson equation, subtracting the gradient to enforce $\nabla \cdot \mathbf{u} = 0$ (incompressibility).
  4. Advection Feedback: The resulting velocity vector field is sampled inside the Antimatter compute pass, dragging millions of particles along fluid streamlines.

Telemetry & Technical Documentation

The complete architectural teardown, including mathematical proofs, GLSL noise kernel deconstructions, and V8 heap flatline verification traces, has been documented in detail:

Critique, engine profiling observations, and low-level graphics discussions are welcome in the comments.

Top comments (0)