Jump to content

UWP Hosted Apps / Edge Stuttering


8bitdna
 Share

Recommended Posts

Hi All,

Any game I run in Edge or UWP hosted apps has a horrible frame drop every few seconds.  This is specifically when using the Panda 2 Gamepad plugin and looks like its down the button state management in the plugin and Edge probably requesting button state each time and it being slow.  This code...

                for (var i = 0; i < gamepad.buttons.length; i++) {
                    if (gamepad.buttons[i].pressed && !pad.buttons[i].pressed) {
                        this.pressed(i, gamepad.index);
                    }
                    else if (!gamepad.buttons[i].pressed && pad.buttons[i].pressed) {
                        this.released(i, gamepad.index);
                    }
                    pad.buttons[i].pressed = gamepad.buttons[i].pressed;
                }

I've improved things a lot by taking a copy of the state and working with that like this by adjusting the plugin code like this...

                var clone = gamepad.buttons.slice(0);
                for (var i = 0; i < clone.length; i++) {
                    if (clone[i].pressed && !pad.buttons[i].pressed) {
                        this.pressed(i, gamepad.index);
                    }
                    else if (!clone[i].pressed && pad.buttons[i].pressed) {
                        this.released(i, gamepad.index);
                    }
                    pad.buttons[i].pressed = clone[i].pressed;
                }

I still see a little frame drop (not as bad) every few seconds though on Edge and UWP hosted apps.  This is running the Gamepad plugin example with no changes other then the above.  Tried a bunch of random HTML5 games on the interwebs and they all seem ok, any ideas?

Link to comment
Share on other sites

That's really strange. In your code change, you are creating new array each frame with the slice function, which should make everything even worse (since you are creating garbage). There must be something else that is slowing your game down.

Does this happen on desktop Edge too?

Link to comment
Share on other sites

Yep, new array every frame and yes happens on desktop Edge.  Try out your Gamepad Plugin example on Edge with an Xbox controller if possible, you should see the 'janking'.  Then change the code to what I did and you'll see it improve but then get little frame rate drops, that could be the garbage collection though from the new array etc.  I'm no JS expert, is there a way to create an array once and copy the contents of gamepad.buttons into it every frame so we don't create the garbage?  I think every time you look into the gamepad.buttons[x].pressed prop it triggers a request at the hardware for ALL buttons state with edge, so as you iterate around the loop its slow, thats the only explanation I could think of!  Shouldn't be like that though according to the official Gamepad HTML5 spec, looks more like an Edge bug.

Link to comment
Share on other sites

  • 2 weeks later...

Seems that way.  Take your Gamepad example and run in on the Xbox or Edge, you'll see the janking.  Then remove this code from you Gamepad plugin and try again, janking gone..

                for (var i = 0; i < gamepad.buttons.length; i++) {
                    if (gamepad.buttons[i].pressed && !pad.buttons[i].pressed) {
                        this.pressed(i, gamepad.index);
                    }
                    else if (!gamepad.buttons[i].pressed && pad.buttons[i].pressed) {
                        this.released(i, gamepad.index);
                    }
                    pad.buttons[i].pressed = gamepad.buttons[i].pressed;
                }

An looking at that code I can't believe it has a significant impact on performance hence why I was thinking Edge issue, see what I mean?  I'm not that much if a JS expert to profile it properly etc, maybe its something else but the Gamepad example hardly does anything (in terms of resource hungry things and a need for performance) so it seems a coincidence.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...