Skip to content

Warm-up and first-seen hitches ​

The first time something is drawn, the card makes its pipeline (its shaders, for the targets it is drawn to) and the client may build its model: a unit type's model is read as its first unit comes up close, an effect's particles first need their kind of stream, a cut's pass is first drawn. Each costs a few milliseconds in the frame that draws it, and several in one frame is a hitch. The warm-up makes them ahead, behind the loading screen or a piece a frame; the first-seen report says which frames went over their budget, and what was made in them.

Quick start ​

Nothing to do: a game warms up behind its loading screen by itself. It reads ahead the model of each unit type on the map, draws the view behind the loading screen until a frame asks for no new pipeline, plays the effects asked for once where the camera looks, so that their streams and the pictures of their particles are made, and makes the cinematic cut's pass ahead. The renderer makes each material's pipelines for every pass it is drawn in (the view's, the sun's cascades, the velocity of the temporal pass, the outline, the glow) as it is made, not as a frame first draws it.

To see what is left, open the 📊 window (or the editor's Metrics) and read First seen: the latest frames over 25 ms, each with the pipelines made and the models built in it.

ts
export const view: GameView = {
	units: { looks: {} },
	world: {
		warm: { units: 'all', colors: 'players', fx: ['fireball', 'heal'], budgetMs: 6000 }
	}
}

Common tasks ​

Turn it off, for the game or a map or a scene ​

ts
world: {
	warm: false
} // the game
// a map's own, in its file or the editor: MapEnvironment.warm
environment: {
	warm: false
}
// by scene and map: a function
world: {
	warm: ({ scene, map }) => (scene === 'menu' ? false : { copies: 2 })
}
// one run of a game: runGame({ ..., warm: false }), or client.prepare(10, { warm: false })

The scene's say goes over the map's, which goes over the game's; false at any of them is no warm-up behind the loading screen. client.warm still warms what code asks.

Choose what is warmed ​

ts
world: {
	warm: {
		units: (type) => type !== 'sheep', // or 'map' (the default), 'all', ['footman', 'knight'], false
		colors: 'players', // or 'owners' (the default), [1, 2], [[0.8, 0.1, 0.1]], (player) => !player.creeps
		fx: ['fireball'], // or 'all'
		transitions: ['ink-wipe'], // true (the cut's, the default), or false
		view: true // the view drawn behind the loading screen (the default there; in code only when asked)
	}
}

Warm in code, at any time ​

ts
// a boss before its wave: its model read ahead, a piece a frame
const result = await client.warm(
	{ units: ['lich'], colors: [creeps], fx: ['frost-nova'] },
	{ priority: 'background', budgetMs: 2000, signal: controller.signal, onProgress: ({ done, total }) => bar.set(done / total) }
)
result.warmed // [{ kind: 'unit', name: 'lich', model: 'lich.glb', ms: 41, ready: true }, ...]
result.skipped // [{ kind: 'fx', name: 'frost-nova', why: 'unknown' }]

priority: 'block' (the default) does every piece at once: a long frame, for a loading screen of your own. 'background' does one a frame and waits for the card's pipelines before the next; waitWhile: () => client.inCinematic holds it while a cinematic plays.

Warm what loads later ​

Unit types whose models come after the game started (GameView.files.later) are warmed in the background as they come, not while a cinematic plays. later: false turns that off.

Find what hitches ​

ts
client.firstSeen.hitches() // [{ frame, frameMs: 41, causes: [{ kind: 'shader', name: 'standard', cause: 'frame', ms: 5.7 }, ...], causeMs }]
client.firstSeen.events() // the latest 200 pipelines made and models built, with their unit type and what made them
client.firstSeen.onHitch((hitch) => console.log(hitch))
client.firstSeen.overMs = 33 // the budget a frame is over (25 ms)

A cause says what made it: close-up (a unit's model built as it comes up close), warm (a warm-up), or frame where nothing said. A shader is a pipeline of a kind of material, its variant and its pass (the view's, a cascade's), its sides and its blend; one prepared ahead says how long the card took (readyMs). Behind the loading screen nothing is a hitch (firstSeen.loading).

Editor ​

Metrics shows First seen for the editor's scene, and a game played here shows it in its 📊 window: each frame over 25 ms of late, its milliseconds, and what was made and built in it, the longest first, with the unit type and what made it. See Metrics and debug views.

Reference ​

WarmWhat ​

FieldWhatDefault
unitsunit types: 'map', 'all' (whose models loaded), a list, a test, false'map'
colorsplayers' colours: 'owners', 'players' (all but the neutral), ids or colours, a test of each player (read, and nothing to make: a colour is a copy's, not a material's)'owners'
fxeffects by id, 'all', or a test; each played once and stopped before a frame draws itnone
transitionstrue (the cut's pass and its copy), ids of the game's own (a mask's or a pass's), falsetrue
viewthe view drawn, all of it that is on, until a drawing makes no new pipeline (8 at most); not in the backgroundtrue behind the loading screen, false in code

WarmOptions, and WarmLook ​

FieldWhatDefault
budgetMsmilliseconds in all; what is not begun is skipped (budget), what is not made is made as drawn4000
priority'block' or 'background''block'
signalan AbortSignal (code only): what is not begun is skipped (aborted)
onProgresstold { done, total, item?, skipped? } as each piece is done or skipped
waitWhilein the background, the next piece waits while it says so (its wait is not its time)
later(WarmLook) types loaded later warmed as they cometrue
onWarmed(WarmLook) told what the loading screen's warm-up did (client.warmed)

A piece skipped says why: budget, aborted, not loaded, unknown, none (a type of parts), full (as many copies kept as may be), failed.

Kept for the older say ​

levels and copies change nothing: a copy is a place in a batch, nothing to build ahead. models (the scenery reads its own as the map is drawn) and materials (there is no scene of materials) are skipped as unknown, each asked.

Measured ​

Measured while the client drew with Babylon (2026); the renderer of our own makes its pipelines as materials are made, which leaves less for the warm-up to do.

The campaign starter's Homecoming, its intro's first 14 seconds, headless Chrome on Metal at 1200 × 800 × 2, frames not held to the display, four runs each:

Warm-upOffOn (the default)
Begin to the intro's first frame2,055 ms2,058 ms
Frames over 25 ms7.55.0
of them between 1 s and 11 s2.50.3
Milliseconds over 16.7 in them160108

The warm-up takes about 250 ms (8 pieces, 15 shaders) and the loading screen's own compiling as much less. The 31–36 ms frame at 3.6 s, mid-zoom, was the knights' swords compiled bent by their bones and the knights' copies built as they came up close: gone. Left, and named in First seen: the first frame's water (its texture arrives after) and a chunk of parts made at the first tick (37–53 ms at 0.4 s), and the trees' levels built as the camera zooms (30–50 ms at 0.4–0.8 s; the scenery's levels are not warmed). A cut compiles nothing, its first as its later ones (its frames 9–13 ms against 3 ms): its pass and its copy are made as the cinematic starts, and by the warm-up.