Angel Miranda

NFSU: reconciliation log

Forensic log + changelog · updated November 2026 (v2: 57c6aee..HEAD)

Full forensic audit and reconciliation changelog for nfsu.cc. Read the build overview first in How I put NFSU in a browser tab. Jump to: Changelog v2 — Mobile survival, WebGL 2 pooled tape & forensic pass (latest) · Changelog v1 — 1.47 GB gpu.js GC & WebGL 2 cache traps.

Changelog v2 · Mobile RAM, cold boot, WebGL 2 pooled tape & forensic reconciliation (latest)

Across commits 31c1167, 8cbf571, d6ef04c, e79e9d2, and the final forensic cleanup, we halved WASM memory, parallelized cold boot, closed car-streaming gaps, made GPU shaders lazy, capped an uncapped 375 fps loading-screen loop, replaced per-draw WebGL 2 closures with a pooled command tape, fixed the last native C build guard, and verified live Cloudflare R2 parity against local dist/ — without cutting a single song from the 2003 soundtrack.

2048 → 1024 MBWASM linear memory; live wasm break dropped 1,548 → 585 MB
6.0 GB → 1.0 GBSafari/WebKit WebGPU race peak at 91 s (0 HUNG, 0 STOP)
4.0 GB → 1.5 GBSafari/WebKit WebGL 2 at 90 s (-62.5%, 30.0 fps, pooled tape)
28/28 & 375all host/*.c pass native clang; 375 patches, 0 overlaps

2.1 · Memory budget: halving WASM RAM before frame 1

Mobile Safari kills tabs once process footprint crosses ~1.5 GB. Previously, speed.wasm reserved a 2 GB fixed SharedArrayBuffer at boot, mapped 1 GB of flat guest address space, and allocated 16 MB stacks across 12 pthread workers — burning RAM before the title screen even drew.

AllocationBeforeAfterSource (file:line)
WASM linear memory2,048 MB1,024 MBtools/recomp/build.py:183 (-sINITIAL_MEMORY=1024MB)
Guest address space1,024 MB384 MBhost/host.h:11 (GUEST_MEM=0x18000000u; measured use ~52 MB)
Thread stacks16 MB × 124 MB × 9tools/recomp/build.py:183, host/threads.c:285 (192 → 36 MB)
Boot worker pool12 workers9 workerstools/recomp/build.py:184 + RN_NPRE=2 on mobile
Live wasm break (Chrome)1,360–1,548 MB585 MBVerified via webcheck.mjs --route (45 MB heap, 7 MB virtual)

In plain termsImagine renting a 2-gigabyte warehouse to store 52 megabytes of boxes, when the landlord evicts anyone using more than 1.5 gigabytes. Shrinking the reservation to 1 GB and guest memory to 384 MB kept the exact same game and audio intact while cutting real WASM footprint by nearly a gigabyte.

2.2 · Cold boot, car chunks & immutable R2

  • Parallel boot: web/boot.js downloads pc/Speed.exe in parallel with streaming out/speed.wasm compilation via Promise.all.
  • Car chunk coverage: Added 99 rows to census/data_chunks.tsv (217 total). dist/data-chunks/ now holds 454 gzipped pieces (273.40 MB from 505.2 MB source), reducing missed /Cars/ Range 206s in the cold trace to 0.
  • Mobile throttling & CDN: Cached the overlay HEAD response in host/trackfiles.c:63-66; phones pass RN_NPRE=2 (host/files.c:313-318) and cap rival prefetch to 5 cars (host/rivals.c:58-60). tools/upload_r2.sh gzips Speed.exe and sets Cache-Control: public, max-age=31536000, immutable on data-chunks/, game/, and pc/Speed.exe.

2.3 · Mobile GPU: lazy shaders & 540p WebGL 2 cap

TrackFilesChange & verified effect
Lazy shadersweb/gpu.jsMoved 6 optional shader/pipeline groups (FXAA, CAS, Bloom, PS, Skinning, Mipmap) behind lazy getters. Boot shaderModules 7 → 1 (clearShader only), renderPipelines 7 → 0.
WebGL 2 mobile capweb/mode.js, web/boot.jsOn mobile + WebGL 2 fallback, defaults CAS sharpening to off (unless ?sharp= is explicitly passed) and caps backbuffer from 1280×720 → 960×540 (44% fewer pixels).
DXT1/3/5 audithost/d3d9.c:1536-1618CPU-decoded to RGBA8 in decode_texels(); native BCn is not viable on mobile WebGL 2 (ASTC/ETC2 chips). Safe 512 px hook documented in upload_level() skipping 1,135 HUD/FE keys.

2.4 · Safari/WebKit Race Footprint Gate (WebGPU & WebGL 2)

Two WebGL 2 root causes were caught and eliminated back-to-back: (1) an uncapped ~375 fps loading-screen loop in PC_Loading.fng fixed by a universal 60 fps ceiling in host/d3d9.c:787-814 (d6ef04c), and (2) ~66k/s per-draw closures and .slice()/.map() copies in web/webgpu_gl.js replaced by a pooled flat command tape and reusable per-device replay state (e79e9d2; glcheck 13/13 original, 17/17 remaster).

Run (Playwright WebKit + footprint -p)Race HUDMenusRace footprintStabilityResult
Baseline WebGPU (before)reached855 MB6,000 MB @ 88 skilled by OSFAIL
Baseline WebGL 2 (before)reached970–1,800 MB9,000 MBkilled by OSFAIL
WebGPU (8cbf571)25.9 s599–612 MB1,006 MB @ 91 s0 HUNG, 0 STOPPASS ≤ 1.5 GB
WebGL 2 before pacer fixnever reached~1,200 MB5,538 MB @ 66 s7 HUNG, killedFAIL (375 fps)
WebGL 2 after pacer fix (d6ef04c)29.15 s653–1,439 MB2,009 → 4,032 MB @ 91 s0 HUNG, 0 STOPFixed load crash
WebGL 2 + pooled tape (e79e9d2)27.70 s656–717 MB1,078 → 1,513 MB @ 90 s (-62.5%)0 HUNG, 0 STOP, 30.0 fpsPASS (~1.5 GB)

In plain termsFirst, the loading screen was painting a static progress bar 375 times per second and drowning Safari before the race even started. Then, during racing, the WebGL 2 wrapper created two tiny JavaScript functions and three temporary arrays on every single draw call — 66,000 times a second. Replacing those with a reusable flat tape cut 90-second WebGL 2 memory from 4.03 GB down to 1.51 GB at a locked 30 fps.

2.5 · Final forensic reconciliation (5-layer check)

LayerAudit resultAction taken
C Host (host/*.c)host/files.c:406-410 (track_drop()) sat outside #ifdef __EMSCRIPTEN__, breaking native clangGuarded track_drop() under #ifdef __EMSCRIPTEN__; now 28/28 host/*.c pass native clang -fsyntax-only
Binary & LifterSpeed.exe MD5 b6b9232c55376b3c38c56aac1f8a121d verified; 13,764 lifted functions (0 failed); 375 active patches, 0 overlapsVerified clean
Web JS (web/*.js)20/20 scripts pass syntax check; glcheck 13/13 original & 17/17 remasterVerified clean
dist/ vs Live R2dist/manifest.json = 5,677 files / 2,100.33 MB (1.956 GiB); live nfsu.cc byte-for-byte MATCH on boot.js, gpu.js, webgpu_gl.js, mode.js, data-chunks.jsonReconciled stale 5,589 count in plan.json step 2 row 3
Git & Worktrees3 dead prunable worktrees left from retired UG2 slicesRan git worktree prune; active branches kept untouched

Changelog v1 · 1.47 GB gpu.js GC churn, WebGL 2 cache traps & dead mc.c hook

Earlier forensic audit after retiring the UG2 world mode and shipping the initial WebGL 2 fallback (57c6aee):

1,472 MBthrowaway JS allocations in 12 s of racing inside web/gpu.js
4 fixesstate-cache & context-loss traps closed in web/webgpu_gl.js
377 → 375active binary patches after retiring host/mc.c & cave 0x797600
3 driftsplan.json string boolean, orphaned HANDOFF.md SHAs & manifest count fixed

1.1 · web/gpu.js — 1.47 GB of per-draw GC churn

An iPhone XR froze on the live site. WebKit malloc_history attributed 5.4 GB of the process footprint to the JS heap (JSC/bmalloc). Chrome's sampling heap profiler over 12 seconds of racing (logs/ch_hp3.heap.json) captured 2,112.9 MB of short-lived JS allocations; 69.7% (1,472.2 MB) came from runList (968.9 MB), pipeline (280.9 MB), and sampler (222.4 MB).

// web/gpu.js — before: allocated on every GPU_DRAW (hundreds per frame)
const key = [g(D_VS), g(D_PS), g(D_DECL), stride, g(D_TOPO), ds, ...].join(',');
pass.setBindGroup(0, uBind, [uoff]);
const entries = []; // built with 3 objects per texture even on cache hit

// after: zero-alloc Map tries, packed 28-bit sampler key, hoisted tuples
const pl = pipeline(w, a, stride, rt.sc || 1);  // vs._pipes → ps → decl → entry[] + tag
UOFF_ARR[0] = uoff; pass.setBindGroup(0, uBind, UOFF_ARR);
let bg = findTexBind(ps.texMask, w, a);         // entries[] allocated only on miss

Reconciled. samplerFrom(w, to) packs all six sampler fields into one 28-bit integer key; pipeline() uses a nested Map trie with an integer fast-reject tag; runList tracks pass targets, viewports and scissors as scalars and hoists UOFF_ARR and BF_ARR.

1.2 · web/webgpu_gl.js — four state-cache traps

SiteFailure modeFix
skipSameStateCached GL enables, blend state and bindings persisted after GPU context lossAdded gl._resetSameState() hooked to webglcontextlost and webglcontextrestored
colorSamplerForCached on samp._rnColor with no device scope or descriptor validationMoved to a WeakMap on device._colorSamplerBySamp verifying all 6 sampler fields
texBindingKeyed by index * 4096 + binding; collides whenever binding >= 4096Replaced with a nested Map (index → binding) scoped by program link version
ulocCached WebGLUniformLocations survived gl.linkProgramWrapped gl.linkProgram to clear p._ul and increment p._linkVer

1.3 · host/mc.c & state drift

Reconciled. Retired the dead pedestrian detour at Speed.exe:0x4479be / cave 0x797600 (host/mc.c, host/mc.h, tools/recomp/patches_mc.py moved to attic/mc/; active patches 377 → 375). Fixed "done": "False" string boolean in plan.json row 11 and orphaned pre-rewrite SHAs in HANDOFF.md.

Links: repo · How I put NFSU in a browser tab · nfsu.cc

Auditoría forense completa y changelog de reconciliaciones de nfsu.cc. Lee primero la historia general en Cómo metí NFSU en una pestaña del navegador. Ir directo a: Changelog v2 — Supervivencia móvil, cinta pooled en WebGL 2 y pasada forense (más reciente) · Changelog v1 — 1.47 GB de GC en gpu.js y trampas de caché en WebGL 2.

Changelog v2 · RAM móvil, arranque rápido, cinta pooled en WebGL 2 y reconciliación forense (más reciente)

A lo largo de los commits 31c1167, 8cbf571, d6ef04c, e79e9d2 y la limpieza forense final, partimos a la mitad la memoria WASM, paralizamos el arranque en frío, cerramos huecos de streaming de autos, volvimos perezosos los shaders de GPU, pusimos techo a un ciclo sin freno de 375 fps en la pantalla de carga, reemplazamos los closures por draw en WebGL 2 por una cinta plana reutilizable, cerramos el último guard nativo en C y verificamos paridad byte a byte contra Cloudflare R2 — sin quitar ni una canción del soundtrack de 2003.

2048 → 1024 MBmemoria lineal WASM; wasm break real bajó 1,548 → 585 MB
6.0 GB → 1.0 GBpico en carrera en Safari/WebKit WebGPU a 91 s (0 HUNG, 0 STOP)
4.0 GB → 1.5 GBSafari/WebKit WebGL 2 a 90 s (-62.5%, 30.0 fps, cinta pooled)
28/28 y 375todos los host/*.c pasan clang nativo; 375 parches, 0 traslapes

2.1 · Presupuesto de memoria: partir a la mitad la RAM WASM antes del cuadro 1

Safari en iOS mata la pestaña cerca de 1.5 GB de huella. Antes, speed.wasm reservaba un SharedArrayBuffer fijo de 2 GB al arrancar, mapeaba 1 GB de espacio plano para el juego y daba stacks de 16 MB a 12 workers — quemando RAM antes de dibujar siquiera la pantalla de título.

ReservaAntesDespuésEvidencia (archivo:línea)
Memoria lineal WASM2,048 MB1,024 MBtools/recomp/build.py:183 (-sINITIAL_MEMORY=1024MB)
Espacio plano guest1,024 MB384 MBhost/host.h:11 (GUEST_MEM=0x18000000u; uso real ~52 MB)
Stacks de hilos16 MB × 124 MB × 9tools/recomp/build.py:183, host/threads.c:285 (192 → 36 MB)
Pool de workers al boot12 workers9 workerstools/recomp/build.py:184 + RN_NPRE=2 en celular
wasm break real (Chrome)1,360–1,548 MB585 MBVerificado con webcheck.mjs --route (45 MB heap, 7 MB virtual)

En simpleImagina rentar una bodega de 2 gigabytes para guardar 52 megabytes de cajas, cuando el casero desaloja a cualquiera que ocupe más de 1.5 gigabytes. Bajar la reserva a 1 GB y el espacio del juego a 384 MB dejó intactos el juego y toda su música, recortando casi un gigabyte real de huella WASM.

2.2 · Arranque en frío, chunks de autos y R2 inmutable

  • Arranque en paralelo: web/boot.js descarga pc/Speed.exe en paralelo con la compilación streaming de out/speed.wasm mediante Promise.all.
  • Cobertura de chunks de autos: Se agregaron 99 filas a census/data_chunks.tsv (217 en total). dist/data-chunks/ ahora guarda 454 piezas gzip (273.40 MB desde 505.2 MB originales), bajando a 0 los Range 206 crudos de /Cars/ en la traza en frío.
  • Control móvil y CDN: Se cacheó el HEAD de overlay en host/trackfiles.c:63-66; en celular se pasa RN_NPRE=2 (host/files.c:313-318) y se limita el prefetch de rivales a 5 autos (host/rivals.c:58-60). tools/upload_r2.sh sube Speed.exe comprimido con gzip y marca Cache-Control: public, max-age=31536000, immutable en data-chunks/, game/ y pc/Speed.exe.

2.3 · GPU móvil: shaders perezosos y tope 540p en WebGL 2

FrenteArchivosCambio y efecto verificado
Shaders perezososweb/gpu.jsSe movieron 6 grupos opcionales (FXAA, CAS, Bloom, PS, Skinning, Mipmap) a getters bajo demanda. Al arrancar startGpu(): shaderModules 7 → 1 (solo clearShader), renderPipelines 7 → 0.
Tope WebGL 2 móvilweb/mode.js, web/boot.jsEn móvil con respaldo WebGL 2, CAS arranca en off (salvo ?sharp= explícito) y el backbuffer baja de 1280×720 → 960×540 (44% menos píxeles).
Auditoría DXT1/3/5host/d3d9.c:1536-1618Decodificado en CPU a RGBA8 en decode_texels(); BCn nativo no es viable en WebGL 2 móvil (chips ASTC/ETC2). Punto seguro de tope 512 px documentado en upload_level() saltando 1,135 llaves HUD/FE.

2.4 · Gate real en Safari/WebKit (WebGPU y WebGL 2)

Se atraparon y cerraron dos causas raíz consecutivas en WebGL 2: (1) un ciclo sin freno de ~375 fps en PC_Loading.fng corregido con un techo universal de 60 fps en host/d3d9.c:787-814 (d6ef04c), y (2) ~66k/s closures por draw y copias .slice()/.map() en web/webgpu_gl.js reemplazados por una cinta plana reutilizable de comandos y estado de replay por device (e79e9d2; glcheck 13/13 original, 17/17 remaster).

Corrida (Playwright WebKit + footprint -p)HUD carreraMenúsHuella carreraEstabilidadResultado
Baseline WebGPU (antes)llegó855 MB6,000 MB @ 88 smatado por el OSFAIL
Baseline WebGL 2 (antes)llegó970–1,800 MB9,000 MBmatado por el OSFAIL
WebGPU (8cbf571)25.9 s599–612 MB1,006 MB @ 91 s0 HUNG, 0 STOPPASS ≤ 1.5 GB
WebGL 2 antes del pacerno llegó~1,200 MB5,538 MB @ 66 s7 HUNG, matadoFAIL (375 fps)
WebGL 2 tras arreglo pacer (d6ef04c)29.15 s653–1,439 MB2,009 → 4,032 MB @ 91 s0 HUNG, 0 STOPCarga arreglada
WebGL 2 + cinta pooled (e79e9d2)27.70 s656–717 MB1,078 → 1,513 MB @ 90 s (-62.5%)0 HUNG, 0 STOP, 30.0 fpsPASS (~1.5 GB)

En simplePrimero, la pantalla de carga pintaba una barra estática 375 veces por segundo y ahogaba a Safari antes de arrancar la carrera. Luego, al manejar, el traductor WebGL 2 creaba dos funciones nuevas y tres arreglos temporales en cada draw — 66,000 veces por segundo. Cambiarlo a una cinta plana reutilizable bajó la memoria en WebGL 2 a los 90 s de 4.03 GB a 1.51 GB corriendo parejo a 30 fps.

2.5 · Reconciliación forense final (auditoría en 5 capas)

CapaHallazgo forenseAcción aplicada
Host C (host/*.c)host/files.c:406-410 (track_drop()) estaba fuera de #ifdef __EMSCRIPTEN__ y rompía clang nativoProtegido bajo #ifdef __EMSCRIPTEN__; ahora 28/28 host/*.c pasan clang -fsyntax-only nativo
Binario y LifterMD5 de Speed.exe b6b9232c55376b3c38c56aac1f8a121d verificado; 13,764 funciones (0 fallidas); 375 parches, 0 traslapesVerificado limpio
Web JS (web/*.js)20/20 scripts pasan sintaxis; glcheck 13/13 original y 17/17 remasterVerificado limpio
dist/ vs R2 en vivodist/manifest.json = 5,677 archivos / 2,100.33 MB (1.956 GiB); paridad byte a byte en nfsu.cc para boot.js, gpu.js, webgpu_gl.js, mode.js, data-chunks.jsonReconciliado el conteo desfasado 5,589 en plan.json fila 3
Git y Worktrees3 worktrees muertos (prunable) de ramas UG2 retiradasEjecutado git worktree prune; ramas activas intactas

Changelog v1 · 1.47 GB de GC en gpu.js, trampas de caché en WebGL 2 y retiro de mc.c

Auditoría forense anterior tras retirar el modo mundo de UG2 y lanzar el respaldo inicial en WebGL 2 (57c6aee):

1,472 MBde asignaciones JS desechables en 12 s de carrera en web/gpu.js
4 arreglostrampas de caché y pérdida de contexto cerradas en web/webgpu_gl.js
377 → 375parches binarios activos tras retirar host/mc.c y la cueva 0x797600
3 desfasesbooleano string en plan.json, SHAs huérfanos en HANDOFF.md y conteo de manifiesto

1.1 · web/gpu.js — 1.47 GB de presión al GC por cuadro

Un iPhone XR se congeló en el sitio en vivo. malloc_history de WebKit atribuyó 5.4 GB de la huella del proceso al heap de JS (JSC/bmalloc). El perfilador de heap de Chrome durante 12 segundos de carrera (logs/ch_hp3.heap.json) capturó 2,112.9 MB de asignaciones temporales; el 69.7% (1,472.2 MB) salía de runList (968.9 MB), pipeline (280.9 MB) y sampler (222.4 MB).

// web/gpu.js — antes: asignado en cada GPU_DRAW (cientos por cuadro)
const key = [g(D_VS), g(D_PS), g(D_DECL), stride, g(D_TOPO), ds, ...].join(',');
pass.setBindGroup(0, uBind, [uoff]);
const entries = []; // 3 objetos por textura incluso cuando ya estaba en caché

// después: tries de Map sin asignaciones, clave entera de 28 bits, tuplas reusadas
const pl = pipeline(w, a, stride, rt.sc || 1);  // vs._pipes → ps → decl → entry[] + tag
UOFF_ARR[0] = uoff; pass.setBindGroup(0, uBind, UOFF_ARR);
let bg = findTexBind(ps.texMask, w, a);         // entries[] solo si hay miss

Reconciliado. samplerFrom(w, to) empaqueta los seis campos del sampler en un entero de 28 bits; pipeline() usa un trie de Maps con tag entero de descarte rápido; runList rastrea targets, viewports y scissors como escalares y reutiliza UOFF_ARR y BF_ARR.

1.2 · web/webgpu_gl.js — cuatro trampas de caché de estado

SitioModo de falloArreglo
skipSameStateEstados GL, blend y bindings en caché sobrevivían a una pérdida de contextoSe agregó gl._resetSameState() conectado a webglcontextlost y webglcontextrestored
colorSamplerForGuardado directo en samp._rnColor sin aislar por dispositivo ni validar descriptorMovido a un WeakMap en device._colorSamplerBySamp verificando los 6 campos
texBindingClave index * 4096 + binding; colisiona si binding >= 4096Reemplazado por un Map anidado (index → binding) acotado por versión de link
ulocWebGLUniformLocations en caché sobrevivían a gl.linkProgramSe envolvió gl.linkProgram para limpiar p._ul e incrementar p._linkVer

1.3 · host/mc.c y desfase de estado

Reconciliado. Se retiró el desvío peatonal muerto en Speed.exe:0x4479be / cueva 0x797600 (host/mc.c, host/mc.h y tools/recomp/patches_mc.py movidos a attic/mc/; parches activos 377 → 375). Se corrigió el booleano string "done": "False" en la fila 11 de plan.json y los SHAs huérfanos en HANDOFF.md.

Enlaces: repo · Cómo metí NFSU en una pestaña del navegador · nfsu.cc