Skip to content

Port Web runtime parity and sustained-performance fixes - #2

Merged
N0zoM1z0 merged 9 commits into
mainfrom
perf/web-streaming-vbo
Sep 11, 2026
Merged

N0zoM1z0 merged 9 commits into
mainfrom
perf/web-streaming-vbo

Conversation

@N0zoM1z0

Copy link
Copy Markdown
Owner

Summary

  • import the target-informed runtime parity, ownership, rendering, score/replay, decompression, and data-validation fixes from the current th08-web baseline while preserving all th08-mods behavior
  • replace per-upload VBO reuse with once-per-frame three-buffer streaming, direct persistent vertex conversion, and safe adjacent-draw coalescing
  • add bounded BGM range lookahead and preserve authored 60 Hz logical time across browser callback jitter
  • compose the portable Double Time 3:2 scheduler inside every Web accumulator step so presentation remains display-paced while gameplay and audio actually advance at 1.5x
  • retain a modifier-aware Playwright replay harness, enforce CPU/memory limits on every Docker build/smoke invocation, and document the architecture and reproduction path

Validation

  • python3 scripts/ci.py
  • node --check scripts/test-web-runtime.mjs
  • npm run test:web-runtime -- --help
  • bash -n scripts/build-web-game.sh
  • git diff --check
  • final-head Actions run 34563333706: repository checks, both pinned Emscripten Release links, both generated-runtime modifier smoke tests, strict nine-file provenance, branch artifact upload; production deploy skipped
  • runtime artifact Actions run 34562601682: source commit 9a63638, also fully green and uploaded without deployment
  • caller-supplied Stage 5 replay, Chromium 150/SwiftShader, 10-second warm-up plus 20-second sample in each mode:
    • no modifiers: direct and proxy both 1,200 callbacks / 1,200 calculations, 59.99 / 59.99 Hz
    • HD+FL+MR(rotate-90)+NF+DT+HR+BS+NB: direct and proxy both 1,200 callbacks / 1,808 calculations, 59.99 / 90.38 Hz
    • all four samples retained Stage 5, matched the expected manifest, produced valid gameplay screenshots, and recorded no test or browser-console error

Evidence boundary

The checkout does not contain canonical resources/th08.exe, so this PR makes no new VC7 exact-match or aggregate reconstruction claim. config/claims.csv remains header-only. Retail DATs, replay files, reports, screenshots, and generated build trees were not committed; local generated artifacts were removed after validation.

Rotate the WebGL vertex-buffer ring once per presented frame, orphan the selected store with GL_STREAM_DRAW, and append all game and blit uploads at increasing offsets. This follows the bounded streaming-storage pattern corroborated by some100/th07 while retaining TH08's pthread and range-read asset architecture.

Write converted vertices directly into the persistent frame queue and coalesce only adjacent triangle lists with byte-identical captured render state. This removes a temporary allocation and duplicate copy from every D3D-shaped draw without changing primitive order or authored timing.

Extend ?perf=1 with repeating browser/worker/game pacing summaries and rolling renderer upload/submission maxima so late-session degradation can be diagnosed on real hardware. Permit manual branch Web builds to upload a provenance-gated test bundle without deploying it, and document the design tradeoffs and why TH07's fixed-step main loop is not copied wholesale.
Keep TH08's synchronous authored file boundary while asynchronously fetching the next 1 MiB thbgm.dat range. Sequential cache misses consume the pending ArrayBuffer when available; seeks and failed prefetches fall back to a direct Blob read, and only one future chunk remains resident.

Extend opt-in diagnostics to label direct versus prefetched retail reads and report their worker wait time. This separates periodic browser File stalls from WebGL submission stalls during real-hardware endurance testing.

Promote the Stage 5 Playwright probe into a parameterized repository script with pinned playwright-core metadata. It serves only the provenance-gated artifacts with isolation headers, uses caller-supplied retail files, injects a replay into session MEMFS, tests direct and proxy links in clean contexts, separates warm-up from measurement, and emits untracked JSON and screenshots.

Use the current Node 24 upload-artifact action for manually dispatched branch test bundles and document the bounded prefetch and reproducible browser-test workflow.
Predict the next Blob cache miss from the number of complete 44,100-byte DirectSound notification reads that fit in the 1 MiB range. The previous physical-end prediction landed 34,276 bytes beyond the actual refill point, so every nominal lookahead was discarded as an offset mismatch.

Document the request-aligned range boundary and preserve direct-read fallback for seeks, short reads, and failed prefetches.
Use a Web-only fixed-step accumulator so a late callback or a handled window message no longer causes the original-shaped one-update gate to discard logical time. Clamp catch-up to 100 ms, execute replay/input and sound processing once per authored calculation, and render once after the pending steps; native and VC7 paths remain unchanged.

Keep browser rAF, worker callback, and authored calculation rates independent in diagnostics so catch-up cannot conceal a real presentation slowdown. TH08 intentionally does not claim TH07-style render interpolation without the corresponding previous-state model.

Correct the retained Playwright probe to measure its window with page performance timestamps. Node-side wall time included delayed CDP result serialization after the frame snapshot and produced false 46--52 FPS reports even when exactly 600 or 1,200 frames advanced.
Run the modifier's deterministic simulation-tick scheduler inside every 60 Hz Web accumulator step. This keeps Double Time at its authored 3:2 simulation ratio while the browser presentation remains display-paced.\n\nCount each actual authored calculation for diagnostics, process sound once per simulation tick, and advance the render cadence once per presentation-time step, matching the existing native modifier integration.
- port target-evidenced background, ANM ownership, popup, RNG, bomb timer, and retry corrections into the Web runtime
- fix modern array ownership and keep decrypted resource lengths aligned with returned allocations
- bound LZSS output and validate score and replay sizes, offsets, and truncated inputs before use
- reject unsupported shared-memory, canvas, and WebGL environments with actionable launcher diagnostics
- remove redundant per-frame GL state calls and cap container builds at conservative single-job resource limits
- document replay, Stage 5, performance, compatibility, cleanup, and verification boundaries
Extend the retained Playwright replay harness so th08-mods can exercise deterministic modifier selections in both direct and proxy presentation modes. Validate the emitted run manifest, Mirror mode selection, and the 1.5x Double Time simulation cadence independently from the browser presentation callback rate. Wait for runtime initialization before changing controls to keep the test reliable across slow hosts.

Advance the recorded th08-web baseline to e3485ab after importing the runtime-parity and sustained-performance work. Keep every Docker invocation under the configured CPU and memory limits, use a mods-specific workflow artifact name, and update all manifest contract tests and package metadata accordingly.
The modifier smoke test loads each generated .js runtime through require(), while the retained Playwright harness already uses an explicit .mjs extension. Do not mark every repository .js file as an ES module: Node otherwise refuses the Emscripten CommonJS loader before the Wasm modifier manifest can be tested.
Explain how the generic 60 Hz Web accumulator composes with the portable Double Time scheduler, including per-simulation-tick audio processing and display-paced rendering. Document the modifier-aware replay command so later work can reproduce normal, Mirror, and Double Time validation without committing retail data.

Record the provenance-gated CI artifact and four Stage 5 Chromium/SwiftShader measurements. Both direct and proxy presentation held 59.99 Hz normally and 59.99 callback / 90.38 simulation Hz with the heavy modifier set, with valid manifests, screenshots, and no recorded browser errors. State the missing canonical executable boundary and avoid any new VC7 exact-match claim.
@N0zoM1z0
N0zoM1z0 merged commit 2bb35c9 into main Sep 11, 2026
5 checks passed
@N0zoM1z0
N0zoM1z0 deleted the perf/web-streaming-vbo branch September 11, 2026 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant