Reputation: 33
sorry for poor english. So, I have about 30fps in my mobile game made with android studio, using webview. The framework I use is phaser 3. I decided to make a simple test. I removed all the code and left, on pointer up event which is showing game.loop.actualfps. I have removed all sprites from loader too. Clicking on screen I have about 35fps which is weird with only 4 lines of code. When i put fps display in update function i had 20fps. I will add that on the computer there is almost constant 60fps.
If I replace the code to my old game made with phaser 2 i have 50-60fps. Is phaser 3 poorly optimized? Here is my boot.js file code:
let newWidth; let newHeight
function calculateDimensions(){
const targetWidth = 480;
const targetHeight =854;
const deviceRatio = (window.innerWidth/window.innerHeight);
const newRatio = (targetHeight/targetWidth)*deviceRatio;
newWidth = targetWidth;
newHeight = targetHeight*newRatio;
}
calculateDimensions();
const gameWidth = newWidth; const gameHeight = newHeight;
const config = {
type: Phaser.AUTO,
width:gameWidth,
heigth: gameHeight,
scale: {
mode:Phaser.Scale.ENVELOP,
autoCenter: Phaser.Scale.CENTER_BOTH
},
physics: {
default: 'arcade',
arcade: {
tileBias:8,
debug:false,
gravity: false
},
render: {
pixelArt: true
}
},
scene: [
preloader,loader,menu,
levelSelect,levelAlert,
shop,
winMenu,loseMenu,
level
]
};
window.onload = () => {
game = new Phaser.Game(config);
}
I tried changing the type from auto to canvas and webgl. Nothing helped. I know these global variables are bad, but that's not the point now :D. What else can I check and what could be the reason for these lags? please help.
Upvotes: 3
Views: 4079
Reputation: 141
I'm probably a bit late, but if you're reading this, try adding "powerPreference":"high-performance" into the game config.
TLDR:
new Phaser.Game({powerPreference:"high-performance",...})
It gives a fair performance boost, at least in Google Chrome.
Upvotes: 2
Reputation: 31
Webview is really slow on some devices. Try to disable physics (and replace it with your custom code if that helps).
From my experience moving to cordova and using webgl really helps a lot. Some devices will start to work as expected if you add isGame:true to the app config.
The really last step you could try is moving webview to custom one (for cordova that would be xwalk or crosswalk plugin), that will significantly increase the size of application (~60Mb) but forces it to work as expected on much wider list of devices.
Upvotes: 3