phaserjs / phaser

Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
https://phaser.io
MIT License
37.12k stars 7.1k forks source link

Noticable performance regression in 3.85.x and above #6919

Closed jamaalsawyerd closed 3 weeks ago

jamaalsawyerd commented 3 weeks ago

Version

Description

I've noticed a performance regression in the newest versions of Phaser that is still there in 3.86.0

I've recorded a 60 fps video of my project with the latest 3.86.0 and the 3.80.1 version I've kept my project on. You'll see that 3.86.0 is noticeably slower, choppier, and the camera adjustment as the character moves seems to be rounding values or something and looks stepped.

I am using scale type RESIZE and pixelArt = true in my general config, if that helps.

Example Test Code

I don't have a sandbox demonstration of the issue because it would involve an elaborate recreation of my current project since I don't know what is causing the slowdown and it affects the entire thing. En lieu of that, please look at my comparison video (particularly the parts where the camera is scrolling):

Additional Information

See the video at this link (couldn't directly attach it because it is over 10mb) https://ftbstudio.net/3_86_0_vs_3_80_1.mp4

photonstorm commented 3 weeks ago

Do you use the Camera startFollow() command in your game? If so, does it pass true for the roundPixels parameter? If not, set it to do so (otherwise it disables it, which you need as part of the pixel art setting)

jamaalsawyerd commented 3 weeks ago

I do use startFollow() and roundPixels is set to true.

image
photonstorm commented 3 weeks ago

I can't see any FPS meter in the video - what does the Chrome Dev Tools rendering monitor look like between the two of them?

jamaalsawyerd commented 3 weeks ago

I'll get that to you in a bit.

jamaalsawyerd commented 3 weeks ago

@photonstorm I may have figured it out and in a way it's actually that a bug was fixed, maybe?

Let me explain my reasoning. I think as the project progressed and certain camera functionality was added for dynamic responsive zooming, I actually want the roundPixels flag set to false now.

Reading the notes on the startFollow function: If you find you're getting a slight "jitter" effect when following an object it's probably to do with sub-pixel rendering of the targets position. This can be rounded by setting the roundPixels argument to true to force full pixel rounding rendering. Note that this can still be broken if you have specified a non-integer zoom value on the camera. So be sure to keep the camera zoom to integers.

I'm very sure my camera zoom is rarely if ever an integer value. So, in my "stable" 3.80.1 with roundPixels set to true, I think it isn't rounding it, as the description is saying. But in the newer builds like 3.85+ it is now enforcing the camera movement rounding, which explains the choppier movement and performance degradation, I believe.

When I turn roundPixels to false on startFollow() in both versions it behaves and performs at 60 fps with the expected behavior. If this explanation is plausible, I believe this ticket should be closed?

My bad if I wasted people's time.