Stack, Snake and Hop re-tessellate rounded rectangles every frame

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript

調査の方向性

Start by reading the drawing code in games/stack/scenes/GameScene.ts, games/snake/scenes/GameScene.ts, and games/hop/scenes/GameScene.ts, then compare it with the sparkTexture example in shared/ui.ts. Run npm run dev and use a Performance trace to check how frame time changes as the Stack board fills or the Snake grows. The issue is done when drawing cost no longer measurably grows with board fill or snake length and the visuals remain unchanged; run npm run typecheck and npm run build.

索引モデルが issue の本文から書いたものです。

説明

help wanted performance severity: medium

Summary

Three games clear a Graphics object and redraw every cell or segment with fillRoundedRect each frame. Phaser's WebGL Graphics renderer tessellates each arc with a fixed step and does not cache geometry, so cost grows with board fill and snake length.

Where

  • games/stack/scenes/GameScene.ts:458-497, games/stack/scenes/GameScene.ts:500-512 (three rounded rects per cell)
  • games/snake/scenes/GameScene.ts:437-452, games/snake/scenes/GameScene.ts:404-412 (two per segment plus three colour objects)
  • games/hop/scenes/GameScene.ts:396-435

Details

Estimated from the Phaser 3.90 source, not measured in a browser:

  • A rounded rect is about 400 points and 400 triangles.
  • Stack with about 100 visible cells: about 300 paths and 120,000 point allocations per frame.
  • Snake at length 50: about 40,000 allocations and triangles per frame.

Impact

Likely GC pauses and dropped frames on phones and low-end laptops, worst when the Stack board is full or the snake is long, which is when timing matters most.

Steps to reproduce

  1. Play Stack until the board is half full, or Snake to length 50.
  2. Record a Performance trace and compare scripting time and minor GC frequency with the start of the run.

Suggested fix

Pre-render one white cell texture with generateTexture (as sparkTexture in shared/ui.ts already does) and draw cells as pooled tinted Images, or stamp into a RenderTexture updated only when the board changes. Cache Snake's gradient colours per length. A cheaper stopgap is fillRect for the glow and highlight layers.

Acceptance criteria

  • Frame time in Stack and Snake does not grow measurably with board fill or snake length
  • Visuals are unchanged

Getting started

  • Relevant files: games/stack/scenes/GameScene.ts, games/snake/scenes/GameScene.ts, games/hop/scenes/GameScene.ts, shared/ui.ts
  • Run locally: npm install, then npm run dev
  • Checks: npm run typecheck and npm run build (there is no test suite yet)
  • Related docs: README.md

Filed by repo-audit/full-audit at b001f5d. Severity: medium. Effort: M. audit-key: performance|games/stack/scenes/GameScene.ts|drawCell

主要言語
TypeScript
スター
3
フォーク
3
PR マージ指標
30日以内にマージされた PR はありません

環境構築

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

はじめの一歩

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

TMHSDigital/GH-Arcade のほかの issue

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

似ている issue

TypeScript の issue をもっと見る

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

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