Per-frame redraw and allocation hot spots (Siege, Maze, sfx noise, pad lookup, Runner HUD, popups, hub loop)

オープン
#107 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
30/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
活発
技術スタック
typescript, vite

調査の方向性

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 の本文から書いたものです。

説明

help wanted performance severity: low

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-577 clears gfx and replays every shield cell as its own fillRect (about 536 rects across 4 shields). games/maze/scenes/GameScene.ts:516-537 does the same for every remaining dot (about 200 fillStyle + fillRect pairs). Both only change on a hit or a dot eaten. Fix: draw them into their own Graphics (Maze already does this for walls in drawWalls) and redraw only when they change.
  • noise() builds a new random AudioBuffer for every sound. shared/sfx.ts:52-66 allocates and fills a buffer with Math.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 with src.start(t, offset, duration).
  • Hub gamepad loop runs forever. src/hub/navigation.ts:227-238 reschedules requestAnimationFrame(poll) unconditionally, even with no gamepad, so the hub never goes idle (battery cost on phones). Fix: start on gamepadconnected (or at load if a pad is already connected) and stop once none remain, as src/hub/pad-bindings.ts:83-101 already does.
  • ArcadeControls.pad rebuilds and sorts the pad list 10 to 20 times a frame. shared/controls.ts:123-131 runs gp.getAll().filter(...).sort(...) on every read, and refresh() and the axis helpers read it repeatedly (shared/controls.ts:185-192, :205-208, :214-235). Fix: resolve the pad once at the top of refresh() and reuse it.
  • Runner re-renders its distance text almost every frame. games/runner/scenes/GameScene.ts:523-532 calls distText.setText from update(), 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 / strokeRoundedRect every 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 on npm 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分
マージ済み PR(30日)
6

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TMHSDigital/GH-Arcade のほかの issue

TMHSDigital/GH-Arcade の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。