glitchless-playtest 0.3.0 → 0.5.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 +69 -3
- package/bin/glitchless-playtest.js +33 -1
- package/package.json +1 -1
- package/src/check-bot.js +465 -0
- package/src/check-page.js +252 -0
- package/src/check-report.js +327 -0
- package/src/check-site.js +158 -0
- package/src/check.js +549 -0
- package/src/engine.js +75 -12
- package/src/index.js +17 -5
- package/src/roblox.js +13 -9
- package/src/run.js +17 -8
- package/src/stop.js +36 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
// What a game check adds to the page it plays, before any of the game's own scripts run (Playwright's addInitScript):
|
|
2
|
+
// the Glitchless browser SDK, started for the check's game as a synthetic session, and a watch on what the page is
|
|
3
|
+
// made of: its engine, its canvases, its draw calls and the words on its screens. The bot (check-bot.js) and the
|
|
4
|
+
// report read the watch from window.__GLITCHLESS_CHECK__. Nothing here changes how the game runs, except that an
|
|
5
|
+
// engine the SDK has an adapter for (Three.js, Phaser, Babylon.js, PlayCanvas) is handed to it, as if the game had
|
|
6
|
+
// Glitchless installed with its defaults.
|
|
7
|
+
|
|
8
|
+
// The script, as one string: the SDK's <script> build (window.Glitchless), then the watch, called with `init`
|
|
9
|
+
// ({ glitchless: options for Glitchless.init, adapters: false to leave engines alone }).
|
|
10
|
+
export function checkInitScript({ sdk, init }) {
|
|
11
|
+
return `${sdk}\n;(${pageWatch.toString()})(${JSON.stringify(init)});`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Runs in the page. Kept free of anything outside itself: it is sent as source.
|
|
15
|
+
function pageWatch(init) {
|
|
16
|
+
// Only the page the check opened: an ad's or a video's frame inside it is not the game.
|
|
17
|
+
if (window.top !== window || window.__GLITCHLESS_CHECK__) return;
|
|
18
|
+
const W = (window.__GLITCHLESS_CHECK__ = { contexts: [], draws: 0, adapters: [], adapterErrors: [], three: { renderers: [], scenes: [], revision: null }, dts: [], labels: {}, buttons: {}, started: performance.now() });
|
|
19
|
+
let gd = null;
|
|
20
|
+
try {
|
|
21
|
+
gd = window.Glitchless.init(init.glitchless);
|
|
22
|
+
} catch (err) {
|
|
23
|
+
W.initError = String(err?.message || err);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Canvases as the game makes them: which kind of drawing each one does (webgl2, webgl, 2d, webgpu).
|
|
27
|
+
const canvases = [];
|
|
28
|
+
const getContext = HTMLCanvasElement.prototype.getContext;
|
|
29
|
+
HTMLCanvasElement.prototype.getContext = function (type, attrs) {
|
|
30
|
+
const ctx = getContext.call(this, type, attrs);
|
|
31
|
+
if (ctx && !canvases.some((c) => c.canvas === this)) canvases.push({ canvas: this, type: String(type).toLowerCase() });
|
|
32
|
+
return ctx;
|
|
33
|
+
};
|
|
34
|
+
// Draw calls on any WebGL context, counted per frame below (an engine adapter counts its own too).
|
|
35
|
+
for (const C of [window.WebGLRenderingContext, window.WebGL2RenderingContext]) {
|
|
36
|
+
if (!C) continue;
|
|
37
|
+
for (const name of ['drawArrays', 'drawElements', 'drawArraysInstanced', 'drawElementsInstanced', 'drawRangeElements']) {
|
|
38
|
+
const fn = C.prototype[name];
|
|
39
|
+
if (typeof fn !== 'function') continue;
|
|
40
|
+
C.prototype[name] = function () {
|
|
41
|
+
W.draws++;
|
|
42
|
+
return fn.apply(this, arguments);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// WebGPU, where the game asks for it.
|
|
47
|
+
if (navigator.gpu?.requestAdapter) {
|
|
48
|
+
const request = navigator.gpu.requestAdapter.bind(navigator.gpu);
|
|
49
|
+
navigator.gpu.requestAdapter = (...a) => {
|
|
50
|
+
W.webgpu = true;
|
|
51
|
+
return request(...a);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Frame times and draw calls per frame on the check's own clock, which the bot reads and clears every step.
|
|
56
|
+
let last = 0;
|
|
57
|
+
let drawsAt = 0;
|
|
58
|
+
W.drawFrames = [];
|
|
59
|
+
const raf = (now) => {
|
|
60
|
+
if (last && !document.hidden) {
|
|
61
|
+
W.dts.push(now - last);
|
|
62
|
+
if (W.dts.length > 4000) W.dts.splice(0, 2000);
|
|
63
|
+
W.drawFrames.push(W.draws - drawsAt);
|
|
64
|
+
if (W.drawFrames.length > 4000) W.drawFrames.splice(0, 2000);
|
|
65
|
+
}
|
|
66
|
+
drawsAt = W.draws;
|
|
67
|
+
last = now;
|
|
68
|
+
requestAnimationFrame(raf);
|
|
69
|
+
};
|
|
70
|
+
requestAnimationFrame(raf);
|
|
71
|
+
|
|
72
|
+
// Three.js tells devtools about each renderer and scene it makes, bundled or not: listen as devtools would.
|
|
73
|
+
const devtools = window.__THREE_DEVTOOLS__ instanceof EventTarget ? window.__THREE_DEVTOOLS__ : new EventTarget();
|
|
74
|
+
if (!window.__THREE_DEVTOOLS__) window.__THREE_DEVTOOLS__ = devtools;
|
|
75
|
+
devtools.addEventListener('register', (e) => (W.three.revision = e.detail?.revision ?? W.three.revision));
|
|
76
|
+
devtools.addEventListener('observe', (e) => {
|
|
77
|
+
const o = e.detail;
|
|
78
|
+
if (o?.isScene) W.three.scenes.push(o);
|
|
79
|
+
else if (o && typeof o.render === 'function' && o.domElement) W.three.renderers.push(o);
|
|
80
|
+
attach();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Phaser makes its game with new Phaser.Game(config): wrap the constructor as Phaser arrives, to hand the game over.
|
|
84
|
+
let phaser = window.Phaser;
|
|
85
|
+
const wrapPhaser = (P) => {
|
|
86
|
+
if (!P?.Game || P.Game.__glitchlessCheck) return;
|
|
87
|
+
try {
|
|
88
|
+
const Game = P.Game;
|
|
89
|
+
const wrapped = new Proxy(Game, {
|
|
90
|
+
construct(target, args, newTarget) {
|
|
91
|
+
const game = Reflect.construct(target, args, newTarget === wrapped ? target : newTarget);
|
|
92
|
+
W.phaserGame = game;
|
|
93
|
+
attach();
|
|
94
|
+
return game;
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
wrapped.__glitchlessCheck = true;
|
|
98
|
+
P.Game = wrapped;
|
|
99
|
+
} catch {}
|
|
100
|
+
};
|
|
101
|
+
try {
|
|
102
|
+
Object.defineProperty(window, 'Phaser', {
|
|
103
|
+
configurable: true,
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: () => phaser,
|
|
106
|
+
set: (v) => {
|
|
107
|
+
phaser = v;
|
|
108
|
+
wrapPhaser(v);
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
} catch {}
|
|
112
|
+
|
|
113
|
+
const adapt = (name, fn) => {
|
|
114
|
+
if (init.adapters === false || !gd || W.adapters.includes(name)) return;
|
|
115
|
+
try {
|
|
116
|
+
fn();
|
|
117
|
+
W.adapters.push(name);
|
|
118
|
+
} catch (err) {
|
|
119
|
+
W.adapterErrors.push(`${name}: ${String(err?.message || err).slice(0, 160)}`);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
function attach() {
|
|
123
|
+
const G = window.Glitchless;
|
|
124
|
+
if (W.three.renderers.length) adapt('three', () => G.instrumentThree(gd, { renderer: W.three.renderers[0], scene: W.three.scenes[0] }));
|
|
125
|
+
const game = W.phaserGame || (window.game?.scene && window.game?.events ? window.game : null);
|
|
126
|
+
if (game) adapt('phaser', () => G.instrumentPhaser(gd, { game, Phaser: phaser }));
|
|
127
|
+
const B = window.BABYLON;
|
|
128
|
+
const engine = B?.EngineStore?.Instances?.[0] || B?.Engine?.Instances?.[0];
|
|
129
|
+
if (engine?.scenes?.length) adapt('babylon', () => G.instrumentBabylon(gd, { engine, scene: engine.scenes[0], BABYLON: B }));
|
|
130
|
+
const pc = window.pc;
|
|
131
|
+
const app = pc?.app || pc?.Application?.getApplication?.() || pc?.AppBase?.getApplication?.();
|
|
132
|
+
if (app?.graphicsDevice) adapt('playcanvas', () => G.instrumentPlayCanvas(gd, { app, pc }));
|
|
133
|
+
}
|
|
134
|
+
// Babylon.js and PlayCanvas are found once the game has made its engine: look a few times while it loads.
|
|
135
|
+
let looks = 0;
|
|
136
|
+
const look = setInterval(() => {
|
|
137
|
+
attach();
|
|
138
|
+
if (++looks >= 30) clearInterval(look);
|
|
139
|
+
}, 1000);
|
|
140
|
+
|
|
141
|
+
// What the page is, read when the bot asks: the engine (by what each leaves on the page), the canvas it draws on,
|
|
142
|
+
// and the words on its screens (levels and waves, the buttons it offers).
|
|
143
|
+
W.read = () => {
|
|
144
|
+
const engines = [];
|
|
145
|
+
const add = (name, version) => engines.push({ name, version: version == null ? null : String(version) });
|
|
146
|
+
// A global by name, a page's top-level const too (Godot's GODOT_CONFIG): indirect eval reads the global scope.
|
|
147
|
+
const global = (name) => {
|
|
148
|
+
try {
|
|
149
|
+
return (0, eval)(`typeof ${name} === 'undefined' ? undefined : ${name}`);
|
|
150
|
+
} catch {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const has = (name) => global(name) !== undefined;
|
|
155
|
+
const scripts = [...document.scripts].map((s) => s.src || '').join(' ');
|
|
156
|
+
if (W.three.revision || window.__THREE__ || W.three.renderers.length) add('three', W.three.revision || window.__THREE__ || null);
|
|
157
|
+
if (phaser?.VERSION) add('phaser', phaser.VERSION);
|
|
158
|
+
if (window.BABYLON) add('babylon', window.BABYLON.Engine?.Version);
|
|
159
|
+
if (window.pc?.Application || window.pc?.AppBase) add('playcanvas', window.pc.version);
|
|
160
|
+
if (has('createUnityInstance') || window.unityInstance || has('UnityLoader') || /\.loader\.js|UnityLoader\.js|\.framework\.js/.test(scripts) || document.querySelector('#unity-canvas, #unity-container')) add('unity', window.unityInstance?.Module?.unityVersion);
|
|
161
|
+
if (has('GODOT_CONFIG') || typeof global('Engine')?.isWebGLAvailable === 'function') add('godot', null);
|
|
162
|
+
if (has('GameMaker_Init') || /game\.js.*html5game|html5game\//.test(scripts)) add('gamemaker', null);
|
|
163
|
+
if (window.C3_RuntimeInterface || has('cr_getC2Runtime') || /c3runtime|c2runtime/.test(scripts)) add('construct', null);
|
|
164
|
+
if (window.gdjs) add('gdevelop', null);
|
|
165
|
+
if (has('EngineLoader') || /dmloader\.js/.test(scripts)) add('defold', null);
|
|
166
|
+
if (window.PIXI || window.__PIXI_APP__) add('pixi', window.PIXI?.VERSION);
|
|
167
|
+
if (window.pico8_buttons) add('pico-8', null);
|
|
168
|
+
if (window.kaplay || window.kaboom) add('kaplay', null);
|
|
169
|
+
if (window.Utils?.RPGMAKER_NAME) add(`rpg maker ${window.Utils.RPGMAKER_NAME}`, window.Utils.RPGMAKER_VERSION);
|
|
170
|
+
if (window.RufflePlayer) add('ruffle', null);
|
|
171
|
+
if (!engines.length && window.Module?.HEAPU8) add('emscripten', null);
|
|
172
|
+
|
|
173
|
+
const visible = (el) => {
|
|
174
|
+
const r = el.getBoundingClientRect();
|
|
175
|
+
return r.width > 2 && r.height > 2 && r.bottom > 0 && r.right > 0 && r.top < innerHeight && r.left < innerWidth && getComputedStyle(el).visibility !== 'hidden';
|
|
176
|
+
};
|
|
177
|
+
const area = (el) => {
|
|
178
|
+
const r = el.getBoundingClientRect();
|
|
179
|
+
return Math.max(0, Math.min(r.right, innerWidth) - Math.max(r.left, 0)) * Math.max(0, Math.min(r.bottom, innerHeight) - Math.max(r.top, 0));
|
|
180
|
+
};
|
|
181
|
+
const shown = canvases.filter((c) => document.contains(c.canvas) && visible(c.canvas)).sort((a, b) => area(b.canvas) - area(a.canvas));
|
|
182
|
+
const main = shown[0];
|
|
183
|
+
const rect = main ? main.canvas.getBoundingClientRect() : null;
|
|
184
|
+
const frames = [...document.querySelectorAll('iframe')].filter(visible).sort((a, b) => area(b) - area(a));
|
|
185
|
+
const frame = frames[0] && area(frames[0]) > innerWidth * innerHeight * 0.25 ? frames[0] : null;
|
|
186
|
+
|
|
187
|
+
// Words on the screen: levels, waves and the like the game writes in its page, and the buttons it offers.
|
|
188
|
+
const text = (document.body?.innerText || '').slice(0, 20000);
|
|
189
|
+
const now = [];
|
|
190
|
+
for (const m of text.matchAll(/\b(level|lvl|wave|stage|round|world|floor|day|chapter|act|zone|room)\s*:?\s*(\d{1,3})\b/gi)) {
|
|
191
|
+
const label = `${m[1][0].toUpperCase()}${m[1].slice(1).toLowerCase()} ${m[2]}`;
|
|
192
|
+
W.labels[label] = (W.labels[label] || 0) + 1;
|
|
193
|
+
if (!now.includes(label)) now.push(label);
|
|
194
|
+
}
|
|
195
|
+
for (const b of document.querySelectorAll('button, [role=button], input[type=button], input[type=submit], a')) {
|
|
196
|
+
const t = (b.innerText || b.value || '').trim().replace(/\s+/g, ' ');
|
|
197
|
+
if (t && t.length <= 32 && visible(b)) W.buttons[t] = (W.buttons[t] || 0) + 1;
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
title: document.title || null,
|
|
201
|
+
engines,
|
|
202
|
+
adapters: W.adapters,
|
|
203
|
+
adapter_errors: W.adapterErrors,
|
|
204
|
+
init_error: W.initError || null,
|
|
205
|
+
contexts: [...new Set(canvases.filter((c) => document.contains(c.canvas)).map((c) => c.type))],
|
|
206
|
+
webgpu: !!W.webgpu,
|
|
207
|
+
canvas: main ? { type: main.type, x: rect.left, y: rect.top, width: rect.width, height: rect.height, pixels: [main.canvas.width, main.canvas.height] } : null,
|
|
208
|
+
frame: frame && !main ? { src: frame.src, ...JSON.parse(JSON.stringify(frame.getBoundingClientRect())) } : null,
|
|
209
|
+
labels: W.labels,
|
|
210
|
+
screen_labels: now,
|
|
211
|
+
buttons: W.buttons,
|
|
212
|
+
heap_mb: performance.memory ? Math.round(performance.memory.usedJSHeapSize / 1048576) : null,
|
|
213
|
+
session: gd?.sessionId || null,
|
|
214
|
+
level: gd?.level ?? null,
|
|
215
|
+
sdk_engine: gd?.engine?.name || null,
|
|
216
|
+
sent: gd?.stats?.sent ?? 0,
|
|
217
|
+
failed: gd?.stats?.failed ?? 0,
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// Just the rectangle of the canvas the game draws on (the largest one shown), for the bot's clicks and screenshots:
|
|
222
|
+
// cheap enough to ask for between inputs, unlike read().
|
|
223
|
+
W.area = () => {
|
|
224
|
+
let best = null;
|
|
225
|
+
let size = 0;
|
|
226
|
+
for (const c of canvases) {
|
|
227
|
+
if (!c.canvas.isConnected) continue;
|
|
228
|
+
const r = c.canvas.getBoundingClientRect();
|
|
229
|
+
const a = Math.max(0, Math.min(r.right, innerWidth) - Math.max(r.left, 0)) * Math.max(0, Math.min(r.bottom, innerHeight) - Math.max(r.top, 0));
|
|
230
|
+
if (a > size) [best, size] = [r, a];
|
|
231
|
+
}
|
|
232
|
+
return best ? { x: best.left, y: best.top, width: best.width, height: best.height } : null;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// Frames since the last step, for the bot's timeline: { n, late, p50, p95, max, draws } (ms; draw calls a frame).
|
|
236
|
+
// Late, as Glitchless counts it: over 1.15× the frame budget the SDK found for this screen (60, 120 Hz…).
|
|
237
|
+
W.take = () => {
|
|
238
|
+
const xs = W.dts.splice(0).sort((a, b) => a - b);
|
|
239
|
+
const draws = W.drawFrames.splice(0);
|
|
240
|
+
const budget = gd?.budgetMs || 1000 / 60;
|
|
241
|
+
const q = (p) => (xs.length ? Math.round(xs[Math.min(xs.length - 1, Math.floor(p * xs.length))] * 10) / 10 : null);
|
|
242
|
+
const drawn = draws.filter((d) => d > 0);
|
|
243
|
+
return { n: xs.length, late: xs.filter((x) => x > budget * 1.15).length, p50: q(0.5), p95: q(0.95), max: xs.length ? Math.round(xs[xs.length - 1]) : null, draws: drawn.length ? Math.round(drawn.reduce((a, b) => a + b, 0) / drawn.length) : null };
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
// What the bot did, on the check's own board ("What the bot did"): a few events a run, never per input.
|
|
247
|
+
W.step = (attrs) => {
|
|
248
|
+
try {
|
|
249
|
+
gd?.track('glitchless_check', attrs);
|
|
250
|
+
} catch {}
|
|
251
|
+
};
|
|
252
|
+
}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
// What a game check says: the report for the game's maker (markdown), the three sentences to send them with the link,
|
|
2
|
+
// and the dashboard made for their game. Plain words with players as the unit ("a player on a phone waits 31
|
|
3
|
+
// seconds"), and always that the numbers come from Glitchless's test machine, not from the game's players. The
|
|
4
|
+
// measurements an agent wants (percentiles, findings' ids) go in their own part at the end.
|
|
5
|
+
|
|
6
|
+
export const CHECK_PAGE = 'check';
|
|
7
|
+
|
|
8
|
+
const isNum = (v) => typeof v === 'number' && Number.isFinite(v);
|
|
9
|
+
const r0 = (v) => Math.round(v);
|
|
10
|
+
const r1 = (v) => Math.round(v * 10) / 10;
|
|
11
|
+
const mb = (b) => (b >= 1048576 ? `${r1(b / 1048576)} MB` : `${Math.max(1, Math.round(b / 1024))} KB`);
|
|
12
|
+
const median = (xs) => {
|
|
13
|
+
const s = xs.filter(isNum).sort((a, b) => a - b);
|
|
14
|
+
return s.length ? s[Math.floor(s.length / 2)] : null;
|
|
15
|
+
};
|
|
16
|
+
const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
17
|
+
const seconds = (s) => (s >= 90 ? `${r1(s / 60)} minutes` : `${r0(s)} seconds`);
|
|
18
|
+
|
|
19
|
+
// Engines by the names check-page.js finds them by, as people write them.
|
|
20
|
+
const ENGINE_WORDS = { three: 'Three.js', phaser: 'Phaser', babylon: 'Babylon.js', playcanvas: 'PlayCanvas', unity: 'Unity', godot: 'Godot', gamemaker: 'GameMaker', construct: 'Construct', gdevelop: 'GDevelop', defold: 'Defold', pixi: 'PixiJS', 'pico-8': 'PICO-8', kaplay: 'KAPLAY', ruffle: 'Flash (played with Ruffle)', emscripten: 'WebAssembly (Emscripten)' };
|
|
21
|
+
|
|
22
|
+
// What the game is made with, in words: "Phaser 3.88 on WebGL", "Unity", "a 2D canvas, no engine Glitchless knows".
|
|
23
|
+
export function engineWords(page) {
|
|
24
|
+
if (!page) return null;
|
|
25
|
+
const e = page.engines?.[0];
|
|
26
|
+
const drawing = page.webgpu ? 'WebGPU' : page.contexts?.includes('webgl2') || page.contexts?.includes('webgl') ? 'WebGL' : page.contexts?.includes('2d') ? 'a 2D canvas' : null;
|
|
27
|
+
if (e) {
|
|
28
|
+
const name = ENGINE_WORDS[e.name] || e.name.replace(/^rpg maker/, 'RPG Maker');
|
|
29
|
+
const version = e.version && e.name !== 'three' ? ` ${e.version}` : e.version ? ` r${String(e.version).replace(/^r/, '')}` : '';
|
|
30
|
+
return `${name}${version}${drawing && !['unity', 'godot', 'gamemaker'].includes(e.name) ? ` on ${drawing}` : ''}`;
|
|
31
|
+
}
|
|
32
|
+
return drawing ? `${drawing === 'a 2D canvas' ? 'a 2D canvas' : drawing}, with no engine Glitchless recognises` : 'an HTML page with no canvas';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// One profile's numbers: loading, frames, freezes, errors and memory, from Glitchless's summary of its session when
|
|
36
|
+
// there is one, else from what the bot measured itself.
|
|
37
|
+
export function profileNumbers(run, summary) {
|
|
38
|
+
const s = summary?.runs?.find((x) => x.session_id === run.session_id) || null;
|
|
39
|
+
const steps = (run.steps || []).filter((st) => st.frames?.n);
|
|
40
|
+
const frames = steps.map((st) => st.frames);
|
|
41
|
+
const worst = steps.reduce((w, st) => ((st.frames.p95 ?? 0) > (w?.frames.p95 ?? 0) ? st : w), null);
|
|
42
|
+
// The longest single frame, and when: a freeze players notice (over 50 ms).
|
|
43
|
+
const longest = steps.reduce((w, st) => ((st.frames.max ?? 0) > (w?.frames.max ?? 0) ? st : w), null);
|
|
44
|
+
const heaps = (run.steps || []).map((st) => st.heap_mb).filter(isNum);
|
|
45
|
+
const third = Math.max(1, Math.floor(heaps.length / 3));
|
|
46
|
+
const avg = (xs) => xs.reduce((a, b) => a + b, 0) / Math.max(1, xs.length);
|
|
47
|
+
const [h1, h2, h3] = [avg(heaps.slice(0, third)), avg(heaps.slice(third, third * 2)), avg(heaps.slice(-third))];
|
|
48
|
+
const heap = heaps.length >= 3 ? { start: heaps[0], end: heaps.at(-1), peak: Math.max(...heaps), climbing: heaps.at(-1) - heaps[0] >= 15 && h3 > h2 && h2 > h1 } : null;
|
|
49
|
+
// Late frames from the bot's own clock when Glitchless's summary is missing (the same 1.15× budget).
|
|
50
|
+
const counted = frames.reduce((a, f) => a + f.n, 0);
|
|
51
|
+
const localSlow = counted ? r1((frames.reduce((a, f) => a + (f.late || 0), 0) / counted) * 100) : null;
|
|
52
|
+
return {
|
|
53
|
+
profile: run.profile,
|
|
54
|
+
played_s: run.seconds_played ?? null,
|
|
55
|
+
ready_s: run.load?.ready_s ?? null,
|
|
56
|
+
load_timed_out: !!run.load?.timed_out,
|
|
57
|
+
bytes: run.load?.bytes ?? null,
|
|
58
|
+
requests: run.load?.requests ?? null,
|
|
59
|
+
late_pct: s?.pct_over_budget ?? localSlow,
|
|
60
|
+
budget_ms: s?.budget_ms ?? null,
|
|
61
|
+
p50: s?.p50 ?? median(frames.map((f) => f.p50)),
|
|
62
|
+
p95: s?.p95 ?? median(frames.map((f) => f.p95)),
|
|
63
|
+
hitches: s?.hitches ?? null,
|
|
64
|
+
errors: s?.errors ?? null,
|
|
65
|
+
gpu: s?.gpu ?? null,
|
|
66
|
+
draws: median(frames.map((f) => f.draws)),
|
|
67
|
+
freeze: longest && longest.frames.max > 50 ? { t: longest.t, max: longest.frames.max, words: longest.words, label: longest.label || longest.level || null } : null,
|
|
68
|
+
worst: worst && worst.frames.p95 > 25 ? { t: worst.t, p95: worst.frames.p95, max: worst.frames.max, words: worst.words, label: worst.label || worst.level || null, screen: worst.screen || null } : null,
|
|
69
|
+
heap,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// "1 in 40 frames" for a share of frames that were late.
|
|
74
|
+
function lateWords(pct) {
|
|
75
|
+
if (!isNum(pct)) return null;
|
|
76
|
+
if (pct < 0.5) return 'fewer than 1 in 200 frames';
|
|
77
|
+
if (pct >= 40) return `${r0(pct)}% of frames`;
|
|
78
|
+
return `1 in ${r0(100 / pct)} frames`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// The errors of the check, merged: Glitchless's (with where they happened) first, then what the browser printed.
|
|
82
|
+
function errorList(result) {
|
|
83
|
+
const out = [];
|
|
84
|
+
const runs = result.profiles.filter((p) => p.session_id).length;
|
|
85
|
+
for (const e of result.summary?.errors || []) out.push({ message: e.message, location: e.location || null, count: e.count, runs: e.sessions, of: runs, kind: e.kind });
|
|
86
|
+
for (const p of result.profiles)
|
|
87
|
+
for (const m of p.errors || []) {
|
|
88
|
+
const msg = m.replace(/^console: /, '');
|
|
89
|
+
if (out.some((e) => e.message && (msg.includes(e.message) || e.message.includes(msg)))) continue;
|
|
90
|
+
const have = out.find((e) => e.message === msg && !e.location);
|
|
91
|
+
if (have) have.runs = Math.min(runs, (have.runs || 1) + 1);
|
|
92
|
+
else out.push({ message: msg, location: null, count: null, runs: 1, of: runs, console: m.startsWith('console: ') });
|
|
93
|
+
}
|
|
94
|
+
return out.filter((e) => e.message);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// What the bot saw that a dashboard with Glitchless installed would count: levels and waves on screen (or the scenes
|
|
98
|
+
// an engine adapter reported), the modes its buttons offer, and the inputs the game answered to.
|
|
99
|
+
const MODE = /^(easy|normal|medium|hard|expert|insane|endless|story|arcade|survival|classic|versus|vs\.?|co-?op|multiplayer|single ?player|1 ?player|2 ?players?|practice|tutorial|daily( challenge)?|challenge|campaign|online|local|time attack|zen|casual|ranked|sandbox|creative|level select|free play|puzzle|speedrun)$/i;
|
|
100
|
+
export function whatTheBotSaw(result) {
|
|
101
|
+
const labels = {};
|
|
102
|
+
const modes = new Set();
|
|
103
|
+
const levels = new Set();
|
|
104
|
+
for (const p of result.profiles) {
|
|
105
|
+
for (const [k, n] of Object.entries(p.page?.labels || {})) labels[k] = (labels[k] || 0) + n;
|
|
106
|
+
for (const b of Object.keys(p.page?.buttons || {})) if (MODE.test(b.trim())) modes.add(b.trim());
|
|
107
|
+
for (const st of p.steps || []) {
|
|
108
|
+
if (st.label) labels[st.label] = (labels[st.label] || 0) + 1;
|
|
109
|
+
if (st.level) levels.add(st.level);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
for (const l of Object.keys(result.summary?.levels || {})) levels.add(l);
|
|
113
|
+
const order = (a, b) => a.localeCompare(b, undefined, { numeric: true });
|
|
114
|
+
const shown = Object.keys(labels).sort(order).slice(0, 12);
|
|
115
|
+
const worked = [...new Set(result.profiles.flatMap((p) => p.inputs?.worked || []))];
|
|
116
|
+
return { labels: shown, levels: [...levels].sort(order).slice(0, 12), modes: [...modes].slice(0, 8), worked };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// The sentences that lead: the most useful thing the check found first (an error, a phone that can't keep up, a long
|
|
120
|
+
// load, memory that climbs), else that it ran well. Each is about players.
|
|
121
|
+
export function headlines(result) {
|
|
122
|
+
const out = [];
|
|
123
|
+
const nums = Object.fromEntries(result.profiles.map((p) => [p.profile, profileNumbers(p, result.summary)]));
|
|
124
|
+
const d = nums.desktop;
|
|
125
|
+
const ph = nums.phone;
|
|
126
|
+
const errors = errorList(result).filter((e) => !e.console);
|
|
127
|
+
if (errors.length) {
|
|
128
|
+
const e = errors[0];
|
|
129
|
+
const every = e.of > 1 && e.runs >= e.of;
|
|
130
|
+
const at = whereWords(e.location);
|
|
131
|
+
out.push({ weight: 100, text: `${every ? 'every run hit' : e.of > 1 ? `${e.runs} of ${e.of} runs hit` : 'the run hit'} an error${at ? ` in ${at}` : ''} ("${e.message.slice(0, 90)}")${errors.length > 1 ? `, one of ${errors.length} different errors` : ''}, so players ${every ? 'likely' : 'may'} hit it too` });
|
|
132
|
+
}
|
|
133
|
+
const loadOf = (n) => (n?.load_timed_out ? `more than ${r0(n.ready_s)} seconds` : isNum(n?.ready_s) ? `about ${r0(Math.max(1, n.ready_s))} seconds` : null);
|
|
134
|
+
if (ph && isNum(ph.late_pct) && ph.late_pct >= 10) out.push({ weight: 80 + ph.late_pct / 5, text: `on a phone-speed CPU the game can't keep up: ${lateWords(ph.late_pct)} came late${d && isNum(d.late_pct) ? `, against ${lateWords(d.late_pct)} on a desktop` : ''}, so a player on a mid-range phone feels it stutter` });
|
|
135
|
+
if (d && isNum(d.late_pct) && d.late_pct >= 5) out.push({ weight: 85, text: `even on a fast desktop, ${lateWords(d.late_pct)} came late${d.worst ? `, worst ${r0(d.worst.t)} seconds in (${d.worst.label || d.worst.words}): frames took up to ${r0(d.worst.max || d.worst.p95)} ms` : ''}` });
|
|
136
|
+
for (const n of [d, ph].filter(Boolean)) {
|
|
137
|
+
const perMin = isNum(n.hitches) && n.played_s ? n.hitches / (n.played_s / 60) : 0;
|
|
138
|
+
if (perMin < 3) continue;
|
|
139
|
+
out.push({ weight: 75 + Math.min(10, perMin), text: `the game froze for a moment ${plural(n.hitches, 'time')} in ${seconds(n.played_s)} ${n.profile === 'phone' ? 'on the phone' : 'on a desktop'}${n.freeze ? `, the longest for ${r0(n.freeze.max)} ms${n.freeze.label ? ` on ${n.freeze.label}` : ''}` : ''}` });
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
const slowLoad = ph?.ready_s >= 15 ? ph : d?.ready_s >= 8 ? d : null;
|
|
143
|
+
if (slowLoad) out.push({ weight: 60 + Math.min(30, slowLoad.ready_s), text: `a player ${slowLoad === ph ? 'on a phone over 4G' : 'on a desktop'} waits ${loadOf(slowLoad)} before it's ready${isNum(slowLoad.bytes) ? `, while it downloads ${mb(slowLoad.bytes)}` : ''}` });
|
|
144
|
+
for (const n of [d, ph].filter(Boolean))
|
|
145
|
+
if (n.heap?.climbing) {
|
|
146
|
+
out.push({ weight: 70, text: `its memory kept climbing ${n.profile === 'phone' ? 'on the phone' : 'on the desktop'}, from ${n.heap.start} to ${n.heap.end} MB in ${seconds(n.played_s || 60)}, so a long session may run out (phones close the tab)` });
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
const missing = result.profiles.flatMap((p) => p.load?.missing || []);
|
|
150
|
+
const gone = new Set(missing.map((m) => m.url)).size;
|
|
151
|
+
if (gone) out.push({ weight: 40, text: `it asks for ${plural(gone, 'file')} that ${gone === 1 ? "isn't" : "aren't"} there (${missing[0].status})` });
|
|
152
|
+
if (!out.length && d) {
|
|
153
|
+
const fine = [`it ran smoothly on a desktop (${lateWords(d.late_pct) || 'almost no frames'} late)`];
|
|
154
|
+
if (ph) fine.push(isNum(ph.late_pct) ? `on a phone-speed CPU ${lateWords(ph.late_pct)} came late` : 'it held up on a phone-speed CPU');
|
|
155
|
+
if (isNum(d.ready_s)) fine.push(`it's ready to play in ${loadOf(d)}`);
|
|
156
|
+
out.push({ weight: 10, text: `good news: ${fine.join(', ')}, and the bots hit no errors` });
|
|
157
|
+
}
|
|
158
|
+
return out.sort((a, b) => b.weight - a.weight).map((h) => h.text);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// The three sentences to send the game's maker, with the link.
|
|
162
|
+
export function checkDm(result) {
|
|
163
|
+
const lead = headlines(result);
|
|
164
|
+
const link = result.share?.url || result.dashboard_url || '';
|
|
165
|
+
const name = result.game.name;
|
|
166
|
+
const where = result.profiles.some((p) => p.profile === 'phone') ? (result.profiles.some((p) => p.profile === 'desktop') ? ' on a desktop and on a throttled phone' : ' on a throttled phone') : ' on a desktop';
|
|
167
|
+
const first = `I had Glitchless's bots play ${name} for a few minutes${where}, and ${link ? `made a dashboard of what they found: ${link}` : 'wrote up what they found.'}`;
|
|
168
|
+
const finding = lead.slice(0, 2).join('; ');
|
|
169
|
+
const close = `It's from our test machine, not your players: with Glitchless in the game, your coding agent gets the same from every player's session${link ? ', and the board is yours to keep' : ''}.`;
|
|
170
|
+
return `${first}\n\n${finding ? `${finding[0].toUpperCase()}${finding.slice(1)}. ` : ''}${close}`;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// The report, in markdown.
|
|
174
|
+
export function checkReport(result) {
|
|
175
|
+
const { game, target } = result;
|
|
176
|
+
const runs = result.profiles;
|
|
177
|
+
const nums = runs.map((p) => profileNumbers(p, result.summary));
|
|
178
|
+
const page = runs.find((p) => p.page)?.page || runs.find((p) => p.page_start)?.page_start;
|
|
179
|
+
const engine = engineWords(page);
|
|
180
|
+
const out = [`# Game check: ${game.name}`, ''];
|
|
181
|
+
out.push(`${target.page_url}${target.site ? ` (${target.site})` : ''} · checked ${result.checked_at.slice(0, 16).replace('T', ' ')} UTC by Glitchless's bots${engine ? ` · made with ${engine}` : ''}`, '');
|
|
182
|
+
const lead = headlines(result);
|
|
183
|
+
if (lead.length) out.push(...lead.slice(0, 3).map((h) => `- ${h[0].toUpperCase()}${h.slice(1)}.`), '');
|
|
184
|
+
const link = result.share?.url || result.dashboard_url;
|
|
185
|
+
if (link) out.push(`The dashboard: ${link}${result.share?.url ? ` (unlisted, shows this check only, for 30 days)` : ''}`, '');
|
|
186
|
+
for (const n of result.notes || []) out.push(`> ${n}`, '');
|
|
187
|
+
|
|
188
|
+
out.push('## What the bots did', '');
|
|
189
|
+
for (const p of runs) {
|
|
190
|
+
const label = p.profile === 'phone' ? 'On a phone' : 'On a desktop';
|
|
191
|
+
if (p.stopped && !p.steps?.length) {
|
|
192
|
+
out.push(`- **${label}** (${p.words}): ${p.stopped}.`);
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
const tried = p.inputs?.tried?.length ? ` It tried ${p.inputs.tried.join('; ')}.` : '';
|
|
196
|
+
const worked = p.inputs?.worked?.length ? ` The screen changed most with ${p.inputs.worked.slice(0, 2).join(', then ')}.` : p.inputs?.tried?.length ? ' No input changed the screen more than waiting did, so the bot may not have got past the start.' : '';
|
|
197
|
+
const carried = (p.steps || []).filter((s) => s.carried_on).length;
|
|
198
|
+
out.push(`- **${label}** (${p.words}): played ${seconds(p.seconds_played || 0)}. ${(p.notes || []).filter((n) => n.startsWith('To start')).join(' ')}${tried}${worked}${carried ? ` The screen stopped changing ${plural(carried, 'time')} (a game over or a menu), and the bot carried on.` : ''}`);
|
|
199
|
+
}
|
|
200
|
+
if (result.ai) out.push(`- The inputs were picked by ${result.ai.model}, which looked at the screen ${plural(result.ai.calls, 'time')}.`);
|
|
201
|
+
out.push('');
|
|
202
|
+
|
|
203
|
+
const cols = nums.map((n) => (n.profile === 'phone' ? 'Phone' : 'Desktop'));
|
|
204
|
+
const row = (label, f) => `| ${label} | ${nums.map((n) => f(n) ?? '–').join(' | ')} |`;
|
|
205
|
+
out.push('## Loading and play', '', `| | ${cols.join(' | ')} |`, `| --- | ${cols.map(() => '---:').join(' | ')} |`);
|
|
206
|
+
out.push(row('Ready to play after', (n) => (isNum(n.ready_s) ? `${n.load_timed_out ? 'over ' : ''}${r0(Math.max(1, n.ready_s))} s` : null)));
|
|
207
|
+
out.push(row('Downloaded', (n) => (isNum(n.bytes) ? mb(n.bytes) : null)));
|
|
208
|
+
out.push(row('Late frames', (n) => lateWords(n.late_pct)));
|
|
209
|
+
out.push(row('A typical frame', (n) => (isNum(n.p50) ? `${r1(n.p50)} ms` : null)));
|
|
210
|
+
out.push(row('The slowest 1 in 20 frames', (n) => (isNum(n.p95) ? `${r1(n.p95)} ms or more` : null)));
|
|
211
|
+
out.push(row('Freezes (a frame over 50 ms)', (n) => (isNum(n.hitches) ? String(n.hitches) : null)));
|
|
212
|
+
out.push(row('Draw calls a frame', (n) => (isNum(n.draws) ? String(n.draws) : null)));
|
|
213
|
+
out.push(row('JavaScript memory', (n) => (n.heap ? `${n.heap.start} → ${n.heap.end} MB${n.heap.climbing ? ', climbing' : ''}` : null)));
|
|
214
|
+
out.push('');
|
|
215
|
+
const budget = nums.find((n) => n.budget_ms)?.budget_ms;
|
|
216
|
+
out.push(`A frame is late when it takes more than 1.15 times the screen's frame time${budget ? ` (${r1(budget)} ms)` : ''}; players feel late frames as stutter.`);
|
|
217
|
+
for (const n of nums)
|
|
218
|
+
if (n.freeze) out.push(`${n.profile === 'phone' ? 'On the phone' : 'On the desktop'}, the longest freeze came ${r0(n.freeze.t)} seconds in${n.freeze.label ? `, on ${n.freeze.label}` : ''}: one frame took ${r0(n.freeze.max)} ms.`);
|
|
219
|
+
for (const n of nums)
|
|
220
|
+
if (n.worst) out.push(`${n.profile === 'phone' ? 'On the phone' : 'On the desktop'}, the slowest moment came ${r0(n.worst.t)} seconds in${n.worst.label ? `, on ${n.worst.label}` : ''}, while the bot was ${n.worst.screen ? `playing (${n.worst.screen})` : `using ${n.worst.words}`}: frames took up to ${r0(n.worst.max || n.worst.p95)} ms.`);
|
|
221
|
+
const missing = [...new Map(runs.flatMap((p) => p.load?.missing || []).map((m) => [m.url, m])).values()];
|
|
222
|
+
if (missing.length) out.push('', `Files the game asks for that aren't there: ${missing.slice(0, 6).map((m) => `\`${m.url}\` (${m.status})`).join(', ')}${missing.length > 6 ? ', …' : ''}.`);
|
|
223
|
+
out.push('');
|
|
224
|
+
|
|
225
|
+
const errors = errorList(result);
|
|
226
|
+
out.push('## Errors', '');
|
|
227
|
+
if (!errors.length) out.push('The bots hit no errors.');
|
|
228
|
+
for (const e of errors.slice(0, 8)) out.push(`- \`${e.message.slice(0, 200)}\`${e.location ? ` at ${e.location}` : ''}${e.count ? `: ${plural(e.count, 'time')}` : ''}${e.of > 1 ? `, in ${e.runs} of ${e.of} runs` : ''}${e.console ? ' (printed to the console)' : ''}`);
|
|
229
|
+
out.push('');
|
|
230
|
+
|
|
231
|
+
const saw = whatTheBotSaw(result);
|
|
232
|
+
out.push('## With Glitchless installed', '');
|
|
233
|
+
out.push('These numbers are from two bot runs. With Glitchless in the game, the same comes from every player\'s session, on their own phones and computers, and the dashboard\'s other pages fill in:');
|
|
234
|
+
out.push(`- Where players stop${saw.labels.length || saw.levels.length ? `: the bot saw ${listWords((saw.levels.length ? saw.levels : saw.labels).slice(0, 6))}` : ''}, and how many get through each.`);
|
|
235
|
+
if (saw.modes.length) out.push(`- Which modes keep players: ${listWords(saw.modes)}.`);
|
|
236
|
+
out.push(`- What players do${saw.worked.length ? ` with ${saw.worked.slice(0, 2).join(' and with ')}` : ''}: the game's own actions, counted per player, and who comes back the next day.`);
|
|
237
|
+
out.push('- Errors with the level, the device and what the player did just before.');
|
|
238
|
+
if (target.site === 'itch.io') out.push("- With the itch.io page connected, its views, downloads and ratings next to the plays Glitchless counts.");
|
|
239
|
+
out.push('', 'To add it, paste this into your coding agent: "Add Glitchless (www.glitchless.gg) to this game, then make it a dashboard."', '');
|
|
240
|
+
|
|
241
|
+
out.push('## The fine print', '');
|
|
242
|
+
const m = result.machine || {};
|
|
243
|
+
out.push(`- Every number here comes from Glitchless's test machine (${[m.os, m.cpu, nums.find((n) => n.gpu)?.gpu, m.browser].filter(Boolean).join(', ')}), not from the game's players.${nums.some((n) => n.profile === 'phone') ? " The phone is that same computer with its CPU slowed 4×, a phone's screen and a 4G-like connection, not a real phone." : ''}`);
|
|
244
|
+
out.push('- The check is private: its game and dashboard are in the checker\'s own Glitchless workspace, nothing ranks games, and its bot runs are marked as bots, so they never count as players.');
|
|
245
|
+
out.push(`- It played a few minutes from one computer and asked the site's robots.txt first.${target.site === 'itch.io' ? ' itch.io\'s game frame was played on its own, at the size the page shows it.' : ''}`);
|
|
246
|
+
out.push('');
|
|
247
|
+
|
|
248
|
+
out.push('## For your coding agent', '');
|
|
249
|
+
out.push(`Glitchless game "${game.in_glitchless || game.name}", service \`${game.service}\`${game.id ? ` (${game.id})` : ''}, version \`${game.version}\`, sessions ${runs.map((p) => p.session_id && `\`${p.session_id}\` (${p.profile})`).filter(Boolean).join(', ') || 'none'}; read them with glitchless_triage or glitchless_session.`);
|
|
250
|
+
const f = result.findings || [];
|
|
251
|
+
if (f.length) {
|
|
252
|
+
out.push('', 'Findings:');
|
|
253
|
+
for (const x of f.slice(0, 8)) out.push(`- [${x.severity}] ${x.title} (\`${x.id}\`)`);
|
|
254
|
+
}
|
|
255
|
+
const adapters = [...new Set(runs.flatMap((p) => p.page?.adapters || []))];
|
|
256
|
+
const adapterErrors = [...new Set(runs.flatMap((p) => p.page?.adapter_errors || []))];
|
|
257
|
+
if (adapters.length) out.push('', `The check handed the game's ${listWords(adapters.map((a) => ENGINE_WORDS[a] || a))} engine to Glitchless's adapter, as installing Glitchless with its defaults would.`);
|
|
258
|
+
if (adapterErrors.length) out.push('', `Adapter problems: ${adapterErrors.join('; ')}.`);
|
|
259
|
+
const notes = runs.flatMap((p) => (p.notes || []).filter((n) => !n.startsWith('To start')));
|
|
260
|
+
if (notes.length) out.push('', ...notes.map((n) => `- ${n}`));
|
|
261
|
+
return out.join('\n');
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Where an error happened, short: "fireLaser" for a function in an inline script, "player.js:120" for a file.
|
|
265
|
+
function whereWords(location) {
|
|
266
|
+
if (!location) return null;
|
|
267
|
+
const m = String(location).match(/^(.+?) \((.*?):(\d+)(?::\d+)?\)$/);
|
|
268
|
+
if (m) return m[2] === '?' || !m[2] ? m[1] : `${m[1]} (${m[2].split(/[\\/]/).pop()}:${m[3]})`;
|
|
269
|
+
return String(location).split(/[\\/]/).pop();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function listWords(xs) {
|
|
273
|
+
const a = [...xs];
|
|
274
|
+
return a.length <= 1 ? a.join('') : `${a.slice(0, -1).join(', ')} and ${a.at(-1)}`;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// The dashboard made for the game: the check's page first (the one its share link shows), then the pages that fill
|
|
278
|
+
// in once Glitchless is installed, named so, with notes built from what the bot saw. ≤ 200 characters a note.
|
|
279
|
+
export function checkDashboard(result) {
|
|
280
|
+
const saw = whatTheBotSaw(result);
|
|
281
|
+
const where = (saw.levels.length ? saw.levels : saw.labels).slice(0, 4);
|
|
282
|
+
const bot = 'From Glitchless\'s bots on its test machine, not players.';
|
|
283
|
+
const installed = 'Fills in with Glitchless installed:';
|
|
284
|
+
const cut = (s) => (s.length > 200 ? `${s.slice(0, 197)}…` : s);
|
|
285
|
+
const check = {
|
|
286
|
+
id: CHECK_PAGE,
|
|
287
|
+
title: 'Game check',
|
|
288
|
+
icon: 'overview',
|
|
289
|
+
panels: [
|
|
290
|
+
{ type: 'stat', metric: 'avg_fps', title: 'Frames a second', size: 's', note: cut(`${bot} Desktop and phone runs together.`) },
|
|
291
|
+
{ type: 'stat', metric: 'frame_p95', title: 'Slowest 1 in 20 frames (ms)', size: 's', note: cut(`${bot} Over 1.15× the screen's frame time is a late frame.`) },
|
|
292
|
+
{ type: 'stat', metric: 'hitches_per_min', title: 'Freezes a minute', size: 's', note: cut(`${bot} A freeze is a frame over 50 ms, well above the frames around it.`) },
|
|
293
|
+
{ type: 'stat', metric: 'errors', title: 'Errors', size: 's', note: bot },
|
|
294
|
+
{ type: 'versions', by: '$profile', title: 'Desktop and a throttled phone', size: 'l', note: cut(`${bot} Phone: the same computer with its CPU slowed 4×, a phone's screen and a 4G-like connection.`) },
|
|
295
|
+
{ type: 'frame_time', title: 'Frame time while the bots played', size: 'm', note: bot },
|
|
296
|
+
...(result.findings?.length ? [{ type: 'findings', title: 'What to fix first', size: 'm', limit: 6 }] : []),
|
|
297
|
+
{ type: 'errors', title: 'Errors the bots hit', size: 'm', limit: 8, note: bot },
|
|
298
|
+
{ type: 'table', event: 'glitchless_check', title: 'What the bots did', size: 'm', columns: ['profile', 'step', 'input', 'screen', 'label'], limit: 12, note: 'Each step of the bots\' play: the inputs they tried and whether the screen moved.' },
|
|
299
|
+
{ type: 'levels', title: 'Levels (with Glitchless installed)', size: 'l', note: cut(`${installed} where players stop and how many get through${where.length ? `. The bots saw ${listWords(where)}` : ''}.`) },
|
|
300
|
+
],
|
|
301
|
+
};
|
|
302
|
+
const players = {
|
|
303
|
+
id: 'players',
|
|
304
|
+
title: 'Players · with Glitchless installed',
|
|
305
|
+
icon: 'players',
|
|
306
|
+
panels: [
|
|
307
|
+
{ type: 'stat', metric: 'players', title: 'Players', size: 's', note: cut(`${installed} people who played, never bots.`) },
|
|
308
|
+
{ type: 'stat', metric: 'median_session_s', title: 'A typical session (s)', size: 's', note: installed.replace(':', '.') },
|
|
309
|
+
{ type: 'stat', metric: 'crash_free_pct', title: 'Sessions without a crash (%)', size: 's', note: installed.replace(':', '.') },
|
|
310
|
+
{ type: 'stat', metric: 'rage_quit_pct', title: 'Quit in frustration (%)', size: 's', note: cut(`${installed} players who left right after dying or failing.`) },
|
|
311
|
+
{ type: 'retention', title: 'Players coming back', size: 'l', note: cut(`${installed} who comes back the next day and the next week (with player IDs on).`) },
|
|
312
|
+
{ type: 'deaths', title: 'Where players die', size: 'm', note: cut(`${installed} deaths by level and cause.`) },
|
|
313
|
+
{ type: 'levels', title: 'Levels', size: 'm', note: cut(`${installed} starts, clears and fails per level${where.length ? ` (the bots saw ${listWords(where)})` : ''}.`) },
|
|
314
|
+
],
|
|
315
|
+
};
|
|
316
|
+
const play = {
|
|
317
|
+
id: 'play',
|
|
318
|
+
title: 'How they play · with Glitchless',
|
|
319
|
+
icon: 'events',
|
|
320
|
+
panels: [
|
|
321
|
+
{ type: 'events', title: "The game's own events", size: 'l', note: cut(`${installed} what the game counts with track(): ${saw.worked.length ? `the actions behind ${saw.worked.slice(0, 2).join("; ")}` : 'its actions'}, picks and purchases.`) },
|
|
322
|
+
{ type: 'versions', by: '$mode', title: 'Modes side by side', size: 'l', note: cut(`${installed} each mode's numbers, with the mode set as a session property${saw.modes.length ? `. The bots saw ${listWords(saw.modes)}` : ''}.`) },
|
|
323
|
+
{ type: 'reports', title: 'Bug reports from players', size: 'm', note: cut(`${installed} players send a bug report from the game (F8), with a screenshot.`) },
|
|
324
|
+
],
|
|
325
|
+
};
|
|
326
|
+
return [check, players, play, { id: 'performance', title: 'Performance', view: 'performance' }, { id: 'errors', title: 'Errors', view: 'errors' }, { id: 'sessions', title: "The bots' runs", icon: 'sessions', view: 'sessions' }];
|
|
327
|
+
}
|