I have this issue I am not able to solved for the longest time…
When I enter and exit a scene, no issues , but when I throw a knive in the room , my entire game freeze and I can’t even refresh the chrome browser, I had to close the tab completely…
Pls take a look at the video …
[https://www.youtube.com/watch?v=OUcWjIJzk1k](https://Game freeze and cpu 100% )
I have also cleared the knifeGroup and other clean up
From the console.log, I notice the freeze is after artGallery scene and before the world scene
type or paste code here
world(player, tile) {
this.startPerformanceMarker('world');
console.log("world function", player, this.knifeGroup.children.size);
this.position.x = this.entryPositionX;
this.position.y = this.entryPositionY;
this.position.dir = "down";
let socket = this.player.socket.id;
let room = this.scene.key;
// Cleanup
console.log("world cleanup")
// Clean up resources
this.knifeGroup.clear(true, true);
EventBus.removeAllListeners("walletData");
PubSub.unsubscribe(TOPIC.TOKEN);
console.log("world start scene")
this.scene.start("world", {
playerPos: this.position,
character: this.character,
socket: socket,
room: room,
});
console.log("world stop artGallery")
// Remove this scene after starting the new one
this.scene.stop("artGallery");
this.endPerformanceMarker('world');
}
Got this error when the game freeze with 0& CPU
artGallery.js:288 Potential infinite loop detected in artGallery update
window.console.error @ app-index.js:35
overrideMethod @ console.js:288
update @ artGallery.js:288
step @ phaser.js:151589
update @ phaser.js:149418
step @ phaser.js:13081
step @ phaser.js:13856
step @ phaser.js:23962
requestAnimationFrame
step @ phaser.js:23964
requestAnimationFrame
step @ phaser.js:23964
requestAnimationFrame
step @ phaser.js:23964
requestAnimationFrame
step @ phaser.js:23964
requestAnimationFrame
step @ phaser.js:23964
requestAnimationFrame
step @ phaser.js:23964
requestAnimationFrame
step @ phaser.js:23964
requestAnimationFrame
step @ phaser.js:23964
requestAnimationFrame
step @ phaser.js:23964
requestAnimationFrame
step @ phaser.js:23964
requestAnimationFrame
step @ phaser.js:23964
requestAnimationFrame
step @ phaser.js:23964
requestAnimationFrame
step @ phaser.js:23964
requestAnimationFrame
step @ phaser.js:23964
requestAnimationFrame
step @ phaser.js:23964
requestAnimationFrame
step @ phaser.js:23964
requestAnimationFrame
step @ phaser.js:23964
requestAnimationFrame
step @ phaser.js:23964
Would it be possible to share more of the code? From the error that was shared and the existing code, there is not enough information to help debug.
One thing to look at would be the logic tied to your event listeners and code cleanup that is happening there. In the video, after you enter the building a second time, it looks like there are two listeners for the player, vs the first time you entered the building there was only one. In the video, you can see the logs firing an extra time and an extra character and animations are playing.
Besides that, I would need more info to try and help.