glitchless-playtest 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -7
- package/bin/glitchless-playtest.js +15 -5
- package/package.json +7 -2
- package/src/compare.js +63 -4
- package/src/config.js +48 -3
- package/src/engine.js +411 -0
- package/src/index.js +25 -8
- package/src/report.js +42 -11
- package/src/roblox.js +319 -0
package/README.md
CHANGED
|
@@ -1,16 +1,97 @@
|
|
|
1
1
|
# glitchless-playtest
|
|
2
2
|
|
|
3
|
-
Playtest every change.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
Playtest every change. Your game's autoplay bot plays it on a saved baseline and on the current code, and
|
|
4
|
+
[Glitchless](https://github.com/glitchless-gg/glitchless) compares the two: slow frames, frame time, render and
|
|
5
|
+
update time, draw calls, hitches, errors and crashes. A regression exits with code 1, so it can gate a pull request.
|
|
6
|
+
It plays Unity, Godot, Unreal and GameMaker builds from their command line ([engine builds](#engine-builds)), Roblox
|
|
7
|
+
games in Roblox Studio ([Roblox](#roblox)), and web games (Three.js, Phaser, Babylon.js, PlayCanvas or plain WebGL) in
|
|
8
|
+
Chrome.
|
|
7
9
|
|
|
8
10
|
```bash
|
|
9
11
|
npx glitchless-playtest --save baseline # before changing the code
|
|
10
12
|
npx glitchless-playtest # after: compares with "baseline"
|
|
11
13
|
```
|
|
12
14
|
|
|
13
|
-
##
|
|
15
|
+
## Engine builds
|
|
16
|
+
|
|
17
|
+
A Unity, Godot, Unreal or GameMaker build with the Glitchless SDK measures itself: started with
|
|
18
|
+
`--glitchless-measure=SECONDS`, it times every frame for that long, prints the numbers as one line of JSON and quits.
|
|
19
|
+
Give the playtest the command that starts the build, an exported build or the engine with the project path, in
|
|
20
|
+
`glitchless.playtest.json`:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"command": ["godot", "--path", "."],
|
|
25
|
+
"scenarios": [
|
|
26
|
+
{ "name": "seed 7", "params": { "autoplay": true, "seed": 7 }, "seconds": 10 },
|
|
27
|
+
{ "name": "seed 21", "params": { "autoplay": true, "seed": 21, "level": 2 }, "seconds": 10 }
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Each scenario starts the build once, one at a time, with its `params` as the game's own flags
|
|
33
|
+
(`--autoplay --seed=7`; `-autoplay -seed=7` in Unreal and GameMaker; after a `--` in Godot), its `args` as they are,
|
|
34
|
+
and the measure flags. No browser and no Glitchless server are needed. Without `scenarios`, it runs
|
|
35
|
+
`--autoplay --seed=7`, then `--autoplay --seed=21`.
|
|
36
|
+
|
|
37
|
+
- **The game needs an autoplay mode**: a bot that starts when the game is given `--autoplay`, plays the same way for
|
|
38
|
+
the same `--seed`, starts levels as it goes, and keeps playing for the whole measure. A game that quits sooner
|
|
39
|
+
prints no measurement, and the error says to lower `seconds` or let the bot keep playing. With the default
|
|
40
|
+
scenarios, a game that starts no level is taken to have no autoplay mode, and the error says how to add one for
|
|
41
|
+
its engine. The Godot demo in the Glitchless repo, `godot/demo/demo.gd`, is a working example with its
|
|
42
|
+
`godot/glitchless.playtest.json`.
|
|
43
|
+
- **Run it with a window.** A headless run draws nothing and runs frames uncapped, so its frame times mean little.
|
|
44
|
+
When the build says it ran headless (Godot's `--headless`, GameMaker), frame times only warn; update time, errors,
|
|
45
|
+
crashes and growth still count.
|
|
46
|
+
- `command` is a list or one string (`"godot --path ."`). Paths are from the project folder; a macOS `.app` runs the
|
|
47
|
+
executable inside it. The engine is told from the command and from what an export leaves beside it; set `engine`
|
|
48
|
+
(`godot`, `unity`, `unreal`, `gamemaker`) when it can't be.
|
|
49
|
+
- `seconds` (default 10) and `warmup` (seconds before measuring: default 0, so errors and stutter while loading count;
|
|
50
|
+
Unity 1, since its memory counters read nothing on the first frames) can be set per scenario or for all. `max_s`
|
|
51
|
+
(default warmup + seconds + 120) kills a build that froze; that run counts as crashed.
|
|
52
|
+
- The build writes its measurement to a file the playtest passes (`--glitchless-out`) too, which is how a Unity player
|
|
53
|
+
on macOS, whose output goes to its log, is read. If a build's file sandbox keeps it from writing there, set
|
|
54
|
+
`measure_file` to where it saves it (GameMaker: `glitchless/measure.json` in its save area).
|
|
55
|
+
|
|
56
|
+
On top of the web checks, an engine build compares frame time p99, GPU time (Unity, Unreal, Godot off Metal), Unreal's
|
|
57
|
+
RHI thread, Unity's physics, garbage collection and what grew over a run (objects, nodes, instances, MB: a leak), and
|
|
58
|
+
with two or more scenarios, each run against the same run of the baseline, and the level each run ended on. Errors
|
|
59
|
+
match across builds even when their numbers or line numbers moved. A crashed run is listed with the last lines it
|
|
60
|
+
printed. For CI, `--baseline-command` runs the other build as the baseline first.
|
|
61
|
+
|
|
62
|
+
## Roblox
|
|
63
|
+
|
|
64
|
+
A Roblox game has no command line, so its runs are play tests in the open Roblox Studio, driven over Studio's own MCP
|
|
65
|
+
server (Assistant → … → Manage MCP Servers → **Enable Studio as MCP server**):
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"engine": "roblox",
|
|
70
|
+
"studio": "My Obby",
|
|
71
|
+
"scenarios": [
|
|
72
|
+
{ "name": "seed 7", "params": { "autoplay": true, "seed": 7 }, "max_s": 90 },
|
|
73
|
+
{ "name": "seed 21", "params": { "autoplay": true, "seed": 21 }, "max_s": 90 }
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Each scenario sets its `params` as attributes of Workspace, starts a play test, waits until `done_when` (Luau, run on
|
|
79
|
+
the play test's server; by default `workspace:GetAttribute("GlitchlessPlaytestDone") == true`) or `max_s`, stops it,
|
|
80
|
+
and puts the attributes back as they were. The SDK sends the play test's sessions where the game's `Glitchless.init`
|
|
81
|
+
says, and the playtest reads them back from that Glitchless server (`--server`): the players' sessions, and the
|
|
82
|
+
server's own for its script errors. So the game needs an autoplay mode that reads those attributes, marks its sessions
|
|
83
|
+
`sessionType = "synthetic"` and says when it's done; [the Roblox SDK's README](https://github.com/glitchless-gg/glitchless/tree/main/roblox#ask-your-agent)
|
|
84
|
+
has the code.
|
|
85
|
+
|
|
86
|
+
- `studio` is part of the open Studio's place name. With one Studio open it can be left out; with several, the
|
|
87
|
+
playtest refuses to guess, so it never plays another place.
|
|
88
|
+
- `service` is read from the place's `Glitchless.init`; set it when that can't be read.
|
|
89
|
+
- `luau` runs in Edit before each play test, for anything an attribute can't do (pointing a test place at a server).
|
|
90
|
+
- `studio_mcp` is StudioMCP's command, when Studio isn't installed where it usually is.
|
|
91
|
+
- It stops with what to do when Studio isn't reachable, is already in a play test, the place has no Glitchless module
|
|
92
|
+
or has Allow HTTP Requests off, or no session arrives.
|
|
93
|
+
|
|
94
|
+
## Web games
|
|
14
95
|
|
|
15
96
|
- **Your game running**, by default at `http://localhost:5173/`, with the Glitchless SDK
|
|
16
97
|
([`glitchless`](https://www.npmjs.com/package/glitchless)) reporting to a Glitchless server.
|
|
@@ -37,11 +118,17 @@ where the engine lets it (Phaser's scene updates and physics). The Phaser demo i
|
|
|
37
118
|
--compare-only A B compare two saved runs without playing
|
|
38
119
|
--baseline-url URL play another running build as the baseline first (for CI)
|
|
39
120
|
--game URL game to play (default http://localhost:5173/)
|
|
121
|
+
--command CMD run an engine build instead (Unity, Godot, Unreal, GameMaker): an exported
|
|
122
|
+
build, or the engine with the project path, e.g. "godot --path ."
|
|
123
|
+
--baseline-command CMD run another engine build as the baseline first (for CI)
|
|
124
|
+
--engine NAME godot, unity, unreal or gamemaker, when the command's name doesn't say;
|
|
125
|
+
roblox plays the place open in Roblox Studio, over Studio's MCP server
|
|
126
|
+
--studio NAME Roblox: which open Studio (part of its place's name), when several are open
|
|
40
127
|
--server URL Glitchless server (default $GLITCHLESS_URL or http://localhost:7777)
|
|
41
128
|
--service NAME game service name (default: read from the page)
|
|
42
129
|
--api-key KEY Glitchless API key (default $GLITCHLESS_API_KEY)
|
|
43
130
|
--quick play only the first scenario
|
|
44
|
-
--max SECONDS cap each run
|
|
131
|
+
--max SECONDS cap each run (an engine build: the seconds it measures)
|
|
45
132
|
--channel NAME browser: chrome (default) or chromium
|
|
46
133
|
--headed show the browser windows
|
|
47
134
|
--json print the full result as JSON instead of markdown
|
|
@@ -53,7 +140,8 @@ Saved runs go in `.glitchless/playtest/` (add it to `.gitignore`).
|
|
|
53
140
|
|
|
54
141
|
A `glitchless.playtest.json` in the project root can set any default: `game`, `server`, `scenarios`,
|
|
55
142
|
`thresholds`, `done_when` (a JavaScript expression that ends a run when it's true), `viewport` and
|
|
56
|
-
`runs_dir
|
|
143
|
+
`runs_dir`; for an engine build, `command`, `engine`, `seconds`, `warmup` and `measure_file`; for Roblox, `engine`,
|
|
144
|
+
`studio`, `luau` and `studio_mcp`.
|
|
57
145
|
|
|
58
146
|
```json
|
|
59
147
|
{
|
|
@@ -5,8 +5,12 @@
|
|
|
5
5
|
// glitchless-playtest # after: compares with "baseline", exits 1 on a regression
|
|
6
6
|
// glitchless-playtest --compare-only baseline latest
|
|
7
7
|
// glitchless-playtest --baseline-url http://localhost:5174/ # CI: main build vs this branch's build
|
|
8
|
+
// glitchless-playtest --command "godot --path ." --save baseline # an engine build instead of a web game
|
|
9
|
+
// glitchless-playtest --engine roblox --studio "My Obby" --save baseline # a play test in Roblox Studio
|
|
8
10
|
//
|
|
9
|
-
//
|
|
11
|
+
// A web game needs the game and a Glitchless server running, and Playwright installed in the game project.
|
|
12
|
+
// An engine build (Unity, Godot, Unreal, GameMaker) needs only the build, with the Glitchless SDK in it.
|
|
13
|
+
// A Roblox game needs its place open in Roblox Studio with Studio's MCP server on, and the Glitchless server it sends to.
|
|
10
14
|
|
|
11
15
|
import { playtest, compareSaved } from '../src/index.js';
|
|
12
16
|
|
|
@@ -17,16 +21,22 @@ const HELP = `Usage: glitchless-playtest [options]
|
|
|
17
21
|
--compare-only A B compare two saved runs without playing
|
|
18
22
|
--baseline-url URL play another running build as the baseline first (for CI)
|
|
19
23
|
--game URL game to play (default http://localhost:5173/)
|
|
24
|
+
--command CMD run an engine build instead (Unity, Godot, Unreal, GameMaker): an exported
|
|
25
|
+
build, or the engine with the project path, e.g. "godot --path ."
|
|
26
|
+
--baseline-command CMD run another engine build as the baseline first (for CI)
|
|
27
|
+
--engine NAME godot, unity, unreal or gamemaker, when the command's name doesn't say;
|
|
28
|
+
roblox plays the place open in Roblox Studio, over Studio's MCP server
|
|
29
|
+
--studio NAME Roblox: which open Studio (part of its place's name), when several are open
|
|
20
30
|
--server URL Glitchless server (default $GLITCHLESS_URL or http://localhost:7777)
|
|
21
31
|
--service NAME game service name (default: read from the page)
|
|
22
32
|
--api-key KEY Glitchless API key (default $GLITCHLESS_API_KEY)
|
|
23
33
|
--quick play only the first scenario
|
|
24
|
-
--max SECONDS cap each run
|
|
34
|
+
--max SECONDS cap each run (an engine build: the seconds it measures)
|
|
25
35
|
--channel NAME browser: chrome (default, uses your real GPU) or chromium
|
|
26
36
|
--headed show the browser windows
|
|
27
37
|
--json print the full result as JSON instead of markdown
|
|
28
38
|
|
|
29
|
-
Scenarios, thresholds and
|
|
39
|
+
Scenarios, thresholds, URLs and the command can also be set in glitchless.playtest.json.
|
|
30
40
|
Exit code: 0 pass (or nothing to compare), 1 regression, 2 error.`;
|
|
31
41
|
|
|
32
42
|
const argv = process.argv.slice(2);
|
|
@@ -42,7 +52,7 @@ if (has('help') || has('h')) {
|
|
|
42
52
|
}
|
|
43
53
|
|
|
44
54
|
const log = (msg) => process.stderr.write(`${msg}\n`);
|
|
45
|
-
const config = { game: val('game'), server: val('server'), service: val('service'), api_key: val('api-key'), channel: val('channel'), headed: has('headed') || undefined };
|
|
55
|
+
const config = { game: val('game'), command: val('command'), engine: val('engine'), studio: val('studio'), server: val('server'), service: val('service'), api_key: val('api-key'), channel: val('channel'), headed: has('headed') || undefined };
|
|
46
56
|
|
|
47
57
|
try {
|
|
48
58
|
let result;
|
|
@@ -52,7 +62,7 @@ try {
|
|
|
52
62
|
if (!a || !b) throw new Error('--compare-only needs two saved run names, e.g. --compare-only baseline latest');
|
|
53
63
|
result = compareSaved(a, b, { config });
|
|
54
64
|
} else {
|
|
55
|
-
result = await playtest({ saveAs: val('save'), compareTo: val('compare'), baselineUrl: val('baseline-url'), quick: has('quick'), maxSeconds: val('max') ? Number(val('max')) : undefined, config, log });
|
|
65
|
+
result = await playtest({ saveAs: val('save'), compareTo: val('compare'), baselineUrl: val('baseline-url'), baselineCommand: val('baseline-command'), quick: has('quick'), maxSeconds: val('max') ? Number(val('max')) : undefined, config, log });
|
|
56
66
|
}
|
|
57
67
|
if (has('json')) console.log(JSON.stringify(result, null, 2));
|
|
58
68
|
else console.log(result.report);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glitchless-playtest",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Playtest bots for game observability: autoplay
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Playtest bots for game observability: your game's autoplay bot plays a Unity, Godot, Unreal or GameMaker build, a Roblox game in Roblox Studio, or a web game (Three.js, Phaser, Babylon.js, PlayCanvas) in Chrome, on the current code and on a saved baseline, and Glitchless flags what got slower or started breaking.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"playtesting",
|
|
7
7
|
"playtest",
|
|
@@ -13,6 +13,11 @@
|
|
|
13
13
|
"performance",
|
|
14
14
|
"regression-testing",
|
|
15
15
|
"playwright",
|
|
16
|
+
"unity",
|
|
17
|
+
"godot",
|
|
18
|
+
"unreal-engine",
|
|
19
|
+
"gamemaker",
|
|
20
|
+
"roblox",
|
|
16
21
|
"threejs",
|
|
17
22
|
"phaser",
|
|
18
23
|
"web-games",
|
package/src/compare.js
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
import { DEFAULT_THRESHOLDS } from './config.js';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
const
|
|
6
|
+
// A metric a run doesn't have (GPU time in a browser, draw calls in GameMaker) is skipped.
|
|
7
|
+
const OVERALL = ['pct_frames_over_budget', 'frame_p95', 'frame_p99', 'render_cpu_ms', 'update_cpu_ms', 'gpu_ms', 'rhi_cpu_ms', 'physics_ms', 'draw_calls', 'hitches_per_min', 'errors_per_session', 'deaths_per_session', 'level_completion_pct', 'geometries_growth_per_level_load', 'gc_ms', 'gc_collections'];
|
|
8
|
+
const PER_LEVEL = ['pct_frames_over_budget', 'frame_p95', 'frame_p99', 'render_cpu_ms', 'update_cpu_ms', 'gpu_ms', 'draw_calls'];
|
|
9
|
+
const FRAME_TIME = new Set(['pct_frames_over_budget', 'frame_p95', 'frame_p99', 'hitches_per_min']);
|
|
8
10
|
|
|
9
11
|
export function judge(before, after, t) {
|
|
10
12
|
if (before == null || after == null || !t) return null;
|
|
@@ -43,6 +45,35 @@ export function compareRuns(baseline, candidate, thresholds = DEFAULT_THRESHOLDS
|
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
|
|
48
|
+
// An engine build's growth over a run, key by key (objects, nodes, instances, MB): a new leak grows more.
|
|
49
|
+
const mg = t.memory_growth;
|
|
50
|
+
for (const key of Object.keys(c.memory_growth || {})) {
|
|
51
|
+
const r = mg && judge(b.memory_growth?.[key], c.memory_growth[key], { ...mg, abs: /_mb$/.test(key) ? (mg.abs_mb ?? mg.abs) : mg.abs });
|
|
52
|
+
if (r) checks.push({ id: `memory_growth.${key}`, label: `${mg.label} (${key.replace(/_mb$/, ' MB').replace(/_/g, ' ')})`, scope: 'all levels', ...r });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// An engine build's runs one by one, when there are several: a slower run is not diluted by the others.
|
|
56
|
+
const bs = b.by_scenario || {};
|
|
57
|
+
const cs = c.by_scenario || {};
|
|
58
|
+
if (Object.keys(bs).length > 1 && Object.keys(cs).length > 1) {
|
|
59
|
+
for (const name of Object.keys(cs)) {
|
|
60
|
+
const br = bs[name];
|
|
61
|
+
const cr = cs[name];
|
|
62
|
+
if (!br || br.crashed || cr.crashed) continue;
|
|
63
|
+
const scope = `run "${name}"`;
|
|
64
|
+
for (const key of PER_LEVEL) {
|
|
65
|
+
const r = judge(br[key], cr[key], t[`level.${key}`]);
|
|
66
|
+
if (r) checks.push({ id: `run.${key}.${name}`, label: t[`level.${key}`].label, scope, ...r });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Where each run ended up: the same seed reaching another level means the game plays differently now.
|
|
71
|
+
for (const name of Object.keys(cs)) {
|
|
72
|
+
const before = bs[name]?.level_end;
|
|
73
|
+
const after = cs[name]?.level_end;
|
|
74
|
+
if (before != null && after != null && before !== after) checks.push({ id: `run.level_end.${name}`, label: 'Level at the end of the run', scope: `run "${name}"`, before, after, change_pct: null, status: 'warning' });
|
|
75
|
+
}
|
|
76
|
+
|
|
46
77
|
const baseErrors = new Map((b.errors || []).map((e) => [e.fingerprint, e]));
|
|
47
78
|
const candErrors = new Map((c.errors || []).map((e) => [e.fingerprint, e]));
|
|
48
79
|
const newErrors = [...candErrors.values()].filter((e) => !baseErrors.has(e.fingerprint));
|
|
@@ -56,11 +87,39 @@ export function compareRuns(baseline, candidate, thresholds = DEFAULT_THRESHOLDS
|
|
|
56
87
|
|
|
57
88
|
// Comparisons are only fair when the same bots played the same scenarios on the same machine.
|
|
58
89
|
const notes = [];
|
|
59
|
-
const sig = (run) => JSON.stringify((run.scenarios || []).map((s) => s.params));
|
|
90
|
+
const sig = (run) => JSON.stringify((run.scenarios || []).map((s) => ({ params: s.params, args: s.args, seconds: s.seconds, warmup: s.warmup })));
|
|
60
91
|
if (sig(baseline) !== sig(candidate)) notes.push('The two runs used different scenarios, so differences may come from the bots rather than the code.');
|
|
92
|
+
if ((baseline.kind || 'web') !== (candidate.kind || 'web')) notes.push('One run played a web game in a browser and the other an engine build: their numbers are not comparable.');
|
|
61
93
|
if (baseline.machine?.gpu && candidate.machine?.gpu && baseline.machine.gpu !== candidate.machine.gpu) notes.push(`Different GPUs (${baseline.machine.gpu} vs ${candidate.machine.gpu}): frame times are not comparable across machines.`);
|
|
62
|
-
|
|
94
|
+
else if (!baseline.machine?.gpu && baseline.machine?.cpu && candidate.machine?.cpu && baseline.machine.cpu !== candidate.machine.cpu) notes.push(`Different machines (${baseline.machine.cpu} vs ${candidate.machine.cpu}): frame times are not comparable across machines.`);
|
|
95
|
+
const capped = (candidate.scenarios || []).filter((s) => !s.finished && !s.crashed).length;
|
|
63
96
|
if (capped) notes.push(`${capped} candidate run(s) hit the time cap before finishing.`);
|
|
97
|
+
notes.push(...(candidate.notes || []));
|
|
98
|
+
|
|
99
|
+
// Frame times only fail a change when both runs measured the same way. Headless, nothing is drawn and frames run
|
|
100
|
+
// uncapped; against a different frame budget (another refresh rate, or one the SDK misread), slow frames are
|
|
101
|
+
// counted against another line. Either way those checks warn instead of failing.
|
|
102
|
+
const headless = !!(b.headless || c.headless);
|
|
103
|
+
const budgetOf = (s, name) => (name ? s.by_scenario?.[name]?.frame_budget_ms : s.frame_budget_ms);
|
|
104
|
+
const differs = (name) => {
|
|
105
|
+
const x = budgetOf(b, name);
|
|
106
|
+
const y = budgetOf(c, name);
|
|
107
|
+
return x != null && y != null && Math.abs(x - y) > 0.05;
|
|
108
|
+
};
|
|
109
|
+
// The whole-run number mixes every run, so any run on another budget skews it.
|
|
110
|
+
const budgetDiffers = (name) => (name ? differs(name) : differs(null) || Object.keys(c.by_scenario || {}).some(differs));
|
|
111
|
+
const scenarioOf = (id) => (id.startsWith('run.') ? id.split('.').slice(2).join('.') : null);
|
|
112
|
+
const softened = new Set();
|
|
113
|
+
for (const x of checks) {
|
|
114
|
+
if (x.status !== 'regression') continue;
|
|
115
|
+
const metric = x.id.replace(/^(level|run)\./, '').split('.')[0];
|
|
116
|
+
const why = headless && FRAME_TIME.has(metric) ? 'headless' : metric === 'pct_frames_over_budget' && budgetDiffers(scenarioOf(x.id)) ? 'budget' : null;
|
|
117
|
+
if (!why) continue;
|
|
118
|
+
x.status = 'warning';
|
|
119
|
+
softened.add(why);
|
|
120
|
+
}
|
|
121
|
+
if (softened.has('headless') && !c.headless) notes.push('A run was headless, where frames run uncapped: frame times only warn here. Measure with a window to gate on them.');
|
|
122
|
+
if (softened.has('budget')) notes.push(`The runs measured slow frames against different frame budgets (${[b.frame_budget_ms, c.frame_budget_ms].filter((v) => v != null).join(' vs ')} ms overall, or a run's own), so slow frames only warn here.`);
|
|
64
123
|
|
|
65
124
|
const regressions = checks.filter((x) => x.status === 'regression');
|
|
66
125
|
return {
|
package/src/config.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
// Playtest settings: defaults suit Zoomies, and a glitchless.playtest.json in the project root can
|
|
2
|
-
// override any of them (scenarios, thresholds, URLs, how to tell a run is finished).
|
|
2
|
+
// override any of them (scenarios, thresholds, URLs, how to tell a run is finished). With "command" set,
|
|
3
|
+
// scenarios run an engine build (Unity, Godot, Unreal, GameMaker) instead of a web game: see engine.js. With
|
|
4
|
+
// "engine": "roblox", they are play tests in the open Roblox Studio: see roblox.js.
|
|
3
5
|
|
|
4
6
|
import fs from 'node:fs';
|
|
5
7
|
import path from 'node:path';
|
|
8
|
+
import { DEFAULT_ROBLOX_SCENARIOS, ROBLOX_DONE_WHEN } from './roblox.js';
|
|
6
9
|
|
|
7
10
|
// Each scenario is one autoplay run. Fixed seeds make the bot play the same way on both builds, so
|
|
8
11
|
// the only thing that changes between baseline and candidate is the code.
|
|
@@ -12,6 +15,13 @@ export const DEFAULT_SCENARIOS = [
|
|
|
12
15
|
{ name: 'novice from level 2', params: { autoplay: 1, seed: 42, skill: 0.6, level: 2 }, max_s: 90 },
|
|
13
16
|
];
|
|
14
17
|
|
|
18
|
+
// An engine build's runs: params become the game's own flags (--autoplay --seed=7), and each run measures for
|
|
19
|
+
// `seconds` after `warmup` (default 0, Unity 1) with the SDK's --glitchless-measure, then the build quits.
|
|
20
|
+
export const DEFAULT_ENGINE_SCENARIOS = [
|
|
21
|
+
{ name: 'autoplay, seed 7', params: { autoplay: true, seed: 7 }, seconds: 10 },
|
|
22
|
+
{ name: 'autoplay, seed 21', params: { autoplay: true, seed: 21 }, seconds: 10 },
|
|
23
|
+
];
|
|
24
|
+
|
|
15
25
|
// A change regresses a metric only when it is worse by BOTH the relative and the absolute margin,
|
|
16
26
|
// so small numbers (0.3 → 0.4 ms) and noise on fast machines don't fail a build.
|
|
17
27
|
// higher: whether a higher value is worse (true) or better (false)
|
|
@@ -21,21 +31,34 @@ export const DEFAULT_SCENARIOS = [
|
|
|
21
31
|
export const DEFAULT_THRESHOLDS = {
|
|
22
32
|
pct_frames_over_budget: { label: 'Slow frames (% over budget)', higher: true, pct: 50, abs: 2, severity: 'fail' },
|
|
23
33
|
frame_p95: { label: 'Frame time p95 (ms)', higher: true, pct: 15, abs: 2, severity: 'warn' },
|
|
34
|
+
frame_p99: { label: 'Frame time p99 (ms)', higher: true, pct: 20, abs: 4, severity: 'warn' },
|
|
24
35
|
render_cpu_ms: { label: 'Render CPU per frame (ms)', higher: true, pct: 30, abs: 1, severity: 'fail' },
|
|
25
|
-
// The game's update code (scripts and physics), where the SDK can time it: Phaser, Godot and Unity.
|
|
36
|
+
// The game's update code (scripts and physics), where the SDK can time it: Phaser, Babylon.js, PlayCanvas, Godot and Unity.
|
|
26
37
|
update_cpu_ms: { label: 'Update CPU per frame (ms)', higher: true, pct: 30, abs: 1, severity: 'fail' },
|
|
27
38
|
draw_calls: { label: 'Draw calls per frame', higher: true, pct: 25, abs: 50, severity: 'fail' },
|
|
39
|
+
// What engine builds measure beyond that, where the engine reports it: the GPU's time (Unity, Unreal; Godot
|
|
40
|
+
// off Metal), Unreal's RHI thread, Unity's physics, garbage collection, and growth over a run (a leak).
|
|
41
|
+
gpu_ms: { label: 'GPU per frame (ms)', higher: true, pct: 30, abs: 1, severity: 'fail' },
|
|
42
|
+
rhi_cpu_ms: { label: 'RHI thread per frame (ms)', higher: true, pct: 30, abs: 1, severity: 'fail' },
|
|
43
|
+
physics_ms: { label: 'Physics per frame (ms)', higher: true, pct: 30, abs: 1, severity: 'fail' },
|
|
44
|
+
gc_ms: { label: 'Garbage collection per run (ms)', higher: true, pct: 50, abs: 20, severity: 'warn' },
|
|
45
|
+
gc_collections: { label: 'Garbage collections per run', higher: true, pct: 50, abs: 3, severity: 'warn' },
|
|
46
|
+
// Counts (objects, nodes, instances) by abs; sizes in MB by abs_mb.
|
|
47
|
+
memory_growth: { label: 'Growth over a run', higher: true, pct: 50, abs: 100, abs_mb: 16, severity: 'warn' },
|
|
28
48
|
hitches_per_min: { label: 'Hitches per minute', higher: true, pct: 50, abs: 1, severity: 'warn' },
|
|
29
49
|
errors_per_session: { label: 'Errors per run', higher: true, pct: 50, abs: 1, severity: 'warn' },
|
|
30
50
|
deaths_per_session: { label: 'Deaths per run', higher: true, pct: 50, abs: 2, severity: 'warn' },
|
|
31
51
|
level_completion_pct: { label: 'Level completion (%)', higher: false, pct: 0, abs: 25, severity: 'warn' },
|
|
32
52
|
geometries_growth_per_level_load: { label: 'Geometry growth per level load', higher: true, pct: 50, abs: 200, severity: 'warn' },
|
|
33
|
-
// Per-level versions of the renderer metrics catch a regression the whole-run average dilutes.
|
|
53
|
+
// Per-level versions of the renderer metrics catch a regression the whole-run average dilutes. An engine build's
|
|
54
|
+
// runs are compared one by one with the same margins.
|
|
34
55
|
'level.pct_frames_over_budget': { label: 'Slow frames (% over budget)', higher: true, pct: 50, abs: 2, severity: 'fail' },
|
|
35
56
|
'level.frame_p95': { label: 'Frame time p95 (ms)', higher: true, pct: 15, abs: 2, severity: 'warn' },
|
|
57
|
+
'level.frame_p99': { label: 'Frame time p99 (ms)', higher: true, pct: 20, abs: 4, severity: 'warn' },
|
|
36
58
|
'level.render_cpu_ms': { label: 'Render CPU per frame (ms)', higher: true, pct: 30, abs: 1, severity: 'fail' },
|
|
37
59
|
'level.update_cpu_ms': { label: 'Update CPU per frame (ms)', higher: true, pct: 30, abs: 1, severity: 'fail' },
|
|
38
60
|
'level.draw_calls': { label: 'Draw calls per frame', higher: true, pct: 25, abs: 50, severity: 'fail' },
|
|
61
|
+
'level.gpu_ms': { label: 'GPU per frame (ms)', higher: true, pct: 30, abs: 1, severity: 'fail' },
|
|
39
62
|
new_errors: { label: 'New error types', severity: 'fail' },
|
|
40
63
|
new_crashes: { label: 'Crashed runs', severity: 'fail' },
|
|
41
64
|
};
|
|
@@ -53,6 +76,19 @@ export const DEFAULTS = {
|
|
|
53
76
|
runs_dir: '.glitchless/playtest',
|
|
54
77
|
scenarios: DEFAULT_SCENARIOS,
|
|
55
78
|
thresholds: DEFAULT_THRESHOLDS,
|
|
79
|
+
// Engine builds: the command that starts one ("godot --path ." or an exported build; a path is relative to the
|
|
80
|
+
// project), which engine it is when its name doesn't say, how long each run measures and waits first, and where
|
|
81
|
+
// the build writes its measurement when it prints nothing (GameMaker's save area, say).
|
|
82
|
+
command: null,
|
|
83
|
+
engine: null,
|
|
84
|
+
seconds: null,
|
|
85
|
+
warmup: null,
|
|
86
|
+
measure_file: null,
|
|
87
|
+
// Roblox: which open Studio to play in (part of its place's name; needed when several are open), Luau to run in
|
|
88
|
+
// Edit before each play test, and StudioMCP's command when Studio isn't where it installs by default.
|
|
89
|
+
studio: null,
|
|
90
|
+
luau: null,
|
|
91
|
+
studio_mcp: null,
|
|
56
92
|
};
|
|
57
93
|
|
|
58
94
|
export function loadConfig(cwd = process.cwd(), overrides = {}) {
|
|
@@ -69,5 +105,14 @@ export function loadConfig(cwd = process.cwd(), overrides = {}) {
|
|
|
69
105
|
const cfg = { ...DEFAULTS, ...fromFile, ...clean };
|
|
70
106
|
cfg.thresholds = { ...DEFAULT_THRESHOLDS, ...(fromFile.thresholds || {}) };
|
|
71
107
|
cfg.runs_dir = path.resolve(cwd, cfg.runs_dir);
|
|
108
|
+
cfg.root = cwd;
|
|
109
|
+
if (cfg.engine) cfg.engine = String(cfg.engine).toLowerCase().replace(/\s+/g, '');
|
|
110
|
+
const roblox = cfg.engine === 'roblox';
|
|
111
|
+
if (!fromFile.scenarios && !clean.scenarios) {
|
|
112
|
+
cfg.scenarios = roblox ? DEFAULT_ROBLOX_SCENARIOS : cfg.command ? DEFAULT_ENGINE_SCENARIOS : DEFAULT_SCENARIOS;
|
|
113
|
+
cfg.default_scenarios = true;
|
|
114
|
+
}
|
|
115
|
+
// done_when is JavaScript in a browser and Luau on a Roblox server.
|
|
116
|
+
if (roblox && !fromFile.done_when && !clean.done_when) cfg.done_when = ROBLOX_DONE_WHEN;
|
|
72
117
|
return cfg;
|
|
73
118
|
}
|