[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CS64AKYVJBGMH85TPZ5DHS":3,"skill-same:01M7CS64AKYVJBGMH85TPZ5DHS":50},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":32,"ownerHtmlUrl":33,"ownerBlogUrl":6,"ownerDescription":34,"updatedAt":35,"install":36,"resources":49},"01M7CS64AKYVJBGMH85TPZ5DHS","web-game-performance-and-testing",null,"Use when working on any browser game (Phaser, PixiJS, three.js, Babylon.js, PlayCanvas, Excalibur, KAPLAY) - requestAnimationFrame with clamped delta and visibility pause, zero-allocation frame loops, measuring in DevTools, bundle and asset size budgets, Vitest with seeded RNG and injected time, and a seeded Playwright smoke test with console capture.","makifbaysal\u002Ftasktrooper","makifbaysal","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F25031940?v=4","01M7CRG3ZCSYZSSEVDMW3DEYC8","Mehmet Akif Baysal","01M7CRG401FJ8YAXH5ER730XYV",122,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fgame-developer\u002Fskills\u002Fweb-game-performance-and-testing\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: web-game-performance-and-testing\ncategory: performance\ndescription: Use when working on any browser game (Phaser, PixiJS, three.js, Babylon.js, PlayCanvas, Excalibur, KAPLAY) - requestAnimationFrame with clamped delta and visibility pause, zero-allocation frame loops, measuring in DevTools, bundle and asset size budgets, Vitest with seeded RNG and injected time, and a seeded Playwright smoke test with console capture.\ntech_stack: Web 2D\nsource: informed by the MDN, Chrome DevTools, Vite, Vitest and Playwright documentation; own wording\n---\n# Web Game Performance and Testing\n\n## Overview\n\nA browser game shares a thread with the page, a garbage collector with every closure, and a download budget with the player's patience. It is also the easiest kind of game for you to verify end to end on this machine: the build, the unit tests and a real browser run are all available. Use them.\n\n**Core principle:** No allocations in the frame loop, a measured bundle, rules tested in Vitest with injected time and a seed, and one seeded Playwright smoke test that fails on console errors.\n\n## The frame loop in the browser\n\n- Drive it with `requestAnimationFrame` (or the engine's loop built on it); never `setInterval`.\n- Browsers throttle or stop rAF in hidden tabs: clamp the delta (≤ 0.25 s), pause the simulation on `document.visibilitychange`, and resume without a catch-up burst.\n- Fixed-step simulation with an accumulator and interpolated rendering (game-loop-and-time); engines with built-in physics steps (Phaser Arcade) already do this for bodies.\n- Audio needs a user gesture: create or `resume()` the `AudioContext` on the first click\u002Fkey\u002Ftap.\n- On touch devices the canvas sets `touch-action: none` so gestures do not scroll or zoom the page.\n\n## No garbage in the loop\n\n```ts\n\u002F\u002F ❌ allocates every frame: new vectors, arrays, closures\nfunction update(dt: number) {\n  const dir = new THREE.Vector3().subVectors(target.position, enemy.position).normalize();\n  enemies.filter((e) => e.alive).forEach((e) => e.step(dt));\n  hud.setText(`Score: ${score}`);\n}\n\n\u002F\u002F ✅ reuses module-level temporaries; plain loops; updates text only on change\nconst tmp = new THREE.Vector3();\nlet shownScore = -1;\nfunction update(dt: number) {\n  tmp.subVectors(target.position, enemy.position).normalize();\n  for (let i = 0; i \u003C enemies.length; i++) if (enemies[i].alive) enemies[i].step(dt);\n  if (score !== shownScore) { shownScore = score; hud.setText(`Score: ${score}`); }\n}\n```\n\nPool bullets, particles and damage numbers; prefer typed arrays (`Float32Array`) for large particle or boid sets; avoid `Array.prototype.map\u002Ffilter\u002FforEach` with fresh closures in hot paths.\n\n## Measure\n\n- Chrome DevTools Performance: record 5–10 s of the changed scene, read frame times and the Bottom-up tab; look for GC events (`Minor GC`) in the frame track.\n- Memory: heap snapshot before entering and after leaving a level — growth means a leak (undisposed textures, listeners left on a global emitter, pooled objects never released).\n- Engine counters: `renderer.info` (three.js), Babylon Inspector statistics, PixiJS devtools, Phaser's debug FPS.\n- In code: `performance.mark`\u002F`performance.measure` around a system to get numbers into a test or log.\n- Never take frame-rate numbers from headless Chromium — it renders WebGL in software. Report numbers from a real browser profile, or say you could not.\n\n## Bundle and assets\n\n- Read the build output: `npm run build` lists chunk sizes; add `rollup-plugin-visualizer` only if the repository already has it.\n- Keep the engine and the first scene in the initial chunk; split later levels with dynamic `import()`.\n- Textures: atlases and compressed formats (KTX2 for 3D, WebP\u002FAVIF for 2D); audio: compressed (OGG\u002FOpus plus an AAC\u002FM4A fallback where Safari needs it).\n- Respect the repository's size budget; without one, report the initial JS gzip size and the first-scene asset weight in the closing message when you changed either.\n\n## Vitest for rules\n\n```ts\n\u002F\u002F src\u002Flogic\u002Frng.ts\nexport function mulberry32(seed: number) {\n  return () => { seed |= 0; seed = (seed + 0x6d2b79f5) | 0; let t = Math.imul(seed ^ (seed >>> 15), 1 | seed);\n    t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t; return ((t ^ (t >>> 14)) >>> 0) \u002F 4294967296; };\n}\n```\n\n```ts\n\u002F\u002F src\u002Flogic\u002Fspawner.test.ts\nimport { describe, it, expect } from \"vitest\";\nimport { Spawner } from \".\u002Fspawner\";\nimport { mulberry32 } from \".\u002Frng\";\n\ndescribe(\"Spawner\", () => {\n  it(\"spawns one wave every 5 seconds regardless of step size\", () => {\n    const a = new Spawner({ waveEverySeconds: 5 }, mulberry32(1));\n    const b = new Spawner({ waveEverySeconds: 5 }, mulberry32(1));\n    for (let i = 0; i \u003C 600; i++) a.step(1 \u002F 60);\n    for (let i = 0; i \u003C 300; i++) b.step(1 \u002F 30);\n    expect(a.wavesSpawned).toBe(2);\n    expect(b.wavesSpawned).toBe(2);\n  });\n\n  it(\"is deterministic for a seed\", () => {\n    const run = () => { const s = new Spawner({ waveEverySeconds: 1 }, mulberry32(42)); for (let i = 0; i \u003C 180; i++) s.step(1 \u002F 60); return s.positions(); };\n    expect(run()).toEqual(run());\n  });\n});\n```\n\n- Rules never import the engine, so tests run in Node without a canvas. Don't mock Phaser or three.js to test a scene — move the rule out.\n- Time is a parameter; where a module genuinely uses timers, `vi.useFakeTimers()` and `vi.advanceTimersByTime(ms)`.\n- Babylon scene logic can run under `NullEngine` in Vitest.\n\n## Playwright smoke test (seeded)\n\n```ts\n\u002F\u002F e2e\u002Fsmoke.spec.ts\nimport { test, expect } from \"@playwright\u002Ftest\";\n\ntest(\"boots, takes input, no console errors\", async ({ page }) => {\n  const errors: string[] = [];\n  page.on(\"pageerror\", (e) => errors.push(e.message));\n  page.on(\"console\", (m) => { if (m.type() === \"error\") errors.push(m.text()); });\n\n  await page.goto(\"\u002F?seed=42&scene=Level1&debug=1\");\n  await expect(page.locator(\"canvas\")).toBeVisible();\n  await expect.poll(() => page.evaluate(() => (window as any).__GAME__?.ready)).toBe(true);\n\n  await page.keyboard.press(\"Space\");\n  await expect.poll(() => page.evaluate(() => (window as any).__GAME__?.player.jumps)).toBe(1);\n\n  await page.screenshot({ path: \"test-results\u002Flevel1-after-jump.png\" });\n  expect(errors).toEqual([]);\n});\n```\n\n- A `window.__GAME__` read-only debug handle exposed only in debug\u002Fdev builds lets tests assert state instead of guessing from pixels.\n- Fixed seed and a direct scene parameter make runs reproducible. Pixel comparisons (`toHaveScreenshot`) only with the loop paused on a deterministic frame and a tolerance; GPU differences make exact matches flaky.\n- Run it the way the repository does (`npx playwright test`); if Playwright is not set up and not installed, use the browser tools and say what the smoke run would have covered (game-visual-self-review).\n\n## Common Mistakes\n\n- `setInterval` loops; unclamped delta after a background tab.\n- Temporaries allocated per frame in vector math.\n- Unit tests importing the engine and failing for lack of WebGL.\n- Smoke tests without a seed, flaking on random spawns.\n- Judging performance from a headless browser.\n\n## Red Flags\n\n- `new` inside the rAF callback or a system's `update`.\n- A Playwright test with no `pageerror` listener.\n- A bundle that grew by hundreds of KB for a small feature, unmentioned in the closing message.\n","# Web Game Performance and Testing\n\n## Overview\n\nA browser game shares a thread with the page, a garbage collector with every closure, and a download budget with the player's patience. It is also the easiest kind of game for you to verify end to end on this machine: the build, the unit tests and a real browser run are all available. Use them.\n\n**Core principle:** No allocations in the frame loop, a measured bundle, rules tested in Vitest with injected time and a seed, and one seeded Playwright smoke test that fails on console errors.\n\n## The frame loop in the browser\n\n- Drive it with `requestAnimationFrame` (or the engine's loop built on it); never `setInterval`.\n- Browsers throttle or stop rAF in hidden tabs: clamp the delta (≤ 0.25 s), pause the simulation on `document.visibilitychange`, and resume without a catch-up burst.\n- Fixed-step simulation with an accumulator and interpolated rendering (game-loop-and-time); engines with built-in physics steps (Phaser Arcade) already do this for bodies.\n- Audio needs a user gesture: create or `resume()` the `AudioContext` on the first click\u002Fkey\u002Ftap.\n- On touch devices the canvas sets `touch-action: none` so gestures do not scroll or zoom the page.\n\n## No garbage in the loop\n\n```ts\n\u002F\u002F ❌ allocates every frame: new vectors, arrays, closures\nfunction update(dt: number) {\n  const dir = new THREE.Vector3().subVectors(target.position, enemy.position).normalize();\n  enemies.filter((e) => e.alive).forEach((e) => e.step(dt));\n  hud.setText(`Score: ${score}`);\n}\n\n\u002F\u002F ✅ reuses module-level temporaries; plain loops; updates text only on change\nconst tmp = new THREE.Vector3();\nlet shownScore = -1;\nfunction update(dt: number) {\n  tmp.subVectors(target.position, enemy.position).normalize();\n  for (let i = 0; i \u003C enemies.length; i++) if (enemies[i].alive) enemies[i].step(dt);\n  if (score !== shownScore) { shownScore = score; hud.setText(`Score: ${score}`); }\n}\n```\n\nPool bullets, particles and damage numbers; prefer typed arrays (`Float32Array`) for large particle or boid sets; avoid `Array.prototype.map\u002Ffilter\u002FforEach` with fresh closures in hot paths.\n\n## Measure\n\n- Chrome DevTools Performance: record 5–10 s of the changed scene, read frame times and the Bottom-up tab; look for GC events (`Minor GC`) in the frame track.\n- Memory: heap snapshot before entering and after leaving a level — growth means a leak (undisposed textures, listeners left on a global emitter, pooled objects never released).\n- Engine counters: `renderer.info` (three.js), Babylon Inspector statistics, PixiJS devtools, Phaser's debug FPS.\n- In code: `performance.mark`\u002F`performance.measure` around a system to get numbers into a test or log.\n- Never take frame-rate numbers from headless Chromium — it renders WebGL in software. Report numbers from a real browser profile, or say you could not.\n\n## Bundle and assets\n\n- Read the build output: `npm run build` lists chunk sizes; add `rollup-plugin-visualizer` only if the repository already has it.\n- Keep the engine and the first scene in the initial chunk; split later levels with dynamic `import()`.\n- Textures: atlases and compressed formats (KTX2 for 3D, WebP\u002FAVIF for 2D); audio: compressed (OGG\u002FOpus plus an AAC\u002FM4A fallback where Safari needs it).\n- Respect the repository's size budget; without one, report the initial JS gzip size and the first-scene asset weight in the closing message when you changed either.\n\n## Vitest for rules\n\n```ts\n\u002F\u002F src\u002Flogic\u002Frng.ts\nexport function mulberry32(seed: number) {\n  return () => { seed |= 0; seed = (seed + 0x6d2b79f5) | 0; let t = Math.imul(seed ^ (seed >>> 15), 1 | seed);\n    t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t; return ((t ^ (t >>> 14)) >>> 0) \u002F 4294967296; };\n}\n```\n\n```ts\n\u002F\u002F src\u002Flogic\u002Fspawner.test.ts\nimport { describe, it, expect } from \"vitest\";\nimport { Spawner } from \".\u002Fspawner\";\nimport { mulberry32 } from \".\u002Frng\";\n\ndescribe(\"Spawner\", () => {\n  it(\"spawns one wave every 5 seconds regardless of step size\", () => {\n    const a = new Spawner({ waveEverySeconds: 5 }, mulberry32(1));\n    const b = new Spawner({ waveEverySeconds: 5 }, mulberry32(1));\n    for (let i = 0; i \u003C 600; i++) a.step(1 \u002F 60);\n    for (let i = 0; i \u003C 300; i++) b.step(1 \u002F 30);\n    expect(a.wavesSpawned).toBe(2);\n    expect(b.wavesSpawned).toBe(2);\n  });\n\n  it(\"is deterministic for a seed\", () => {\n    const run = () => { const s = new Spawner({ waveEverySeconds: 1 }, mulberry32(42)); for (let i = 0; i \u003C 180; i++) s.step(1 \u002F 60); return s.positions(); };\n    expect(run()).toEqual(run());\n  });\n});\n```\n\n- Rules never import the engine, so tests run in Node without a canvas. Don't mock Phaser or three.js to test a scene — move the rule out.\n- Time is a parameter; where a module genuinely uses timers, `vi.useFakeTimers()` and `vi.advanceTimersByTime(ms)`.\n- Babylon scene logic can run under `NullEngine` in Vitest.\n\n## Playwright smoke test (seeded)\n\n```ts\n\u002F\u002F e2e\u002Fsmoke.spec.ts\nimport { test, expect } from \"@playwright\u002Ftest\";\n\ntest(\"boots, takes input, no console errors\", async ({ page }) => {\n  const errors: string[] = [];\n  page.on(\"pageerror\", (e) => errors.push(e.message));\n  page.on(\"console\", (m) => { if (m.type() === \"error\") errors.push(m.text()); });\n\n  await page.goto(\"\u002F?seed=42&scene=Level1&debug=1\");\n  await expect(page.locator(\"canvas\")).toBeVisible();\n  await expect.poll(() => page.evaluate(() => (window as any).__GAME__?.ready)).toBe(true);\n\n  await page.keyboard.press(\"Space\");\n  await expect.poll(() => page.evaluate(() => (window as any).__GAME__?.player.jumps)).toBe(1);\n\n  await page.screenshot({ path: \"test-results\u002Flevel1-after-jump.png\" });\n  expect(errors).toEqual([]);\n});\n```\n\n- A `window.__GAME__` read-only debug handle exposed only in debug\u002Fdev builds lets tests assert state instead of guessing from pixels.\n- Fixed seed and a direct scene parameter make runs reproducible. Pixel comparisons (`toHaveScreenshot`) only with the loop paused on a deterministic frame and a tolerance; GPU differences make exact matches flaky.\n- Run it the way the repository does (`npx playwright test`); if Playwright is not set up and not installed, use the browser tools and say what the smoke run would have covered (game-visual-self-review).\n\n## Common Mistakes\n\n- `setInterval` loops; unclamped delta after a background tab.\n- Temporaries allocated per frame in vector math.\n- Unit tests importing the engine and failing for lack of WebGL.\n- Smoke tests without a seed, flaking on random spawns.\n- Judging performance from a headless browser.\n\n## Red Flags\n\n- `new` inside the rAF callback or a system's `update`.\n- A Playwright test with no `pageerror` listener.\n- A bundle that grew by hundreds of KB for a small feature, unmentioned in the closing message.\n",{"name":5,"source":24,"category":25,"tech_stack":26,"description":7},"informed by the MDN, Chrome DevTools, Vite, Vitest and Playwright documentation; own wording","performance","Web 2D","main","910394a0b6db9fc8c9a8f36328ec421d3ebd8b38","catalog\u002Fagents\u002Fgame-developer\u002Fskills\u002Fweb-game-performance-and-testing",18,"https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper","https:\u002F\u002Ftasktrooper.ai","https:\u002F\u002Fgithub.com\u002Fmakifbaysal","Senior Software Developer","2026-11-15 04:50:29",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add makifbaysal\u002Ftasktrooper --skill web-game-performance-and-testing",{"tool":42,"command":43},"bunx","bunx skills add makifbaysal\u002Ftasktrooper --skill web-game-performance-and-testing",{"tool":45,"command":46},"pnpm","pnpm dlx skills add makifbaysal\u002Ftasktrooper --skill web-game-performance-and-testing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fgame-developer\u002Fskills\u002Fweb-game-performance-and-testing\u002FSKILL.md",true,[],[51,57,64,71,78,85],{"skillNo":52,"name":53,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":19},"01M7CSVEPQW6J6TD6CS2T5FPNZ","visual-craft","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fvisual-craft\u002FSKILL.md",[],[],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M7CSVAQG91ETHQ0HBNZDG5FR","ux-copy","Use when you write any words a user reads in a mockup or a hand-off - content language and voice, buttons, labels, errors, empty states, confirmations, numbers and dates, and the longest-string check","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fux-copy\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M7CSV6H0J38659NDXHJQ8396","screen-mockup-html","Use when you draw screens as the design task's HTML mockup - ONE canvas document holding every screen and every variant side by side, the sanitizer-safe recipe, phone and wide frames, the states grid, static control states, and the loopback self-check with screenshots at 375, 768 and 1440 attached to the task","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fscreen-mockup-html\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M7CSV3JFRF3BM3XK52M7YEYR","performance-awareness","How the performance score moves for your role. Use when the score context shows a declining trend, or before handing off work you have not self-checked against every criterion.","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fperformance-awareness\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M7CSTZDH00YRF5SCT7BRT9QD","design-variants","Use when a screen design needs variants - how many, variants as side-by-side rows on the one canvas, what makes two variants genuinely different, recommending one, how the human's choice is read, and narrowing to the chosen one in revision","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fdesign-variants\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M7CSTV6P3SM3PAE28DB0RF77","design-system-authoring","Use when you derive, change or extend a design system - where tokens live per stack, the DTCG token tree, role-based names for both themes, base vs layer vs drift, the DESIGN.md section order, the inventory format, the contrast check and the lint every proposal returns","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fdesign-system-authoring\u002FSKILL.md",[],[]]