key press slows framerate (empty project) Flash target



  • This issues is with Flash target. Windows and Neko are fine. Others, I'm not sure ATM.

    In Player#update() when checking FlxG.keys.pressed (or anyPressed) the framerate drops, but while still holding the key down, if I press and release any other key, (whether being used in my game or not doesn't matter) the framerate goes back up.

    For example, for repeated shooting while holding the shoot key down it slows the framerate after a second or so, but by simply pressing and releasing some other key while I'm shooting it's fine again and I can hold it indefinitely without framerate dropping.

    It also affects my player movement and anything with keys that are being pressed. At first I thought it was "just how it is" being in update() and all, but since releasing some random key brings the framerate back up it must be something else.

    Any info or ideas to solve this would be great.



  • bumping this with minimal code and empty PlayState for a test subject to demonstrate.

    EDIT: I'm not even importing, or checking FlxG.keys.

    project.xml

    <?xml version="1.0" encoding="utf-8"?>
    <project>
        
        <app title="KeyPress Test" file="KeyPressTest" main="Main" />
        
        <window width="960" height="720" fps="60" background="#000000" hardware="true" vsync="true" />
        
        <set name="SWF_VERSION" value="11.8" />
        <set name="BUILD_DIR" value="export" />
        
        <classpath name="source" />
        
        <haxelib name="flixel" />
        
    </project>
    

    Main.hx

    package;
    
    import flixel.FlxGame;
    import openfl.display.Sprite;
    
    class Main extends Sprite
    {
        public function new()
        {
            super();
            
            addChild(new FlxGame(480, 360, PlayState));
        }	
    }
    

    PlayState.hx

    package;
    
    import flixel.FlxState;
    
    class PlayState extends FlxState
    {
    	// empty
    }
    
    • Make an empty project ^
    • Build target flash in debug mode.
    • Watch the framerate in debug.
    • Press and hold any key, the framerate drops. While still holding that key down, press and release any other key. The framerate goes back up.

    This is most noticeable when running my game fullscreen, but still happens to a lesser degree in smaller resolution. It makes my performance appear poor when it's not really. This seems to be a flash-only problem.



  • You should try using hxscout to profile your app to figure out where the perf issues are coming from: http://hxscout.com/



  • @gamedevsam237

    Thanks for the reply.

    I've tried using hxscout but can't get it to work. I get errors when trying to compile: C:/HaxeToolkit/haxe/lib/hxcpp/3,3,49/src/hx/Debug.cpp(373) : error C2664: '_beginthreadex' : cannot convert parameter 3 from 'DWORD (__stdcall *)(void *)' to 'unsigned int (__stdcall *)(void *)'

    I don't understand how to use this tool. It's supposed to be as easy as adding -Dtelemetry to the command line according to hxscout site. I also tried adding the project tags as shown in the HelloFlixel example.

    It says it only supports hxcpp. This issue I'm having is only with the flash build.

    my specs:

    flixel: [4.2.0]
    hxcpp: [3.3.49]
    hxtelemetry: [0.3.5]
    lime: [2.9.1]
    openfl: [3.6.1]
    

    This key press issue is present in a completely empty project. I'm just wondering how to overcome it, and if anyone else has this problem. Is it my PC? I'm using Windows 7. Maybe it's a HW issue? All I know is it runs great on Windows, Android, html5, neko. It would run great on flash except for this one problem. It makes my player stutter (framerate changes) when holding a key down to run, or any key for that matter. I can hold any arbitrary key down and framerate drops. BUT if I simply press and release ANY other key, while still holding that key down, it smooths out the framerate back to 60, and stays fine until I press and hold another.

    I would use html5 for my online version except that I have lots of emitters and that is a performance hit, although the key press issue is not a problem.

    I'm starting to think it's to do with my PC/HW since it seems that no one has noticed this before. I'd like to verify that but I only have the one computer to try it on.

    I still want to get hxscout working so I can optimize my apps. I'll give it a go again later. I got frustrated with it and need to move on to something else for now.



  • I'm almost sure this is a hardware/software problem with my computer. I haven't figured out why, but I don't think it's a HF issue. Sorry for the trouble.



  • yes, when not using a slow computer there is a noticeable drop in the frame rate when a key is held down.



  • So, this is also true for you, @galoyo ?

    Press and hold any key, the framerate drops. While still holding that key down, press and release any other key. The framerate goes back up.

    Does anyone else notice this? If so, how can it be overcome?



  • while holding the key, press then release any other key the framerate goes back up is true for me



  • Thanks for checking that @galoyo.


Log in to reply