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
- Open Metrics in the bottom drawer.
- 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).
- Read what is drawn (draw calls, meshes, triangles, textures), memory, what is merged and what is at which level of detail.
- Check the list of recent frames over 33 ms, each with the phase that took most of it.
- 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
- Open Metrics (or, in a game played here, its 📊 window).
- 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). - 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
- Open View › Debug view (or search "debug").
- Pick one: Wireframe, Shadow cascades, Navmesh, Overdraw, Detail levels, Pick ids or Fog texture.
- 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):
| Key | Overlay | Shows |
|---|---|---|
| Shift+P | Where one walks | Walkable ground |
| Shift+B | Where one builds | Green where a building can go |
| Shift+K | Slow ground | Ground that slows units |
| Shift+L | Cliff levels | Each cliff level in its own colour |
| Shift+Y | Layers of cells | The game's cell layers |
| Shift+J | Grass styles | Each style of grass and bushes in its colour |
| Shift+U | Grass state | Burning, burnt, cut, flattened and growing grass |
| Shift+H | Hiding patches | Each patch of grass that hides, outlined |
| Shift+G | Grid | Lines between cells |
| Shift+T | Triangles | The edges of every triangle drawn, over the picture |
| Shift+V | Detail levels | What is drawn at which level, and what is not drawn |
| Shift+F | Footprints | The cells each building and mine takes |
| Shift+C | Camps notice | How far each camp notices who comes near |
| Shift+N | Names | Names 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
- Open Console in the bottom drawer. The bar counts its errors (red) and warnings.
- Show or hide levels with their buttons, or type to find words.
- 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
- Look at the Problems count on the bottom bar, and open Problems in the drawer.
- Click a problem to select what it is about and look at it.
- 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
- Open Statistics (right rail, or View › Statistics).
- Read, per player: units and buildings with supply, mines and trees within 16 cells of their start.
- Read the ground: cells in play, the share walked on and built on (click to show the overlay).
- 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
- Open File › The editor's settings, then Graphics (or search "graphics").
- Pick a preset, or set shadows, render resolution and anti-aliasing (from the next time the editor opens).
- 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:
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:
checkMap(map, registry, [...LOOK_RULES, ...(view.mapRules ?? [])]) // as the editor checks itapps/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
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).
| Rule | What it means |
|---|---|
unknown-type, unknown-creeps, unknown-tile | Something the game does not have |
off-map, region-off-map, region-past-edge, path-off-map | Off the map or past its edge |
deep-water | In deep water, and does not sail or fly |
name-twice | A name used twice |
start-blocked, starts-apart, unreachable | Starts or mines nobody can walk to |
too-many-players | More players than the game allows |
missing-target | A field names a region, point or path that is gone |
missing-file | A model, sound or music with no file |
heavy-model | A model over 3 MB with no lighter levels |
empty-random-group, unknown-random-group, empty-item-table, unknown-item-table | Random groups and item tables |
unknown-camera | A camera that is not there |
path-tile-missing, path-profile-short | A path's paint or bed |
prefab-loop, prefab-source-missing | Prefabs |
objective-*, rule-* | Objectives and rules |
other-race | Placed for a player whose race may not have it |
unknown-foliage-style | Grass painted with a style neither the game nor the map has |
foliage-hides-nobody | A style that hides but is shorter than every unit on the ground |
foliage-no-fire | A flammable style in a game whose grass has no fire |
game | A 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
| Setting | Kept in | Default |
|---|---|---|
| Graphics preset and parts | editor.prefs.graphics | |
| Most frames a second | editor.prefs.maxFps | 0 (no cap) |
| Frame budget | editor.prefs.frameBudget | 6 ms |
| When left alone | editor.prefs.whenIdle | Draw as always |
| Merge scenery | EditorPrefs.mergeScenery | On |
| Full detail | EditorPrefs.fullDetail | Off |
| Animate units | EditorPrefs.animateUnits | Off |
Triangle budgets are TRIANGLE_BUDGETS over GameView.world.quality.triangles; mapStatistics(map, registry) counts without an editor.