Skip to content

Metrics and debug views ​

See what a frame costs, look inside the scene with debug views and overlays, read the Console, count what is on the map, and fix the map's problems.

See what a frame costs ​

  1. Open Metrics in the bottom drawer.
  2. Read how the frame is spent: the editor's own work and the renderer's parts (side views, culling, picture, cascades, uniforms, uploads, encoding; the GPU's, the span of the frame's passes on the card), and its phases (tool, panels, camera, world, drawing, overlay).
  3. Read what is drawn (draw calls, meshes, triangles, textures), memory, what is merged and what is at which level of detail.
  4. Check the list of recent frames over 33 ms, each with the phase that took most of it.
  5. For each layer of grass: chunks and tufts drawn of those laid, the last laying and a frame's time, and cells burning (of the game played here while it is shown).

Metrics measures only while it is open.

Find what hitches the first time ​

  1. Open Metrics (or, in a game played here, its 📊 window).
  2. Read First seen: the latest frames over 25 ms, each with what was compiled and built in it, the longest first: a shader with its material, a model with its unit type, and what made it (close-up, level, warm, frame).
  3. Under it, how many shaders and models were made so far, and how many of them by the warm-up.

A frame that shows a cause the warm-up could have made ahead is one to add to the game's warm-up (GameView.world.warm). See Warm-up and first-seen hitches.

Show a debug view ​

  1. Open View › Debug view (or search "debug").
  2. Pick one: Wireframe, Shadow cascades, Navmesh, Overdraw, Detail levels, Pick ids or Fog texture.
  3. Pick it again to turn it off.

The navmesh is made from the map as Play here would make it, so what stands on the map cuts it. A game played here shows the same view. See Debug views for a game's own.

Show an overlay ​

Press Shift and a letter (or use the View menu):

KeyOverlayShows
Shift+PWhere one walksWalkable ground
Shift+BWhere one buildsGreen where a building can go
Shift+KSlow groundGround that slows units
Shift+LCliff levelsEach cliff level in its own colour
Shift+YLayers of cellsThe game's cell layers
Shift+JGrass stylesEach style of grass and bushes in its colour
Shift+UGrass stateBurning, burnt, cut, flattened and growing grass
Shift+HHiding patchesEach patch of grass that hides, outlined
Shift+GGridLines between cells
Shift+TTrianglesThe edges of every triangle drawn, over the picture
Shift+VDetail levelsWhat is drawn at which level, and what is not drawn
Shift+FFootprintsThe cells each building and mine takes
Shift+CCamps noticeHow far each camp notices who comes near
Shift+NNamesNames of what the rules know by name

Grass state and Hiding patches show the map as edited (Grass and bushes in the editor), and, while it is played here, the game's grass as its rules have it, over the game's ground.

Triangles are drawn over the finished picture, so mist, clouds and night do not hide them. A game shows the same with its debug panel's Show triangles.

Read the Console ​

  1. Open Console in the bottom drawer. The bar counts its errors (red) and warnings.
  2. Show or hide levels with their buttons, or type to find words.
  3. Click a line to see it whole. A stack's places link to the code; a line about a thing on the map selects it; a line with a file or unit type opens the code.

It has everything said while the editor is open: the editor's lines, the client's (a model that did not load), a game played here, and uncaught errors. Repeated lines show once with a count. The last thousand lines are kept (editor.logs).

Fix the map's problems ​

  1. Look at the Problems count on the bottom bar, and open Problems in the drawer.
  2. Click a problem to select what it is about and look at it.
  3. Fix it, or press Silence beside it to ignore that rule for this map. Silenced rules are listed under the problems, to check again.

Play does not start while the map has an error. The checks cover unknown types, things off the map or in deep water, a name used twice, starts that cannot reach each other, mines nobody can reach, too many players, missing files, heavy models with no lighter levels, and how the map looks (lights, mist, weather, tile borders, decals…).

Count what is on the map ​

  1. Open Statistics (right rail, or View › Statistics).
  2. Read, per player: units and buildings with supply, mines and trees within 16 cells of their start.
  3. Read the ground: cells in play, the share walked on and built on (click to show the overlay).
  4. Read Triangles drawn now against what each quality allows (300 thousand on low, a million on medium, three million on high).

Click a count to select what it counts.

Set the editor graphics ​

  1. Open File › The editor's settings, then Graphics (or search "graphics").
  2. Pick a preset, or set shadows, render resolution and anti-aliasing (from the next time the editor opens).
  3. Set Frame budget (6 ms; 0 for no limit), the most frames a second (0 for no cap), When left alone (keep drawing, 15 frames a second, or stop until something wakes it).

A game played here keeps its own frame rate and frame budget. View › Merge scenery draws every model as copies instead of merged chunks, to compare; View › Full detail draws everything as made.

Add checks of your own ​

Return problems from your game's check:

ts
export function checkField(map: GameMap): MapProblem[] {
	const problems: MapProblem[] = []
	if (!map.paths.some((path) => path.name === ROAD_PATH)) problems.push({ message: 'The invaders need a road: a path called "road"', error: true })
	// ...
	return problems
}

Give it in Rules.editor (MapEditorDef.check). A problem that says what it is about ({ about: { thing: id, kind: 'td.clearings' } }) is selected by a click. MapEditorDef.silence silences rules for every map of the game. Check maps in tests with checkMap:

ts
checkMap(map, registry, [...LOOK_RULES, ...(view.mapRules ?? [])]) // as the editor checks it

apps/example/tests/mapCheck.test.ts checks every map of the repository this way, and npm run map check does it from the command line.

In code ​

ts
editor.debugView('navmesh') // null to turn it off
editor.debugViewShown
editor.toggleOverlay('walkable')
editor.toggleOverlay('grassState') // 'hiding' for the patches that hide
editor.perf // what Metrics measures
editor.perf.sample(0)?.firstSeen // the frames over 25 ms with what was compiled and built in them
editor.statistics.map() // the counts, with the things counted
editor.statistics.triangles() // { drawn, budgets, fits }
editor.setPrefs({ maxFps: 60, frameBudget: 6, whenIdle: 'slow' })

Reference ​

Map check rules ​

Each problem says its rule and what it is about (an object, a camp, a region, a point, a path, a doodad, a player).

RuleWhat it means
unknown-type, unknown-creeps, unknown-tileSomething the game does not have
off-map, region-off-map, region-past-edge, path-off-mapOff the map or past its edge
deep-waterIn deep water, and does not sail or fly
name-twiceA name used twice
start-blocked, starts-apart, unreachableStarts or mines nobody can walk to
too-many-playersMore players than the game allows
missing-targetA field names a region, point or path that is gone
missing-fileA model, sound or music with no file
heavy-modelA model over 3 MB with no lighter levels
empty-random-group, unknown-random-group, empty-item-table, unknown-item-tableRandom groups and item tables
unknown-cameraA camera that is not there
path-tile-missing, path-profile-shortA path's paint or bed
prefab-loop, prefab-source-missingPrefabs
objective-*, rule-*Objectives and rules
other-racePlaced for a player whose race may not have it
unknown-foliage-styleGrass painted with a style neither the game nor the map has
foliage-hides-nobodyA style that hides but is shorter than every unit on the ground
foliage-no-fireA flammable style in a game whose grass has no fire
gameA game's own check that names no rule

The engine's checks are MAP_RULES (each a MapRule: { id, check(map, registry, say, context) }); the client's look checks are LOOK_RULES, and a view adds its own with GameView.world.mapRules. Silenced rules are kept in GameMap.silence.

Graphics settings ​

SettingKept inDefault
Graphics preset and partseditor.prefs.graphics
Most frames a secondeditor.prefs.maxFps0 (no cap)
Frame budgeteditor.prefs.frameBudget6 ms
When left aloneeditor.prefs.whenIdleDraw as always
Merge sceneryEditorPrefs.mergeSceneryOn
Full detailEditorPrefs.fullDetailOff
Animate unitsEditorPrefs.animateUnitsOff

Triangle budgets are TRIANGLE_BUDGETS over GameView.world.quality.triangles; mapStatistics(map, registry) counts without an editor.