Performance Bottleneck with Group.get() Method in Phaser
Maintainer thường phản hồi trong vòng 3 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript
- Lĩnh vực
- game-dev, performance
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện các lệnh gọi lặp lại tới Group.get() từ main.js với một group lớn, sau đó kiểm tra phần triển khai Group.get() của Phaser và so sánh thời gian với phần thiết lập SeedItem trong SeedItem.js. Xác định xem chi phí nằm ở object pooling hay ở việc khởi tạo, và xác định việc hoàn thành là một cải thiện hiệu năng được chứng minh mà vẫn duy trì hành vi dự kiến của các đối tượng trong pool.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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!
- Ngôn ngữ chính
- JavaScript
- Star
- 40.7k
- Fork
- 7.2k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của phaserjs/phaser
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Type definition for TilemapLayer.getTileAt is wrongCó thể đã có người làm @hkbughk đã nhận 34 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Shader.preDestroy leaks its ShaderQuad's vertex buffer and VAO on every create/destroy cycle (4.2.1)Có thể đã có người làm @k1epg01ng129-eng đã nhận 32 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Black opaque background on transparent Phaser.Text textures in Phaser 4.2.1 on older iOS WebGLCó thể đã có người làm @SamuelMalmfors đã nhận 14 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
phaserjs/phaser#7392 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của phaserjs/phaser
Issue tương tự
-
enhancement ready
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
DCGM/semant-demo#708 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 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
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Client codegen: an import repeated in an impl file is emitted twice, and the browser rejects the moduleCó thể đã có người làm @MalithaPrabhashana đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
jaseci-labs/jac#10756 ·
Maintainer thường phản hồi trong vòng 1 ngày