8bitdna Posted September 16, 2018 Share Posted September 16, 2018 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? Quote Link to comment Share on other sites More sharing options...
enpu Posted September 17, 2018 Share Posted September 17, 2018 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? Quote Link to comment Share on other sites More sharing options...
8bitdna Posted September 17, 2018 Author Share Posted September 17, 2018 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. Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted September 20, 2018 Share Posted September 20, 2018 @enpu Any idea what might be causing this? I'm interested at making a game to release on X-Box + Steam so it would be good to know if there is a fix for this Quote Link to comment Share on other sites More sharing options...
enpu Posted September 20, 2018 Share Posted September 20, 2018 I'm sure there is a fix for this. As @8bitdna said, it sounds like an Edge bug. Will take a look asap. Ninjadoodle 1 Quote Link to comment Share on other sites More sharing options...
enpu Posted September 30, 2018 Share Posted September 30, 2018 Just to confirm, the fps drop occurs only when using Gamepad plugin? Quote Link to comment Share on other sites More sharing options...
8bitdna Posted October 2, 2018 Author Share Posted October 2, 2018 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.