godotjs / godotjs/javascript

Collision Result GC Leading to Engine Crash in GodotJS

Đang mở
#216 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C++
Star
1.1k
Fork
80
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### Version

4.1-v0.0.20-20240906

### System information

Windows11

### Issue description

```ts
export default class TestScript extends godot.PhysicsBody2D {
collink: any;

_ready() {
this.set_physics_process(true); // Enable physics processing
}

_physics_process(delta: number): void {
let velocity = new godot.Vector2();
if (godot.Input.is_action_pressed("up")) velocity.y -= 1;
if (godot.Input.is_action_pressed("down")) velocity.y += 1;
if (godot.Input.is_action_pressed("left")) velocity.x -= 1;
if (godot.Input.is_action_pressed("right")) velocity.x += 1;

// Normalize velocity vector and scale by speed and delta time
if (velocity.length() > 0) {
velocity.x *= 5;
velocity.y *= 5;

// Update position and handle collisions
// Without storing the collision result, the object is garbage collected (GC)
// which leads to game crashes on subsequent collision checks
const res = this.move_and_collide(velocity, false, 0.08, true);
if (res) this.collink = res; // Store collision result to prevent GC
console.log('res', res);
}
}
}

```

### Steps to reproduce

Just testing the above code

### Minimal reproduction project (MRP)

[game.zip](https://github.com/user-attachments/files/17529435/game.zip)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Start with the attached game.zip reproduction and run the TypeScript script around PhysicsBody2D.move_and_collide. Trace the GodotJS binding and collision-result lifetime, then repeatedly exercise the collision path without manually retaining res. Done means the reproduction no longer crashes during subsequent collision checks.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
cpp, typescript
Lĩnh vực
game-dev
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
38/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.