Performance Bottleneck with Group.get() Method in Phaser
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- javascript
- 領域
- game-dev, performance
調査の方向性
まず、大きなグループを使って main.js にある Group.get() の繰り返し呼び出しを再現し、次に Phaser の Group.get() 実装を調べ、SeedItem.js の SeedItem セットアップとタイミングを比較します。コストがオブジェクトプーリングにあるのか構築にあるのかを判断し、期待されるプール済みオブジェクトの動作を維持した、性能向上が実証されることを完了の条件とします。
索引モデルが issue の本文から書いたものです。
説明
Problem Description
I'm experiencing significant performance issues with the Group.get() method in Phaser. The method takes an unusually long time to execute, especially when the group contains a large number of objects. This significantly impacts the performance of my application.
Code Snippets
main.js (Relevant Part)
const seedItems = scene.add.group({
classType: SeedItem,
maxSize: -1,
runChildUpdate: false
});
this.fillItems = (itemClass, itemDataList, cols = 6, itemWidth = 181, itemHeight = 201) => {
const panel = scrollList.getElement('panel');
const line = Math.ceil(itemDataList.length / cols);
itemDataList.forEach((data, index) => {
const row = Math.floor(index / cols);
const col = index % cols;
const x = col * (itemWidth + 20) + 160;
const y = row * (itemHeight + 30) + 110;
let start = performance.now();
const seedItem = seedItems.get();
console.log("cost", performance.now() - start);
if (seedItem) {
seedItem.updateData(x, y, data);
seedItem.setActive(true);
seedItem.setVisible(true);
panel.add(seedItem);
}
});
panel.setSize(GameConfig.Screen.width, (itemHeight + 30) * line + 30);
scrollList.layout();
};
SeedItem.js (Simplified and Sanitized)
export default class SeedItem extends Phaser.GameObjects.Container {
constructor(scene, x, y, children) {
super(scene, x, y, children);
// UI elements initialization
this.bg = scene.add.image(0, 0, "item_atlas", "item_bg.png").setInteractive({ useHandCursor: true });
this.icon = scene.add.image(0, 0, "common_atlas", "icon_seed_default.png");
this.levelText = scene.add.text(-70, -95, "", { fontFamily: "Arial", fontSize: "24px", fill: "#ffffff" });
this.countText = scene.add.text(45, 35, "", { fontFamily: "Arial", fontSize: "24px", fill: "#385bb6" });
this.nameText = scene.add.text(0, 85, "", { fontFamily: "Arial", fontSize: "22px", fill: "#fffffb" }).setOrigin(0.5, 0.5);
this.notBuyBg = scene.add.image(0, 0, "item_atlas", "item_not_available.png").setVisible(false);
// Event listeners
this.bg
.on("pointerdown", (pointer) => { /* ... */ })
.on("pointermove", (pointer) => { /* ... */ })
.on("pointerup", (pointer) => { /* ... */ });
}
updateData(x, y, data) {
this.setPosition(x, y);
const { level, count, name, type } = data;
this.levelText.setText(`Lv.${level}`);
this.countText.setText(count);
this.nameText.setText(name);
}
}
Steps to Reproduce
- Create a group with
maxSize: -1. - Repeatedly call
group.get()in a loop (e.g., for populating a grid). - Observe the execution time of each
get()call.
Expected Behavior
The get() method should return a pooled object quickly, even for large groups.
Possible Workarounds
- Pre-warm the pool by pre-creating objects.
- Limit the group size if possible.
Could you investigate this issue or suggest optimizations? Thanks!
- 主要言語
- JavaScript
- スター
- 40.7k
- フォーク
- 7.2k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
phaserjs/phaser のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
メンテナーはふだん 3 日以内に返信
-
Type definition for TilemapLayer.getTileAt is wrong対応中かも @hkbughk が 34 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 3 日以内に返信
-
Shader.preDestroy leaks its ShaderQuad's vertex buffer and VAO on every create/destroy cycle (4.2.1)対応中かも @k1epg01ng129-eng が 32 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 3 日以内に返信
-
Black opaque background on transparent Phaser.Text textures in Phaser 4.2.1 on older iOS WebGL対応中かも @SamuelMalmfors が 14 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
phaserjs/phaser#7392 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
phaserjs/phaser の issue をすべて見る
似ている issue
-
enhancement ready
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
DCGM/semant-demo#708 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
agents area: runtime automation chore cli consistency dependencies developer-experience difficulty: easy documentation enhancement good first issue help wanted hygiene json-output priority: P3 starters tests
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
Client codegen: an import repeated in an impl file is emitted twice, and the browser rejects the module対応中かも @MalithaPrabhashana が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
jaseci-labs/jac#10756 ·
メンテナーはふだん 1 日以内に返信