HaxeFlixel / flixel

Free, cross-platform 2D game engine powered by Haxe and OpenFL
https://haxeflixel.com/
MIT License
1.92k stars 427 forks source link

Innaccurate fps to FlxG.stage.frameRate #3150

Open helpmeiguess opened 1 month ago

helpmeiguess commented 1 month ago

Take a basic project. Make an openfl.display.FPS and add it in main. In your Starting state, set FlxG.stage.frameRate to your monitors current hz. In your project.xml, make sure vsync="true" for your target. Compile. The FPS display will be accurate to your actual hz, sometimes with a difference of around 1 or 2. In project.xml, change vsync to false. Compile. The FPS display will be inaccurate.

144 stage.frameRate displays ~168, 60 does 64. Test with whatever numbers you'd like. if you're skeptical, try 90 fps and then try 91. The display from 92 to 102. That's definitely not right.


Observed behavior: Setting fps with vsync results in drastically different frame times than with FlxG.drawFrameRate or FlxG.stage.frameRate

144 hz vsync: image

frameRate set to 144, no vsync: image Expected behavior: Fps values maintain consistent and predictable using vsync or in game frameRate.

I don't know how this went unnoticed so long.

Rudyrue commented 1 month ago

this is an openfl/lime problem flixel can't really do anything about it

DetectiveBaldi commented 1 month ago

this is an openfl/lime problem flixel can't really do anything about it

^ This issue can also be produced on a standard openfl create template.

image

Main.hx:

package;

import openfl.display.Sprite;

class Main extends Sprite
{
    public function new()
    {
        super();

        addChild(new openfl.display.FPS());

        stage.frameRate = 144;
    }
}
Geokureli commented 1 month ago

Someone wanna raise this up to openfl/lime?

Plz link this issue in there so it connects

helpmeiguess commented 1 month ago

https://github.com/openfl/openfl/issues/2710#issue-2328867866