Per-frame redraw and allocation hot spots (Siege, Maze, sfx noise, pad lookup, Runner HUD, popups, hub loop)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 30/100
- Issue 类型
- 重构
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- typescript, vite
- 领域
- game-dev, performance
调研方向
This is a bundle of seven separate performance items, so pick one and leave the rest. A good starting point is the Siege shield redraw in games/siege/scenes/GameScene.ts near lines 572-577, using the Maze wall drawing in games/maze/scenes/GameScene.ts (drawWalls) as the pattern. Done means that item is fixed or declined with a before-and-after Performance trace, and the other items are tracked separately.
由索引模型根据 Issue 内容生成。
描述
Summary
A handful of avoidable per-frame costs outside the ones #35 and #37 already track. None is serious alone, but together they add main-thread work and garbage on low-end phones at 60 to 120 Hz. All costs below are estimates from reading the code; nothing was profiled.
Where and what
- Siege shields and Maze dots redrawn every frame.
games/siege/scenes/GameScene.ts:572-577clearsgfxand replays every shield cell as its ownfillRect(about 536 rects across 4 shields).games/maze/scenes/GameScene.ts:516-537does the same for every remaining dot (about 200fillStyle+fillRectpairs). Both only change on a hit or a dot eaten. Fix: draw them into their own Graphics (Maze already does this for walls indrawWalls) and redraw only when they change. -
noise()builds a new random AudioBuffer for every sound.shared/sfx.ts:52-66allocates and fills a buffer withMath.random()on each call. Astro calls it every 90 ms while thrusting (games/astro/scenes/GameScene.ts:246-249) and per rock; Runner every 90 ms while sliding (games/runner/scenes/GameScene.ts:284). That is roughly 170 KB/s of garbage while thrusting. Fix: create one 1 s noise buffer once and play slices withsrc.start(t, offset, duration). - Hub gamepad loop runs forever.
src/hub/navigation.ts:227-238reschedulesrequestAnimationFrame(poll)unconditionally, even with no gamepad, so the hub never goes idle (battery cost on phones). Fix: start ongamepadconnected(or at load if a pad is already connected) and stop once none remain, assrc/hub/pad-bindings.ts:83-101already does. -
ArcadeControls.padrebuilds and sorts the pad list 10 to 20 times a frame.shared/controls.ts:123-131runsgp.getAll().filter(...).sort(...)on every read, andrefresh()and the axis helpers read it repeatedly (shared/controls.ts:185-192,:205-208,:214-235). Fix: resolve the pad once at the top ofrefresh()and reuse it. - Runner re-renders its distance text almost every frame.
games/runner/scenes/GameScene.ts:523-532callsdistText.setTextfromupdate(), and at 380 to 920 px/s with 12 px per metre the value changes 32 to 77 times a second, each a canvas redraw and texture upload. Fix: use a BitmapText, or update at most every 100 ms. (Related: #36.) - Score popups create and destroy a blurred Text each time.
shared/ui.ts:34-47(floatText) makes a new Text with a 12 px shadow blur per popup; Breakout calls it per brick (games/breakout/scenes/GameScene.ts:329) and Astro per rock (games/astro/scenes/GameScene.ts:464), so multiball moments create several at once. Fix: pool a few popup Texts per scene, or use a BitmapText font. - Also worth adding to #35: Runner draws drones and the runner with
fillRoundedRect/strokeRoundedRectevery frame (games/runner/scenes/GameScene.ts:464-466,:505-507,:516-519).
Impact
Frame-time jitter and extra garbage collection on low-end mobile at the busiest moments, and an idle hub that keeps waking the CPU.
Acceptance criteria
- Each item fixed or explicitly declined, with a before/after Performance trace for the Siege/Maze and hub items.
Getting started
- Relevant files: listed above
- How to run tests:
npm test; profile with the browser's Performance panel onnpm run dev - Related: #35, #36, #37
Filed by repo-audit/full-audit at de2b25b. Severity: low. Effort: M. audit-key: performance|games/siege/scenes/GameScene.ts|render
- 主要语言
- TypeScript
- 星标
- 3
- 派生
- 3
- 平均合并
- 10 小时 22 分钟
- 30 天内合并 PR
- 6
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TMHSDigital/GH-Arcade 的其他 Issue
-
good first issue performance severity: low
难度 3/5 1-2 天 新手友好度 72/100
TMHSDigital/GH-Arcade#141 ·
维护者通常 1 天内回复
-
enhancement help wanted severity: low
难度 4/5 3-5 天 新手友好度 55/100
TMHSDigital/GH-Arcade#139 ·
维护者通常 1 天内回复
-
enhancement help wanted severity: medium
难度 4/5 3-5 天 新手友好度 56/100
TMHSDigital/GH-Arcade#127 ·
维护者通常 1 天内回复
-
enhancement help wanted severity: medium
难度 4/5 3-5 天 新手友好度 48/100
TMHSDigital/GH-Arcade#126 · 1 条评论 ·
维护者通常 1 天内回复
-
accessibility enhancement severity: low
难度 4/5 3-5 天 新手友好度 40/100
TMHSDigital/GH-Arcade#114 ·
维护者通常 1 天内回复
查看 TMHSDigital/GH-Arcade 的全部 Issue
相似的 Issue
-
[MCP]: page snapshots in .playwright-mcp/ are not git-ignored (.playwright-cli/ is, since #42318)未关闭
难度 2/5 1-3 小时 新手友好度 62/100
microsoft/playwright#44289 ·
维护者通常 1 天内回复
-
good first issue
难度 2/5 半天 新手友好度 65/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
blamechris/chroxy#9272 ·
维护者通常 1 天内回复
-
no-repo-link tool-submission
难度 1/5 1 小时以内 新手友好度 66/100
BraveOPotato/NoSignups#2458 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
drmrd/vernacular#1061 ·
维护者通常 1 天内回复