High CPU usage when game is iddle

Hello, I’m evaluating Phaser to build a simple puzzle game. I’ve found that CPU usage is very high (~100% of 1 core) even though there’s no changes in the game.

It’s like Phaser is rendering the game even though there’s no movement. Yo can see the effect with this example: https://phaser.io/examples/v2/games/sliding-puzzle

I’ve seen a Phaser 2 plugin for optimizing CPU that allows to render the game only when there are changes, but I can’t find anything similar for Phaser 3. I’m sure that there is some option somewhere to optimize that, but don’t know where.

Do you know if there is a way to optimize rendering for puzzle games?

You will have to post some of your code if you want the community to be able to help. Also, the example you linked is from Phaser 2, and runs fine on my computer (although I may be misunderstanding you.) Post your code in code tags which

// looks like this: 
```code here!```

Thanks, UltimateProGrammer. That was a wrong link, this is the correct one:
http://labs.phaser.io/view.html?v=3.22.0&src=src\input\dragging\stack%20of%20cards.js

It works fine but CPU usage spikes when I run the example, even when there is no movement. If I run it fullscreen, CPU usage increases even more.

I’ve tested it on Firefox 74.0 and Chromium 80.0.3987.87, both on Linux 64.

I’ve downloaded the example and launched it from localhost to check that the problem was not with the examples’ page. It has the same behaviour. I changed the example to run with only one card and it has the same CPU usage.

It’s like some kind of rendering loop is running despite there is no need to do it.

On my old mac it doesn’t spike. I only see CPU usage go up when dragging. Sorry I couldn’t be of help. Maybe try submitting a bug report?

Phaser always renders each frame.

I made this for you.

4 Likes

Thanks a lot, samme. I tried to adapt SaveCPU plugin from version 2 but I was unable to do so. I may make another attempt now that I have your plugin as an example. If I could have some time to be at home…

This was the CPU usage I had before using the plugin:

This is the new CPU usage. It only consumes CPU when mouse is down:

Much better performance. It’s only a 20% increase but from eight cores.

1 Like

1 Like

I made an account just to say thanks for this! I’m making a puzzle game too and it was idling at 50-60% of one core, now that’s down to 10% :tada:

2 Likes