OpenTPW

Browser performance#

OpenTPW shares its game code between native builds and the browser. The browser's WebAssembly runtime and WebGL bridge run much of that work on the page's main thread. A task that occupies that thread also postpones drawing and input.

The desktop engine's own CPU profile (simulation and frame, with the changes of 18 October that also remove garbage the browser pays for) is in ENGINE-PERFORMANCE.md.

Measuring#

tools/web-perf/run.mjs repeats the measurements below with one command. Chrome runs with --mute-audio (also headed, and for tools/web-postcard-smoke.mjs), so measurement runs make no sound; --audible lets a human listen. --music is unaffected: it switches the game's own music and speech on, and Web Audio still decodes them while the speakers are muted. It serves a published wwwroot and the player's own game folder on 127.0.0.1 (the page's ?data= route), opens them in a fresh headless Chrome profile through the DevTools Protocol, drives the game through the same UI calls as the native front-end smoke test and writes a JSON report plus a Markdown summary. It needs Node 22 or later and Chrome; it has no dependencies. The game files stay on the machine and no game data goes into the report.

dotnet publish source/OpenTPW.Web/OpenTPW.Web.csproj -c Release -o out/web
node tools/web-perf/run.mjs --web out/web/wwwroot --game "/path/to/Theme Park World" --label interpreter --runs 3
ScenarioWhat it measures
start (always first)loading until the first frame and the lobby
lobbya steady window (--window, 30 s) in the lobby
junglethe cold start of Full Simulation Jungle (the construction frame) with its load profile, then a steady window
buythe first buy-menu open (Aztec Mayhem selected) and the first Belly Bounce, Balloon Shop, Burger Shop and Drinks Shop selections
memorywasm memory, managed heap and JS heap every 10 s over --memory-minutes
switchmemory across park changes (Jungle, the lobby, the next island's park, the lobby, Jungle again; --visits <n> adds a lobby and Jungle for each visit past the third), each point after a full collection and after waiting up to 60 s for the sound sample decodes in flight to end (a warning when one is still running): wasm, live managed memory, live parks, entities, live textures by source, archive and sound bytes, what the sound mixer reaches by the field holding it (PerfAudioBytes), and in the lobby the static fields that hold the most (--runtime-roots: also the framework's statics and array pools, PerfRuntimeRoots, and every reached object by type with an estimate of their bytes, PerfObjectCounts)
revisitwith --keep lazy or --keep all: the same profile reopened without the served folder; Play, the lobby, then Jungle from the kept files (fails if it asks for the folder)
umbrellaCost(after jungle) the frame cost of a staged crowd (--crowd, default 400 extra guests) in rain, a steady window without and one with an open umbrella over every guest, at the Home and the farthest zoom (Program.PerfUmbrellaCrowd, loopback ?perf=1 only; docs/UMBRELLAS.md "Tuning")
coopDigest(after jungle) the co-op session digest's cost, which the host takes once a second of real time: the median of 15 digests and world hashes on the park as it stands, again after up to 80 of the buy menu's rides and shops are built (money cheated in for them), again after --crowd extra guests are staged, and once more after 20 s of play (Program.PerfSessionDigest, PerfPlaceObject, PerfCrowd; docs/COOP.md "Measurements")
winterCost(after jungle) the frame cost of a staged crowd (--crowd, default 400) in rain at the Home zoom, one window per step, each added to the one before: rain (a rain-only crowd, no snow: the staging applies weather quality 30 and every step applies it again before its window), rainSnow (the settled snow held at --cover, default 1), rainSnowUmbrellas (an open umbrella over every guest, held open), rainSnowDressed (and every guest in warm items) and the same at the farthest zoom (rainSnowDressedFar); each window records whether it still rained at its end, and the umbrellas and items drawn. The items' own cost is rainSnowDressed minus rainSnowUmbrellas. Last it saves a screenshot of a freshly staged dressed crowd in snow without umbrellas (--shot, --zoom default 70, the camera on one guest chosen by --follow, default -250: it skips the 250 newest visible guests, so with the default crowd of 400 it is the 150th guest of the new crowd, which stands in the open away from the entrance roofs; guests are picked by id order, so look at the picture and adjust --follow if a run lands under a roof) (PerfSnow, PerfUmbrellas, PerfUmbrellasOff, PerfWinter, PerfRaining; docs/WINTER.md "Tuning")
events(after jungle) the frames after each event a player causes in a park session ("Event hitches" below): every HUD window opened, closed and reopened; the first buy previews and builds; weather; a bus arrival; the evening; research completing; the autosave; a month end and a year end; a coaster built; a crowd of --crowd guests; and a soak at the fastest speed (--soak seconds). For each event it reports the worst frame, the p95 and the slowest frames with the game's named work in them (FrameMarks). --profile adds the functions a CPU profile spent each slow frame in, named with --symbols
door(after jungle) the entry price window's park door clicked through the HUD's input three times in the fresh, closed park: open, close, open again. Each click gets its worst frame, p95, the time until the economy reports the new state and, for an opening, the time until the first new guest (at most --door-wait seconds, default 20). The events scenario ends with the same clicks
lobbyEnter(after jungle) the lobby's enter-park button in a session that starts with saved parks: the park is left to the lobby, which writes its automatic checkpoint, and the page is loaded again in the same profile. Then three clicks on the button, each followed up to the screen it opens and back, with its frames and the time until that screen
digestdeterministic work that must give the same result in every build, timed: every texture of the theme decoded and hashed, and the fixed park run of the original-data determinism test (seed 2026, 3000 ticks at the fastest speed; economy and guests) reduced to its world state hash. It blocks the page while it runs, so it comes last

tools/web-perf/compare.mjs --a <reports> --b <reports> prints the medians of two builds side by side with the change per measure (and how many runs a row rests on when some lacked it), and fails unless every run of both builds has the same digest.

Frame times are the wall time of each exported Program.Frame, recorded by the page only with ?perf=1. "Main thread busy" is the renderer main thread's task time over wall time (Performance.getMetrics): how much of the time that thread is occupied, which is what postpones drawing and input. It is not the operating system's CPU time, and whether the October samples below used the same method is not recorded, so the two are not directly comparable. Music and speech are muted through the options file and effects stay on, as on 11 October (--music keeps them on); world textures are the default Original (the browser then also carried the redrawn HD interface art, removed on October 18, 2026). The hooks behind ?perf=1 (Program.Perf.cs: state, a click on an element by id, a key, a buy-window selection, memory counters) change nothing unless the harness calls them. The page honours ?perf and ?perfSeed only on a loopback address, and the seed may only write the options file and the display settings (--frame-cap), so a link to the public page cannot write into a player's saved files. In perf mode the page asks for the drawn-frame count around every call, a small extra cost on the main thread that both sides of a comparison share.

The park view before October 24, 2026. The harness drives the game through its own UI calls and never moves the pointer. Until October 24 a page that had seen no pointer read it at (0, 0), the canvas's top-left pixel, which lies in the park camera's edge band. So in every park window whose camera the harness does not hold on a guest each frame (the umbrella and winter screenshot hooks do), the view scrolled to the park's top-left corner within about five seconds of the park opening; in Jungle that corner is bare grass. Since then the page reports no pointer ([EXT:browser-no-pointer], WEB.md) and the view stays where the park opens, so park windows from before and after that change are not comparable. One interpreter build of each side (Apple M5, Chrome 155, 1280×900, Jungle, a 20 s steady window): main thread busy rose from 15.5% to 21.2% and the frame p50/p95 from 1.9/2.8 ms to 2.7/4.5 ms, at 59.99 fps both.

Baseline, 13 October (interpreter build at 618ad830, Chrome 155 headless, Apple M5 hardware Metal through ANGLE, 1280×900; median of three runs of the final harness, range in brackets). This is a different machine from the M4 numbers below, so compare runs of the harness with each other, not with them.

MeasureValue
Lobby, main thread busy16.5 % (9.5–17.0), 60 fps, frame p95 3.8 ms (3.2–4.0)
Jungle, main thread busy16.6 % (11.8–21.1), 60 fps, frame p95 4.7 ms (4.6–5.1)
Jungle cold construction, largest frame2,492 ms (2,468–2,549); park ready 2,808 ms after the click
Open buy menu / Aztec Mayhem, largest frame80.3 ms (80.1–96.1)
Belly Bounce71.5 ms (62.0–74.2)
Balloon Shop25.6 ms (25.5–28.6)
Burger Shop37.1 ms (27.6–38.9)
Drinks Shop50.7 ms (35.0–55.6)
Wasm memory in the park230 MB, no growth over 2 minutes

How far a single run can be trusted. Over six runs in two sessions (three with an earlier version of the harness) the cold construction stayed within ±3 % (2,399–2,549 ms): that is the measure to decide on (the AOT experiment in the browser plan). Main thread busy and the small first-use frames varied by up to about ±30 % between sessions on this laptop. Compare builds with --runs 3 or more (medians, every run kept in the report) and run them alternately on an idle machine; a difference smaller than the ranges above is not a result.

Ahead-of-time compilation (13 October)#

The interpreter build against the same sources compiled ahead of time (-p:RunAOTCompilation=true, the wasm-tools workload), three runs each taken alternately on the M5 setup above:

MeasureInterpreterAOTChange
Start: first frame1,914 ms1,367 ms−29 %
Lobby: main thread busy19.3 %10.8 %−44 %
Jungle cold construction, largest frame2,540 ms (2,539–2,554)1,136 ms (1,132–1,137)−55 %
Jungle: main thread busy23.0 %14.5 %−37 %
Jungle: frame p955.1 ms3.0 ms−41 %
Open buy menu / Aztec Mayhem103.6 ms53.5 ms−48 %
Belly Bounce / Balloon / Burger / Drinks Shop70 / 34 / 36 / 51 ms37 / 20 / 24 / 27 ms−32 to −48 %
Digest: 1,698 Jungle textures decoded2,396 ms626 ms−74 %
Digest: fixed park run (3000 ticks)478 ms257 ms−46 %
Wasm memory in the park229 MB211 MB−8 %

The ranges do not overlap. In every run both builds gave the same digest, texture hash 1CC5AEB033691043 and world state hash 120A09CBAE070E0A, and the desktop runtime gives the same two hashes for the same work, as does an AOT build made in the Linux server image. That covers decoding the theme's 1,698 textures and the fixed park run, which exercises the economy and the guests but not the rides, object scripts, weather or staff; within that coverage AOT changed the speed, not the result (the check now covers rides, object scripts, weather and staff as well and runs in CI: docs/DETERMINISM.md, "Browser and native"). These are three runs per build on one machine: they show a large improvement there, not a speed guarantee for every device.

The cost is the build: the native module grows from 2.9 to 32.6 MB, the Brotli-compressed framework from 11.8 to 16.5 MB, and a publish takes about 110 s instead of 27 s. The browser plan's rule (AOT when the cold construction or the first menu frame gets at least 40 % faster, judged against the size of the original game the player supplies anyway) is met, so the published page (the server image, source/OpenTPW.Server/Dockerfile) is compiled ahead of time. A local dotnet publish stays an interpreter build without a workload (docs/WEB.md).

CoreCLR on WebAssembly (17 October)#

.NET 11 can run the browser build on CoreCLR (dotnet publish -p:UseMonoRuntime=false) instead of Mono. It starts and plays, and the texture hash 1CC5AEB033691043 and the simulation hash 0B45FAA2ED526C78 match the Mono builds in every variant below, but it is slower than Mono AOT, so Mono stays the default and CoreCLR is an opt-in. Medians of 3 runs, .NET 11 (11.0.100-rc.2.26504.105), Chrome 155 on an Apple M5:

MeasureMono AOTMono interpreterCoreCLR, interpreterCoreCLR + ReadyToRun (tools/web-coreclr/r2r.mjs)
Bundle, Brotli / raw19.9 MB / 69.0 MB13.3 MB / 29.2 MB13.8 MB / 30.9 MB29.8 MB / 152.2 MB
First frame / lobby2376 / 2399 ms3323 / 3323 ms8657 / 8816 ms4501 / 4525 ms
Jungle ready10206 ms13085 ms98368 ms21442 ms
Jungle steady: main thread busy / p95 frame9.8 % / 1.6 ms23.8 % / 4.4 ms100 % / 69.6 ms (7.9 fps)96.6 % / 9.1 ms (38 fps)
Texture decode (1698 textures)555 ms2443 ms16985 ms1590 ms
3000-tick run202 ms355 ms3093 ms1385 ms

What the .NET 11 pages say and what exists in RC2. The "What's new in .NET 11 runtime" page (updated for RC 2) lists, under CoreCLR on WebAssembly, WebCIL V1 as the default (crossgen2's WasmObjectWriter writes it) and a working native re-link. That is the crossgen2 tool and the loader; it does not announce an SDK switch. In the installed RC2 packs (microsoft.net.sdk.webassembly.pack and Microsoft.NET.Runtime.WebAssembly.Sdk 11.0.0-rc.2.26504.105) there is no ReadyToRun step for browser-wasm: no PrebuiltR2RDirectory in ConvertDllsToWebcil, no crossgen target, and PublishReadyToRun=true stops with NETSDK1095. The SDK integration is dotnet/runtime#133378 (merged 17 September 2026 into main, milestone 12.0.0; ReadyToRunTests.cs exists on main and not on release/11.0), and the runtime pack carries no prebuilt native/r2r images. So dotnet publish gives an interpreter-only CoreCLR build. The crossgen2 package that the workload restores can however target --targetos:browser --targetarch:wasm --obj-format:wasm, and the loader accepts its images if the boot config gives each one its tableSize and its payloadSize. tools/web-coreclr/r2r.mjs does exactly that on a finished publish (it compiles the trimmed IL as one version bubble with --inputbubble --compilebubblegenerics; the SDK's --opt-cross-module:* crashes crossgen2 RC2 on this project, and composite images are rejected by the runtime), which is the last column. Per assembly bubbles (no --inputbubble) boot too but are barely faster than the interpreter (about 8.6 fps, simulation 2.2 s).

Result: ReadyToRun takes CoreCLR from 98 s to 21 s for Jungle and from 8 to 38 fps, texture decode becomes faster than the Mono interpreter, but it is still 2 times slower to Jungle, 7 times slower on the simulation, the main thread is saturated (97 % against 10 %) and the download is 50 % larger (the Brotli size of the 152 MB raw payload is 29.8 MB). The rule for switching the published page (at least as fast as Mono AOT in time to playable and in frame or simulation speed) is not met, so it stays on Mono. The earlier "never reaches the first frame" finding came from the measuring harness waiting at the Game Mode screen, not from the runtime. Revisit with .NET 12 (the SDK integration, the runtime's own performance work in dotnet/runtime#124218, and probably a working --opt-cross-module).

Frame cap (13 October)#

The frame rate limit on the OpenTPW options page (DisplaySettings.FrameCap: off by default, 30 or 60 fps) caps drawing, not the simulation: FrameLimiter books frames on a grid of 1/cap seconds with a quarter interval of slack for timing jitter, the browser skips an animation frame that comes too early and the desktop sleeps until the next one is due, and the simulation's fixed clock (FixedStepClock) takes the elapsed time in larger steps. The browser now keeps its display settings in /config like the desktop, so the choice survives a reload.

Interpreter build, two runs per setting taken alternately on the M5 setup (the harness's --frame-cap; frames are counted only when the renderer drew one):

CapFrames drawnCalls skipped (30 s)Main thread busy, lobby / Jungle
Off60 fps017.5 % / 22.6 %
3030.0 fpsabout 90010.0 % / 12.9 % (−43 %)
6059.96–59.99 fps0–117.1 % / 17.2 %

In these samples a 30 fps cap took 43 % off the main thread rather than half; the likely reason (not measured apart) is that only the drawing halves, while the simulation keeps its 60 ticks a second and the page still runs one animation-frame callback per display frame. A cap at the display rate drew practically every frame. Input is read once per drawn frame, so a 30 fps cap can add about one display frame of input delay; that is why it stays off by default.

Where the cold park start goes (13 October)#

LoadProfile (source/OpenTPW.Common/LoadProfile.cs) times named sections of the park start when the harness turns it on (PerfProfile): the start's steps in GameFlow.StartLevel and the Level constructor, and the building blocks texture decoding, texture creation, model parsing and WAD reads. Off, a section costs a thread-id read and a comparison. Sections nest, so a parent includes its children. The harness reads the profile when the park is ready and again five seconds later; for cold Jungle the two are identical, so all of this happens during the start. Two runs of the AOT build on the M5 setup (interpreter in brackets, one run):

SectionAOT, msWithin it
Whole start (start-level)1,010–1,047 (2,338)
Objects placed250–256 (386)
Original park read186 (297)object catalogue 121
Guests151 (222)kid sprite sets 107–108
Park audio started131–133
Economy76 (132)
Terrain75–78 (257)
Texture decoding, 90 textures61–64 (243)spread over the sections above
Model parsing, 14 models62–64 (102)spread over the sections above
Texture creation, 129 / WAD reads, 2955 / 2–3

In these runs decoding was about 6 % of the AOT start (10 % in the interpreter), so a cache of decoded textures could save at most about 60 ms of a Jungle start, less the time to read it back; the browser plan's phase 3 therefore waits. The larger shares are the object catalogue, the kid sprite sets, starting the park audio and the object placement: those, or spreading the start over frames, are the next targets.

Building a park over frames (13 October)#

Until now a park was built in one frame: GameFlow.StartLevel tore the lobby down and constructed the level in a single call. That took about 550 ms on the AOT build (the largest frame of the cold Jungle start), and the page stood still for all of it. The audio mixer keeps only about 93 ms queued, so the lobby music stopped too. Phase 5 of the browser plan spreads that work over frames:

Three alternating runs against main (AOT, M5 setup, medians):

Measuremainover framesChange
Jungle cold: largest frame509 ms107 ms−79 %
Jungle cold: frames of 50 ms or more11–2
Jungle cold: ready717 ms832 ms+16 %
Construction frames122–23 (12 ms each, a few steps 25–54 ms)

The digest hashes are identical in every run. The steady lobby and park windows are unchanged: in the runs without other load on the machine their frame p95 was 0.6–0.7 against 0.6 ms (lobby) and 0.8–0.9 against 0.9 ms (Jungle). A review running alongside the later runs raised both builds alike, so their medians are left out. With a 10 ms budget an earlier set gave 584 → 140 ms and a ready time 29 % later. The park is ready later because the work now waits for frames; the lobby goes on drawing and playing meanwhile. Two costs remain:

Files read on demand, and the textures that stayed (13 October)#

The second part of the memory phase closed the three items left open below:

StepLive managed beforeAfterWasm before → afterTextures without a path
Jungle94 MB41 MB254 → 176 MB20
Lobby47 MB24 MB254 → 176 MB1 (25 before)
Fantasy109 MB48 MB305 → 254 MB20
Lobby again58 MB28 MB305 → 254 MB1 (25 before, growing)
Jungle again113 MB51 MB305 → 254 MB20

What still grows a little (24 → 28 MB in the lobby) is the cache of each theme visited for the first time: its textures stay cached by path (Fantasy's 57), and so does its part of the object catalogue, which makes a revisit faster. Visiting a park of a theme seen before adds nothing (Jungle again holds the same textures); with all themes visited the cache is at its largest, and a limit on it is not part of this phase. Three alternating runs against the build without this change: the digest's hashes are unchanged, the cold Jungle frame is the same (625 against 586 ms, medians of four), and the page's wasm memory in the park is 31 % lower.

Memory across park changes (13 October)#

The switch scenario takes each point after a full collection, so the managed figure is live memory. On the AOT build (M5 setup) it found two leaks:

StepLive managed beforeAfterLive parks before → after
Jungle94 MB94 MB1 → 1
Lobby67 MB47 MB1 → 0
Fantasy124 MB109 MB2 → 1
Lobby again81 MB58 MB1 → 0
Jungle again132 MB113 MB2 → 1

These are one run of the scenario on one machine. Still open, and larger: the textures made at run time without a path (signs, object textures, colour blocks) stay in Asset.All and on the GPU after their park (textures held 265 → 251 → 333 → 319 → 345 over the scenario: Fantasy's own textures stay cached by path, and about a dozen path-less ones remain per park); the archive files (22–29 MB read so far; archives are never closed) and the sound banks (about 35 MB) are kept whole in managed memory although the browser already holds the files; and the mixer's share still grows by about 6 MB a park. The page's wasm memory peaks at 305 MB after the second park and does not shrink.

Three start costs removed (13 October)#

Splitting the profile's large sections further showed that two of them were not the work their names suggest:

AOT builds, three runs each taken alternately on the M5 setup (compare.mjs):

MeasureBeforeAfterChange
Jungle cold, largest frame1,143 ms520 ms−55 %
Jungle cold, ready after the click1,421 ms804 ms−43 %
Whole start (start-level)992–1,083 ms431–451 msabout −58 %
Start, first frame1,603 ms1,131 ms−29 %
Open buy menu / first shop selections64 / 18–38 ms42 / 13–23 ms−29 to −45 %
Digest: texture decoding / fixed park run644 / 261 ms481 / 135 ms−25 / −48 %
Wasm memory in the park212 MB254 MB+20 %

The digest's hashes are unchanged in every run. Live managed memory is the same (102 MB) and the start allocates less (555 against 736 MB in all), but with far fewer small allocations the garbage collector runs less often (16 against 57 gen0 collections), the heap grows further between them, and a page's WebAssembly memory never shrinks: its peak is 42 MB higher. The memory phase of the plan starts from that.

Game files kept in the browser (13 October)#

With the game files kept in OPFS (docs/WEB.md), interpreter build, M5 setup; the harness's --keep and its revisit scenario (the same profile reopened without the served folder):

MeasureValue
First visit, first frame, without keeping / keeping what the parks use1,974 / about 1,990 ms (medians of three alternating runs; within the noise)
First visit, Jungle ready2,880 / 2,931 ms
Revisit, Play button shown after loading the page160–170 ms
Revisit, lobby after Play1,630–1,700 ms (97 MB kept: the start and Jungle)
Revisit, Jungle ready from the kept files2,800–2,870 ms
All at once: first visit, first frame / revisit lobby3,406–4,658 ms (307 MB kept before the start) / 1,709–1,752 ms

Writing first ran during the copy and slowed the first start by about a quarter; it now waits until the game has started.

Measured workload#

Two matched 30-second samples on 11 October 2026 used headless Chrome, Apple M4 hardware Metal through ANGLE, a 1280×900 canvas, Original world textures and the redrawn HD interface art that the build then bundled (removed on October 18, 2026). Jungle used a stationary camera, music and speech muted through the UI, effects on and no world-texture downloads (the browser build has none). Muting does not itself stop audio decoding.

Phasev0.7.6 main-thread CPUOptimized prototypeReduction
Lobby27.8% of one core22.0% of one core20.8%
Jungle41.1% of one core29.4% of one core28.4%

The Jungle frame-callback 95th percentile fell from 7.3 to 5.8 ms. The old sample had two 286/279 ms main-thread tasks outside the render callback; the optimized steady sample had no tasks of at least 50 ms. Its largest frame gap was still 40.4 ms, compared with 292.8 ms before. Terrain, rides, guests and HUD remained visible and animated. These figures measure the page's main thread, not all Chrome processes or GPU time, and do not promise the same numbers on another device.

First build-menu selections#

On 12 October, the first selection of an attraction or shop stalled a browser frame for 422–1,011 ms. Profiling traced most of that time to LZSS texture decompression: each backreference read its entire lookback window, up to 4,095 bytes, even for a short copy. The decoder now copies forward directly into a growing output array, including overlapping references. Texture scratch storage is quadratic rather than cubic, decoded planes use arrays, and previews resolve each used material once and reuse parsed models. Unused sign materials still do no work.

Matched cold selections used the same original files, Full Simulation Jungle, Original world textures, the then-bundled HD interface (removed on October 18, 2026) and a 1280×800 browser viewport. These numbers measure wall time inside the actual exported Program.Frame, not network loading, GPU time or overall FPS. The baseline is deployed v0.7.12; the after column is the optimized local build.

First actionBeforeAfter
Open buy menu / Aztec Mayhem710 ms172 ms
Belly Bounce478 ms75 ms
Balloon Shop422 ms42 ms
Burger Shop649 ms35 ms
Drinks Shop1,011 ms42 ms

Selections are substantially shorter, but first-use work remains: opening the menu still takes about 172 ms in this sample, and Belly Bounce takes 75 ms. Warm preview frames remain around 4–6 ms. Device and runtime differences affect these timings. The complete original texture corpus retains identical pixels: 8,412 successful RGBA hashes and the same four malformed-file errors, plus 31 synthetic cases.

The follow-up on 13 October reduced the same first menu frame from about 165 ms in deployed v0.7.13 to about 94–96 ms in repeated local candidate runs. Bundled HUD PNGs are decoded at build time and stored as compressed, exact RGBA; sign rasterization scans an ordered active-edge window without changing coverage. The existing park-file copy wait also prepares only shared buy-menu image resources, with a 6 ms budget checked between images. One indivisible image can exceed the remaining budget. Previews and signs still load on request. All 55 bundled images and all 75 signed previews retain their original pixel hashes.

Preparation uses the normal image cache and invalidation. A transition with no file wait keeps the usual lazy loading fallback, so this timing is not a guarantee for every first-open situation. It caches menu art earlier, including button states, even if the menu is never opened. The compressed image representation adds about 1.7 MB to the Web module; desktop builds retain PNGs. In the measured wait, no extra frame exceeded 20 ms apart from the existing initial scene construction. The remaining first-preview work is still visible; this does not claim a 16 ms cold frame.

Changes#

Transfer and memory (October 19, 2026)#

Measured with the published AOT page (dotnet publish -c Release -p:RunAOTCompilation=true), served by the real OpenTPW.Server (so its precompressed copies, ETags and headers are what the browser sees), Chrome 155 headless and muted, Apple M5, 1280 x 900, the game folder from the harness. tools/web-perf/run.mjs --upstream http://127.0.0.1:<port> --scenarios start,jungle,switch,reload,transfer forwards every request but /game/ to that server and logs it (path, status, Content-Encoding, Cache-Control, ETag, conditional or not, bytes sent); reload loads the page again in the same profile and transfer prints the log by scenario. --track-origins, --gc <params> and the counters below are diagnostics; the harness reads them only when asked.

Transfer#

A cold page load plus a Jungle park (the game's own files come from the player's folder and are not counted): 105 requests and 20.2 MB sent before, 104 and 17.4 MB after. Everything is listed in the table; "raw" is the size on disk, "sent" the bytes on the wire.

FilesCountRaw MBSent MB beforeSent MB afterContent-EncodingCache-Control after
dotnet.native.<hash>.wasm (the runtime, AOT code)142.68.498.47brimmutable, 1 year
OpenTPW.Web.<hash>.wasm (the game)112.42.222.22brimmutable
38 other assemblies (.wasm)385.01.291.29brimmutable
ICU data (icudt_no_CJK)11.20.230.23brimmutable
dotnet.js and the two fingerprinted runtime scripts30.40.100.10brdotnet.js no-cache, the others immutable
page scripts (main.js, opentpw-*.js), index.html, style.css120.10.020.02brno-cache (ETag, 304)
pools sprites .TPC (Jungle, with the pools extension on: the swim and land sets)247.97.865.02none before, br afterno-cache before, immutable after (?v=<hash>)
pools sprites .ESP (350 bytes each)240.010.010.01noneno-cache before, immutable after
/favicon.ico (404)10gone
Total105 / 10469.520.217.4

What was wrong:

Checked and left as it is: the SDK's Brotli is already level 11 with the 4 MB window (lgwin 22: the same 8,899,876 bytes for the runtime as a local re-run); window 24 would save 138 KB (1.5 %). The scripts of the page (main.js and its modules) stay revalidated with ETag and 304: they have no fingerprint in their names, and giving them one (the SDK's import map) needs an inline script, which the page's content security policy forbids.

Memory#

Jungle in the browser (the switch scenario: Jungle, lobby, Jungle, lobby, Jungle, each point after a full collection; the second park is Jungle again because the next island is locked). Counters added for this: gpuTextureBytes and gpuTextures (the live WebGL textures and renderbuffers, from their size and mip chain), PerfTextureBytes (distinct textures by path group and the largest ones), PerfAssetBytes (array bytes behind Asset.All by type, and the shaders by file), committed and fragmented GC bytes, and the renderer process's resident memory (ps).

StepLive managed MB before / afterShader assets before / afterRenderer resident MB before / afterWasm MB before / afterGPU textures MB
Jungle72 / 61236 / 90755 / 619214 / 214149
Lobby59 / 45357 / 195789 / 663214 / 21482
Jungle again (park 2)80 / 62398 / 901,121 / 852445 / 371150
Lobby again73 / 52519 / 1951,123 / 861445 / 37182
Jungle once more86 / 62560 / 90905 / 842445 / 371150

Texture digest hash 845CD7FD1E465A18 and fixed-park simulation hash ECB0C5BC6BFC46B9 are the same in both builds. (One run each, one machine: the wasm and resident figures depend on when the runtime's allocator grew.)

Where the memory goes in a Jungle park (after): the wasm memory is 214 MB: 61 MB live managed objects, the rest the runtime (the 13 MB game assembly and the others are loaded into it), the allocator and its free space after the build's garbage (the build allocates about 590 MB). Wasm memory never shrinks; its peak after the second park is 371 MB. GC parameters do not change it: MONO_GC_PARAMS soft-heap-limit=128m gave 214 MB and nursery-size=1m 209 MB (against 215), and major=marksweep-conc hangs the page. The JS heap is 16-23 MB. The GPU holds 149 MB in Jungle (by estimate from size and mip chain; 82 MB in the lobby): about 46 MB of that are the render targets at 1280 x 900 (4x multisampled colour and depth, the resolve texture and the swap chain; they scale with the canvas size, so a high-DPI window costs several times as much), the 38 textures made from bytes are 69 MB (the guest, staff, particle and sign atlases, mostly 1024 x 1024 and 1024 x 512), and the 137 + 81 + 42 textures loaded by path 14 MB.

What was changed:

The answers to the questions asked:

The AudioMixer root across visits (21 October)#

The 4.6 MB "growth" of the AudioMixer root was a sampling artefact, not a leak. Two things made the figure misleading:

The harness now waits until no sound decode is in flight before it takes a point (soundDecodesInFlight in PerfCounters, from GameAudio.Counts), and PerfAudioBytes names what the mixer reaches by the field that holds it (the diagnostic that found the two causes). The root walks also no longer enter a ConditionalWeakTable (the sound system's table of ended categories): reading an entry whose key has been collected crashed the walk in the AOT runtime ("memory access out of bounds"), once the points were taken with no decode in flight.

Six visits on the published AOT build (Chrome 155 headless and muted, Apple M5, 1280 x 900; --scenarios jungle,switch --visits 6), each point after a full collection. Both runs are of 21 October, before the texture fix below (the October figure above, 18.7 MB, is an earlier run of the same first point):

StepBefore: AudioMixer root MBBefore: decodes in flightAfter: AudioMixer root MBAfter: decodes in flightAfter: live managed MB
Lobby18.8120.2047.2
Lobby again23.5220.0050.9
Lobby 323.3220.1051.1
Lobby 423.4220.2051.0
Lobby 523.5 (by PerfAudioBytes)220.1051.0

"Before" is the same game code sampled the old way (two seconds after reaching the lobby, decodes in flight or not); the game's sound code did not change. Even then the root steps up once, from the first lobby to the second (one decode in flight against two), and stays there; it never grew per visit. The Jungle points are flat as well (19.5-20.8 MB reached from the mixer, 7.8 MB of decoded samples, 4-5 voices). The live managed memory also steps up once (47.2 -> 50.9-51.1 MB in the lobby in this run) and stays flat from the second visit on; that step is not the mixer's (see the next section).

A with-data test (AudioParkVisitTests, inconclusive without OPENTPW_GAME_PATH) runs the sound system without an output device through five visits (the lobby, Jungle with its music, placed ambients, crowd, a scream and a click, the listener moved away so the looping ambients release their outputs, then the lobby again) and checks that every visit leaves the same voices, sentences, chains, placed sounds, tracked one-shots and loops and held sounds as the first, and no decode in flight; with the park's chains not stopped at its end it fails (one more chain each visit).

Textures and live memory across visits (21 October)#

The same six-visit runs showed one more texture alive after every park visit (306 -> 311 in the park, 278 -> 282 in the lobby; 389 -> 396 GPU textures). A texture made from bytes now records the file and line that made it (Texture.Origin, with PerfTrackTextureOrigins; the browser's AOT stack traces carry no method names), and the switch scenario's texture groups named it: BlueprintMarkers.AreaTexture, the yellow-and-black square the coaster tool's placement area draws. Every park makes its blueprint markers, and their OnDelete released the material and model but not this texture, so each park left one 8 x 8 texture and its GPU texture for the session. It now goes with the markers. After the fix, textures held stay at 306 in Jungle and 277 in the lobby, and GPU textures at 391 and 361, from the second visit to the sixth.

The native front-end smoke test now checks it: the textures not loaded by path (less the type signs ObjectSigns keeps for the session on purpose) are as many after leaving a park as before entering it, after the first park and again after the second; a failure names the file and line of each texture left. Without the fix it fails with the blueprint area texture as the one extra.

Open item: the origin of a texture made from bytes uses [CallerFilePath], so the build embeds the source paths of the build machine in the assemblies (the origin itself is recorded only while tracking is on). A PathMap in the build would make them relative; not done yet.

The texture-pack list of .wct textures (Texture.wctTextures, weak references used when a pack is switched) was pruned only at a pack switch, so each park added about 230 dead entries for the session. It is now pruned whenever it doubles (408-721 entries over six visits, against 232 more per visit before).

The one-time step of live managed memory after the first visit (in the run after the texture fix, with --runtime-roots: 47.1 -> 52.2 MB in the lobby, then flat at 52.1-52.2 MB to the sixth visit; 50.9-51.1 MB in the run of the previous section, so the step's size varies from run to run) is not held by the game. PerfObjectCounts (with --runtime-roots) walks every static field of the game's and the framework's assemblies and the shared array pools and estimates the bytes of everything they reach: 56.9 MB in the first lobby and 57.0 MB in each later one (+0.1 MB, a UI text layout cache filled on first use, 197 layouts). PerfRuntimeRoots shows the framework's statics and array pools flat at about 2.3 MB. The step therefore lies outside every static root: in the runtime's own accounting of its heap after the second park's allocation peak (the wasm memory grew from 218 to 452 MB during that build) or in GC handles the JavaScript interop holds; it does not grow after the second visit. What does keep growing is the GC heap's fragmentation, about 1 MB per visit (6.8 -> 12.5 MB in the lobby; the heap 48.7 -> 59.1 MB) with the live objects flat, and with it the wasm memory once more at the fourth park (452 -> 542 MB): the allocator's peak, not a leak, and the lever is less garbage in the park build (see the recommendations above).

Recommendations (not done, with their trade-offs):

Remaining stalls#

In the earlier 11 October sample, after removing archive collections, cold Jungle construction still occupied one callback for roughly 16.5 seconds (17.9 before). The 12 October build-selection run measured 3.2 seconds for its initial Jungle construction frame, versus 10.8 seconds in its v0.7.12 baseline; loading the original folder and copying theme files are outside that frame. Advisor response 587 prepared in 87.9 ms, including 76.6 ms synchronous PCM decode; the first response measured 223.5 ms of PCM decoding. Those first-use costs are outside the matched steady windows and are not claimed as eliminated. Occasional smaller frame gaps remain as well. Broad visibility culling and full scene-material lifetime work are separate optimization opportunities; ahead-of-time compilation has since halved the cold construction (see above).

Verification#

The focused original-data suite passed 101 tests; the general CPU suite passed 1,424, with 348 fixture/platform skips. After the archive change, the full original-data suite passed 1,681 tests with 94 optional/platform skips in 55 seconds; the earlier v0.7.5 run took 28 minutes 54 seconds. Archive metadata, lazy data caching, response 587 PCM and its nine lip-sync marks are covered. Web publish passed. A 601-frame native frontend smoke checked two distinct shared-material transforms by GPU pixel readback, outside-frame uniform uploads, stable resource-set reuse, native texture replacement, shader rebuild, shared-owner retirement and deferred disposal, along with the existing park/menu tests.

See browser setup and limitations, audio and texture packs.

Wide zoom (October 18, 2026)#

The wide zoom option lets the park camera go out to the zoom value 300 (UI.md). tools/web-perf/run.mjs --scenarios jungle --window 20 --zoom 300 measures a second steady window with the park camera held at that zoom value (hook PerfZoom); the control run with --zoom 110 shows what the second window costs by itself (the first window follows the park's cold start). Published build of this branch (dotnet publish -c Release), Chrome 155 headless, Apple M5 through ANGLE/Metal, 1280 x 900, Jungle, 20 s windows, one run each:

WindowMain thread busyfpsFrame p95Largest gapLong tasks
First steady window, zoom 110 (zoom 300 run)18.9 %59.773.6 ms62.1 ms0
Second window, zoom 30012.7 %59.972.6 ms20.2 ms0
First steady window, zoom 110 (control run)17.3 %59.943.2 ms34.2 ms0
Second window, zoom 110 (control)11.4 %59.992.4 ms19.4 ms0

tools/web-perf/run.mjs --scenarios jungle,umbrellas --zoom 80 --shot umbrellas.png is a capture aid for the umbrellas extension (docs/UMBRELLAS.md): after the Jungle start it calls the harness hook PerfUmbrellas, which gives every guest an open umbrella and keeps the camera on the first visible guest, waits until the renderer draws one (a new park has no guests for a while) and saves a screenshot. It is the browser twin of the desktop's Debug-build --debug-umbrellas, not a measurement; the guests' fields are written directly, so nothing from such a run may be saved.

tools/web-perf/run.mjs --scenarios jungle,winter --zoom 70 --shot winter.png is the same capture aid for the winter extension (docs/WINTER.md): the harness hook PerfWinter dresses every guest in warm items (a head item by the guest's id, mittens on three guests in four), keeps the camera on the first visible guest, waits until the renderer draws an item and saves a screenshot after ten more seconds, so the followed guest has left the entrance. Not a measurement; nothing from such a run may be saved.

The browser holds 60 fps at zoom 300 with no long task: against the same second window at zoom 110 the main thread is busy 1.3 points more (12.7 % against 11.4 %) and the 95th percentile frame is 0.2 ms longer. The Jungle park has few guests, so this is the empty-park case; a crowded park was not measured in the browser.

Event hitches (October 19, 2026)#

The game stuttered in the browser at some in-game events. The events scenario measures them: node tools/web-perf/run.mjs --web <wwwroot> --game <folder> --scenarios start,jungle,events --music. --music keeps the advisor's speech on, so its decoding is measured too; Chrome stays muted. Every exported frame of at least opentpwPerf.markMs (8 ms; 40 ms during the cold start) carries the game's named work of that frame. FrameMarks sections cover the frame, update, draw, park, level and simulation parts, and every LoadProfile section counts as load:<name>. Off, a section is one boolean test. --profile adds a CPU profile (Profiler domain, 250 µs samples). For each slow frame it lists the hottest functions, the call stacks six frames deep (stacks) and the game functions behind the runtime's time (owners). The AOT module's functions appear as wasm-function[n]. --symbols names them from the publish's Emscripten symbol map: publish with -p:WasmEmitSymbolMap=true and pass obj/Release/net11.0/wasm/for-publish/dotnet.native.js.symbols. The dotnet.native.*.js.symbols copied into wwwroot is the runtime pack's, not the AOT module's. New hooks in Program.Perf.cs drive the events: PerfOpenWindow, PerfSpeed, PerfAdvisorAdvice, PerfCheat, PerfResearch, PerfSkipToBoundary, PerfCrowd, PerfBuildCoaster, PerfAutosaveDue, PerfPlaceObject and PerfFrameMarks. As with the other hooks, a park they touched is not a real run. The page puts them on the devtools console (as opentpwPerf.program) only on a loopback address with ?perf=1; they are no security boundary, since the .NET runtime lets a console reach every [JSExport] of any page (getDotnetRuntime(0).getAssemblyExports), and they change only the game in that tab.

PerfResearch completes research items as a researcher's points would, with the park's events. PerfSkipToBoundary runs the economy alone to 45 ticks before a month or year boundary, and the park then crosses it at the fastest speed. The soak runs 30 s at the fastest speed with the Belly Bounce, the shops, the coaster and about 400 guests. That covers thought balloons, ride and coaster runs with guests boarding, arrivals and month ends as they happen. A ride start with boarding guests was not measured as an event of its own.

Published AOT builds, origin/main eaf1ef83d without (before) and with these changes (after). Both builds carry the harness. Chrome 155 headless and muted, Apple M5 through ANGLE/Metal, 1280 x 900, Jungle Full Simulation. Values are medians of three alternating runs of each build, in milliseconds: worst frame and p95 of the frames after the event. The machine carried other work (load average about 12), so differences of a few milliseconds are noise.

EventBefore: worstBefore: p95After: worstAfter: p95Cause (from the profile)
Park start, largest frame713234the entering frame, before and after
Park start, entering frame572147before: restart snapshot (System.Text.Json metadata for the snapshot types about 315 ms, asset manifest hash about 120 ms, capture about 85 ms) and the advisor (welcome line decode); after: capture 82, advisor creation 58, first speech play 22, first draw 19
Park start, largest frame before entering21683the economy step: case correction of archive member paths in the Emscripten file system (BaseFileSystem.MatchCase, about 120 ms of lookupPath); after: the economy's own catalogue and balance parsing
Park start, the gate sign step145-15773-74x87 emulation of the gate sign (SignMaskShaping, SignEffectShape, SignRelief)
Park ready after the click9,7639,293
First open of a HUD window (11 windows, range)13-421.7-2.78-182.4-6.4before: the advisor's line decoded in one frame (Mp2Decoder.Synthesis.Run, 17-50 ms per line, the most frequent hitch); after: decoded in 5 ms slices, which raises the p95
Reopen of a HUD window (range)4-381.7-4.02.5-92.3-7.3the advisor's line, as above
First buy preview, Belly Bounce2022.5552.1sign composition in the draw; after: Ext.Add in SignEffectShape.Blur and SignRelief
Build Belly Bounce, Balloon Shop, Burger Shop2.7-9.22.1-2.63.3-7.02.2-2.4
Rain, thunderstorm, clear2.3-10.61.6-1.92.1-3.61.4-1.5
Bus arrival3.02.17.31.5noise
Evening dusk, night, day2.3-5.21.8-1.91.5-3.31.3-1.4
Research completes19.42.06.91.5before: the advisor's line
Autosave (capture, then slices)41.91.936.71.4the live capture, which must finish in one frame: CaptureResumeSnapshot and its ValidateSnapshot (ParkLayoutSnapshot.ValidateCells, ValidateShape, ValidateGuests)
Month end7.32.13.81.7
Year end26.52.37.62.6before: the advisor's line
Coaster built (station and circuit)20.32.116.51.7first use of the coaster's models and textures (level.entities)
Crowd of 400 guests added13.93.46.32.9
Soak at the fastest speed (30 s, 406 guests)21.33.410.63.0before: advisor lines

The build of a park now takes about 35 frames instead of 16, each within the 12 ms budget, and the park is still ready about 0.5 s sooner.

Changes#

The entering frame (October 21)#

After the changes above, the frame that enters the park still took 147 ms. The rest of it came from the runtime's first-call work (method initialization and generic instantiation in the AOT build) and from file reads that only the entering frame made. Measured on published AOT builds of this branch after merging origin/main 926db9535, without (before) and with (after) the changes below, same machine and harness as above, medians of three runs, in milliseconds. The FrameMarks names in the table come from the entering frame:

Part of the entering frameBeforeAfter
Whole frame (also the largest frame of the park start)21685
Construction part (the last entry of the build-frame list)13435
Restart capture (load:restart-capture)717
Advisor creation (load:advisor)376
First speech (advisor.play; 5-6 ms of it is the first 5 ms decode slice)148
First draw (frame.draw)1919
Park HUD, created and first update (load:park-hud, park.hud)2316
Park ready after the click9,1999,147
Largest frame before entering7475

The build takes 38 frames instead of 34. No frame of 40 ms or more follows the entering one. The other events of the events scenario stayed within noise.

The welcome line's PCM was still decoded over frames (the sliced path above), starting in the entering frame. Since C2c-2b-3e the park build decodes the lines a park's start says first (the Welcome, which has one response, and in Instant Action the prebuilt park's) ahead, a 5 ms slice of their MPEG a step (AdvisorEntryPreparation.LineSteps), and the advisor takes their PCM when it says them; a line decoded ahead starts at its time instead of a few frames late. The first draw did not change. The CPU profile of that frame did not name its cost, because the profile's window and the frame did not line up. Pipelines are already created with their materials during the build.

The first draw and the park HUD (October 21)#

The entering frame's first draw (frame.draw, 19 ms) and the park HUD (load:park-hud and the HUD's first park.hud, 16 ms) were the two largest parts left. Two harness changes named their cost:

What the profile and the marks showed, on the published build before the changes below:

PartmsWhat it is
Sky (draw.sky)4-8first-time work: Level.DrawSky created the sky on its first call. That reads the colour grid (a .tga decode, most of load:image-decode), loads the cloud and cylinder textures, and builds the geometry and two materials.
Interface textures (draw.overlay)5-6first-time work: the overlay decoded, keyed and uploaded each image of the HUD's first draw (UiImages.Load; thoughts2.wct, thoughts.wct, purple_button.wct, meter.wct, b_money.wct and smaller ones) and smoothed the font atlas
Entities (draw.level)3.4the first call of each renderer's draw (RideHeadRenderer, BalloonRenderer, GuestRenderer, LitterRenderer 0.4-0.6 ms each). The GPU calls are small: all gl.* marks together stay under 1 ms, 24 material resource sets take 0.3 ms. The rest is the AOT runtime's first-call work.
Advisor model (draw.advisorModel)1.9its first pose and the render target of its image; the advisor itself is made in this frame
HUD draw (draw.hud)1.2the first call of each widget's draw
Deletions at the frame's end (frame.post)0.4-2.9the retired lobby's textures, one WebGL deleteTexture each
HUD creation (load:park-hud)6.6ParkHud.Build (about 3 ms), the build catalogue's grouping (OriginalBuildCatalog, about 2 ms, mostly its LINQ GroupBy's first use) and the rest of the constructor
HUD first update (park.hud)8.7spread over the update's parts, each paying the runtime's first-call work: UpdateBlueprint (BlueprintMarkers.Show, about 3 ms), UpdateCursor, SampleHappiness, HandleCheatKeys and smaller ones

Two changes move or spread the first-time work. The picture does not change: the same sky, HUD and textures are made, only earlier, and a deletion only releases what nothing draws any more.

Measured on published AOT builds of this branch without (before) and with (after) these changes, both with the new marks, same machine and harness as above. Values are medians of five runs of each build, in milliseconds:

Part of the entering frameBeforeAfter
Whole frame8360
Construction part (the last entry of the build-frame list)3627
First draw (frame.draw)19.47.7
Sky (draw.sky)7.60.4
Interface textures (draw.overlay)5.31.0
Entities, advisor model, HUD draw (draw.level, draw.advisorModel, draw.hud)3.4, 1.9, 1.23.1, 1.8, 1.0
Image decoding (load:image-decode)4.90
HUD creation (load:park-hud)6.60
HUD first update (park.hud)8.77.4
Largest frame of the park start83 (entering)73 (a build step)
Largest frame before entering7771
Park ready after the click9,1579,137

The build takes 39 frames instead of 38; each new step stays within the 12 ms budget. No frame of 40 ms or more follows the entering one. The entering frame is no longer the largest frame of the park start: the economy and gate sign steps of the build are. The events scenario's other events stayed within noise. Some runs of both builds met other work on the machine, which raised the p95 of every event in them to about 5 ms.

What the entering frame still spends, apart from the advisor's creation, first update and first speech (about 15 ms together) and the live capture (7 ms):

Build steps (October 21)#

After the entering frame's changes, the largest frames of the park start were steps of the park's build. Each did one piece of work at once. The harness named them: --profile with the new --cold-mark-ms option marks and profiles every frame of the cold start from the given length (20 ms here), and tools/web-perf reports the cold start's frames over 33 ms. Measured on the published AOT build of origin/main 6ecadcbd9, same machine and harness as above, one profiled run (times under the profiler run about 1.5 times longer than without it). Construction ms of one step:

StepmsWhat it was
Economy77-84ObjectCatalog.Load, called inside the economy's catalogue for the mods' objects (EconomyObjectCatalog.AddModObjects): with the official extensions on, their content roots count as mods, so the whole object catalogue was read here at once (about 44 ms). The economy's own catalogue (13), the balance settings (4) and the ParkEconomy constructor (10, of which ParkResearch 6).
Terrain and gate sign44the gate sign's composition (SignSurfaceComposer.Compose, 30: the effects 17, of which the shape's blur 6 and the relief 11; the paint masks' shaping 6; the text masks 5) and the blueprint markers
Objects53the ride script handler table (RideOpcodes, 33): its static constructor searched the assembly by reflection and compiled every handler with Expression.Compile, on the first object's script
Guests70SetupGuests (61): the kid, pool, umbrella and winter sprite sets and anchors (6-8 each), and the renderers' atlases and their texture uploads (8-10 each)
Staff, gate and economy58the staff's sprite sets (16) and renderer (17), the level HUD (7), the placed particles (4)
Entry preparation40the warm-up of the economy capture (15-20); in another run the advisor's settings (30, of which 10 a scan of every message per descriptor row in AdvisorTables.UnproducedMessages and 8 the scan messages)
Terrainunder 33the ground mesh and its textures, the terrain meshes' textures

The work was not the problem; each step held a whole part of it. The steps were split, and the steps that remained long now start a frame of their own. What each step makes, and the order, is unchanged:

Tests: BuildStepsTests compares the economy made in steps with the one made at once (Full Simulation and Instant Action Jungle, its whole save and import evidence), signs composed in interleaved steps with signs composed at once, the opcode table built in steps with every handler in the assembly's order, and the unproduced advisor messages with the former scan. The front-end smoke also compares the gate sign's pixels of the park built over frames with the park built in one go (digest F22DF07B950D3E1C both). The world hash 9C04AE5746B2E140, 124 entities and 14 objects are as on origin/main. The sign corpus hashes, the restart snapshot's tests (its capture warm-up changes neither the park nor its snapshot) and the determinism tests pass.

Published AOT builds of origin/main (before) and this branch (after), alternating, medians of three runs, in milliseconds. The machine carried other work (load average 6-14):

MeasureBeforeAfter
Largest frame of the park start80 (the economy step)56 (entering)
Largest frame apart from the entering one8036 (the advisor's global model)
Largest construction part of a build step (the harness's build-frame list, without the entering one)7934
Build steps whose construction part is over 20 ms123
Frames over 33 ms, from the click until 5 s after the park is ready82
Frames of 50 ms or more, same window51
Entering frame6856
Of it: the HUD's first update (park.hud)14.94.8
Of it: the restart snapshot (load:restart-snapshot)8.211.7
Frames the park is built over4063
Park ready after the click9,2279,376

The park is ready about 150 ms later: it is built over 63 frames instead of 40, and each frame also updates and draws the lobby. The frames over 33 ms left are:

The restart snapshot in the entering frame rose by about 3.5 ms. Its profile shows the runtime's generic-context work (mini_init_method_rgctx and its hash table) in the snapshot's asset filter (ParkResumeMods.AssetsForUse), which happened elsewhere before. The filter's warm-up with the manifest's own type took half of it back. Such first-call work moves between frames when other first calls move, so this part of the entering frame varies by a few milliseconds.

The lobby's enter-park button (October 21)#

The lobby's enter-park button (enterPark, b_entpark) opens the island's theme start: the parks to continue and New park, or the game mode screen when there is none. To offer the saved parks, the click reads them (ThemeContinuation.Probe, AutomaticThemeContinuation.Newest: each slot's file parsed and checked, the automatic ones also serialized again for their digest). The first such read of a session also made the world-save codec's reflection metadata, which took a whole frame. The new lobbyEnter scenario measures it. After the Jungle park, it leaves the park to the lobby, which writes the automatic checkpoint, then loads the page again in the same profile, as a player returning to the game does. It then clicks the button three times. Each click is followed up to the screen it opens and back to the lobby.

ClickBefore: frameBefore: until the screenAfter: frameAfter: until the screen
First click of the session397402126132
Second click53636774
Third click53636267

Values are in milliseconds: the worst frame after the click, and the time from the click until the game reports the theme start. Medians of five runs of each build. The later clicks differ only by the machine's load: in the two pairs of runs taken alternately they were 59-69 ms before and 56-67 ms after. The first click's frame was the codec's metadata (ParkResumeJson.Deserialize: decode_klass_ref, mono_metadata_type_hash and the other type work of the runtime). Every click then reads and checks the saves. The automatic ones are also serialized again for their digest (menu.themeStartSaves, 45-65 ms). The first click still spends about 60 ms more than the later ones, mostly in the runtime's interpreter on the codec's first runs (mono_interp_exec_method, do_jit_call). No click was ignored or needed a second click in these runs. The harness clicks through the game's own input injection (PerfClick), not through the browser's mouse events, so a focus problem of the page itself would not show here.

The codec's metadata in the lobby's idle frames. When any theme has a saved park, the lobby's frames now make that metadata in steps (ParkResumeJson.WarmupSteps, the same steps a park's build runs for its first restart snapshot). Each frame runs steps until at least 4 ms have gone. Nothing is read or written, and the codec's output does not change. A click before the steps end makes the rest itself, as before. A session without saved parks skips it. Every click still reads the saves, as before (about 50 ms); caching them would need a guarantee that the files have not changed.

The park door (October 21)#

The new door scenario clicks the entry price window's door through the HUD's input three times in the fresh Jungle park (closed): open, close, open again. It is also the last part of the events scenario, so the events before it keep their closed park. The new PerfParkOpen hook reads the door's state; the clicks go through PerfClick.

ClickWorst framep95Until the economy reports the new state
First (opens)9.51.417
Second (closes)3.01.511
Third (opens again)3.61.513

Values are in milliseconds, medians of three runs of the final build. The state time includes the harness's polling.

The door's first opening has no hitch: the economy reports the park open within a frame or two. The wait after it is the original's arrival schedule. A park's first arrival group is due at turn 604 of the economy's clock, counted from the park's start and not from the door (GuestSimulation.UpdateArrivals; a turn is 248 ms, so about 150 s at normal speed). Then the bus brings the group. The door does not reset that timer. In the long run, the first new guest was in the park 146 s after the first click. Nothing was changed there.

Remaining hitches#

HitchWorst frameCauseWhat a fix would take
Entering the park56 msthe advisor's creation, first update and first speech (about 17 ms), the restart snapshot's live capture (12 ms), the first draw (8 ms: first calls of the entities', the advisor model's and the HUD's draws), the HUD's first update (5 ms) and the park's audio (3 ms)first calls are the runtime's: warming them needs a side-effect-free way to run the code once before entering
Autosave capture37 ms, once per autosave intervalCaptureResumeSnapshot and its validation in the frame the autosave is duethe same deferred validation; a cheaper capture of the cell layout
First buy preview of a ride with a sign55 msthe sign's effects: Ext.Add in SignEffectShape.Blur and the relief's square roots through BigInteger (Ext.IntegerSquareRoot)a word-pair square root and add-free blur passes, or composing the sign over frames before the preview shows it
The advisor's global model (a park build step)about 35 msone step reads the model, its textures and its clips (AdvisorRig.Load)a read in steps: AdvisorEntryPreparation.Prepare would need steps, with its log capture around each one
A click on the lobby's enter-park button with saved parks50-65 ms per click (125 ms for the session's first)the theme start reads and checks every saved park of the island, and serializes the automatic ones again for their digestkeep what the probe read for files that have not changed, or read them over frames before the screen shows
The restart snapshot's first slices after entering30-35 msits validation of the cells and its first serialization slices meet their first callsfiner validation slices
Coaster first built17 msfirst use of the coaster's models and texturespreload them with the park's catalogue
Advisor line, while decodingp95 about 6 msthe 5 ms slicesnone needed (under a 60 Hz frame)

Joining a shared park (October 22, 2026)#

A guest's join of a co-op session builds the host's park over frames beside the live scene, as a park start does, and swaps it in once it is checked (docs/COOP.md, "The game's join"). scripts/measure-coop-join-browser.sh measures it in a published page: the co-op join smoke's measuring join phase (tools/web-coop-join.mjs, ?coopSmoke=1) over a host phase recorded once by the desktop's Release build of the same source. Chrome 155 headless and muted, Apple M5 through ANGLE/Metal, 1280 x 900, no frame cap; medians of five runs compiled ahead of time and three interpreted, in milliseconds. The native column is the desktop's first build in a process (Release, compiled as it first runs), from the measurement of C2c-2b-1; it times the update only, the page also each whole frame. Every value of every run is in docs/COOP.md, "Measurements".

Part of the joinAOTInterpreterNative
The save's parse (one step)374508167
The objects' restore and the coasters (one step)3201,413436
The level's last step141307172
The guests (one step)85250135
The check at the cut7610145
The swap's frame (the check, the swap and the rest of the frame's update)331644325
The longest frame while building, with its drawing3921,420440 (update)
The wait for the level's files375 frames, 6.4 s383 frames, 7.2 snone
Catching up after the swap638 ticks in 10 frames, 0.59 s758 ticks in 29 frames, 2.0 s1 tick, 1 frame
The resync over the guest's park, longest frame14233388 (update)

Where a join's slice ends (C2c-2b-3a)#

On main after the build steps were split (#741), the join's level steps had shrunk (the level's last step 62 ms ahead of time, the guests 24 ms), but the wait for the files still spun, and the save's parse made the codec's reflection metadata in one go. C2c-2b-3a ends the wait's slice after one question, ends a slice before a step known to be long, and makes the metadata in steps of its own. Same machine and harness, medians in milliseconds (docs/COOP.md, "Measurements"):

Part of the joinAOT beforeAOT afterInterpreter beforeInterpreter after
The wait for the level's files371 frames9 frames387 frames8 frames
The join's build403 frames64 frames471 frames107 frames
From asking to join to the swap (the page's frame record)8.9 s2.7 s13.2 s5.2 s
The save's parse (the metadata in steps after)38488582191
The objects' restore and the coasters2832881,3611,230
The swap's frame, with its drawing341345658627
Catching up after the swap0.57 s0.26 s2.17 s0.75 s

The page copies a theme's files between its frames, so the loop that spent every frame's budget asking for them most likely kept that copy waiting; these timings do not follow the copy itself. The measuring smoke's marks were on while each park was built, where the baseline had none, so small differences are no finding. The swap's frame is now the longest of a join ahead of time. Its marks show the joined park's first update of its level (185 ms: the pools' 72, the entities' first use of models, textures and pipelines 67, the first simulation step 45), the check at the cut (75) and the advisor's first update (39). A park start prepares much of that first-time work in its build (GameFlow.PrepareEntry); the join's build does not yet (C2c-2b-3c).

The swap's frame (C2c-2b-3c)#

C2c-2b-3c checks the joined park at the cut in the frame its build completes in and swaps it in the next, holds the stream's ticks to the frame after the swap, and prepares the park's first frame in a last build stage (prepare, [EXT:park-entry-preparation]): the coasters' views, the pool bridges' meshes and the swimmers' sprite sets. Same machine and harness, medians of three runs (five before) in milliseconds, compiled ahead of time (docs/COOP.md, "Measurements"):

Part of the joinBeforeCheck and swap apartFirst frame prepared
The swap's frame, with its drawing345229119
A resync's swap's frame, with its drawing14412139
The frame after the swap, with its drawing38.652.753.2
A join's longest frame, with its drawing345 (the swap's)290 (the objects' restore)292 (the objects' restore)

The check (74 ms) now shares the frame its build completes in, the first ticks (a replayed placement's first models among them) the frame after the swap, and the prepared work 113 ms over 7 build frames, its longest step 39 ms. The swap's frame keeps the advisor's first update (37 ms), the pools' (23 ms, the swimmers' renderer still made there) and the session's step (13 ms). The longest frame of a join is now the objects' restore (C2c-2b-3d).

The objects' restore over steps (C2c-2b-3d)#

C2c-2b-3d restores a joined park's saved objects one a build step instead of all in one, so the build's budget ends its slices between them (ParkLayoutSnapshot.RestoreObjectSteps). Same machine and harness, medians of three runs in milliseconds, compiled ahead of time (docs/COOP.md, "Measurements"):

Part of the joinBeforeAfter
The longest build frame, its update29087.0
The objects' sections287266
The level stage672 over 23 frames622 over 27
A join's longest frame, with its drawing292 (the objects' restore)110 (the swap's)

The restore's longest step is now its first: the snapshot's checks and the first object, 87 ms. A type's sign is still composed on the step of its first object (134 ms in all), since the page has no worker to compose it on; on the desktop the sign worker takes most of that work. The swap's frame is a join's longest again; its largest parts are the park's first update of its level and the advisor's first update, about 35 ms each.

The advisor prepared for a join (C2c-2b-3e)#

C2c-2b-3e reads in the join's build what the joined park's advisor reads for its first line, as a park start's build does, and decodes that line ahead (docs/COOP.md, "The game's join"). Same machine and harness, medians of three runs in milliseconds, compiled ahead of time:

Part of the joinBeforeAfter
The swap's frame, with its drawing11090.1
Of it the advisor's first update33.94.3
The first frame after the swap, with its drawing48.541.8
The build's prepare stage103 over 7 frames187 over 14
A join's longest frame, with its drawing110 (the swap's)94.4 (the restore's first step)

The prepare stage's longest step is still a coaster's (38 ms); the advisor's steps took at most 14 ms, and the line's decode is spread over 5 ms slices. The save stage, which this change does not touch, took 87.6 ms against the before's 80.7. A join's longest frame is now a build frame (94 ms with its drawing, median); the longest steps are the restore's first (93 ms: the snapshot's checks and the first object with its sign) and the save's parse (88 ms).

A type's first use in steps of its own (C2c-2b-3g)#

C2c-2b-3g reads what each saved type's first object reads in build steps of its own before the restore places the objects: its model and clips, its sign, its textures and its hoarding (docs/COOP.md, "The game's join"). The page has no sign worker, so it composes a type's sign over the composition's own steps and hands it to the type's first object as the desktop's worker hands over its signs. The restore's checks end a step of their own, and the layout's checks format a message only when one fails. Same machine and harness, medians of three runs in milliseconds, compiled ahead of time; the before is b5de0764e, which only adds the measuring smoke's records of the build's long frames:

Part of the joinBeforeAfter
The restore's first object94.0, with the checks12.1
A type's first object, the longest step62.2 (the water ride)20.5 (the minecart)
The types' own steps, the longestnone13.5
The validation stage's longest step27.46.7
The cells' checks, three a join63.112.4
The level stage656 over 27 frames620 over 41
A join's longest build frame94.1 (the restore's first step)86.3 (the save's parse)

The snapshot's checks, before in the restore's first step with the first object, are a step of their own under the budget. The signs cost the same (141 ms composed in steps ahead against 142 ms on their objects' steps), now spread over the level's 314 more steps, and no frame of the objects' part of the level reaches 30 ms. Of the minecart's 20.5 ms, 16.8 ms are its coaster ride's first use. A join's steps of more than 50 ms are now the save's parse (86 ms), the check at the cut (71 ms, in the frame its build completes in) and the level's last step (64 ms, the resume's restore).

The save's read over steps (C2c-2b-3h)#

C2c-2b-3h parses a join's save a 32 KiB slice a step, with the serializer's own asynchronous reader fed a slice a step (SlicedJsonDeserializer), and checks its shape in steps of their own (docs/COOP.md, "The game's join"). The page has no thread to parse on, so the parse is spread over frames instead. Same machine and harness, medians of three runs in milliseconds, compiled ahead of time; the before is 9e48a4ee4:

Part of the joinBeforeAfter
The save stage's longest step91.414.7
The save stage91.4 in one step90.0 over 43 steps and 7 frames
A resync's save stage's longest step53.83.5
A join's longest build frame91.5 (the save's parse)76.9 (the level's last step)
A resync's longest build frame55.730.3

The parse costs what it did, spread over its steps. The validation stage's last step, the comparison of the asset manifests, took 19.7 ms in five of six runs against 7 to 9 before, with no garbage collection in it; its cause is not known. A join's steps of more than 50 ms are now the check at the cut (71.5 ms, of which 56.5 ms is the economy's serialization for its digest making the serializer's metadata in a process's first check; 7.9 ms in a resync) and the level's last step (69 ms, of which the resume's restore takes 59 ms against 6.3 in a resync). Both are mostly a process's first use of their code. The review fixes after the measured commit make the asset manifests' comparison, among the save's last eager checks, format no message while its checks hold.

The check and the level's last step (C2c-2b-3i, 3j)#

Both were mostly a process's first use of their code: compiled ahead of time, the code a call runs for the first time still costs its compilation by the browser's WebAssembly engine, which is not the serializer's metadata alone. C2c-2b-3i runs the economy digest's serialization once ahead in the join's build, over the joined park's economy, a part of its save a step (a last build stage, digest), after making the metadata in the codec stage; C2c-2b-3j restores the saved simulation a part a step (docs/COOP.md, "The game's join"). Same machine and harness, medians of three runs in milliseconds, compiled ahead of time; the before is 0d7383931:

Part of the joinBeforeAfter
The check at the cut71.513.4
The level stage's longest step68.9 (its last)28.1
The digest stagenone49.1 over 43 steps and 3 frames, longest 23.7
A join's longest build frame76.9 (the level's last step)40.5
A resync's digest stagenone25.0 over 3 frames

The metadata with the resume's steps alone took the check to 46 to 81 ms. No build frame of a join now reaches 50 ms. The swap's frame measured 93 to 106 ms with its drawing against 87 to 92 before, but its pool swimmers vary from run to run: in alternating runs of both pages the before's swap frames took 101 to 119 ms and the after's 95 to 114.

A browser host (C2c-2b-4)#

The co-op join smoke's host phase runs in the page, and the desktop's join phase replays its recording with every checkpoint equal (docs/COOP.md, "The browser's host"). Same machine and harness, medians of three runs in milliseconds, compiled ahead of time. A capture's cut takes 17.0 ms (the desktop's 9.9) and 20.7 at the second capture, and its save serializes in slices, the longest 22.7 ms in the median run (26.6 in the slowest). The stream's first checkpoint after the park was shared took a frame of 69 to 77 ms, the economy's digest running its code for the first time. The smoke's host now runs that code once ahead before it hosts (CoopSession.PrepareHostSteps, which the game's own sharing does not run yet), and that frame takes 31 to 33 ms or less. What remains of a host's work is the digest at each checkpoint, once a second: at the session's end 30 ms in a frame of 33 to 37.

The digest's canonical text (C2c-2b-4b)#

The session digest's economy part is now written as canonical text straight from the park save's bytes, without a JSON tree, and hashed a byte a step; the text and the hash are the same (docs/COOP.md, "The digest's canonical text"). Same machine and harness, medians of three runs in milliseconds, compiled ahead of time; the before is 996b0e133:

PartBeforeAfter
The guest's check at the join's cut12.611.2
The guest's check at the resync's cut7.65.9
The join's digest stage45.542.6
The resync's digest stage23.311.8
The page host's digest at capture 1's cut, at capture 2's7.2, 11.76.1, 11.5

The economy's canonical text takes 4.4 to 8.8 ms of a digest in the page host instead of 7.9 to 14.0. The page host's checkpoint frames near the session's end take a median of 16 to 18 ms a run instead of 17 to 23, at most 21 instead of 32, so none reaches 30 ms any more. The save's serialization (8 to 18 ms in those frames, as before) is now the digest's largest part in the page.

Source: docs/BROWSER-PERFORMANCE.md in the project repository.