Weird lags

Hi, i had about 30fps in my mobile game made with android studio using webview. It is made with 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 impossible. When i put showing fps in update function i had 20fps. So i put my first game code made with phaser 2 and i have 60fps. What can cause that?

Please help. I have tried everything. Removed all the code and still 40 fps with pure phaser

Hello ptaku19

As a test, can you run the game on a web browser

When you reach 40 fps or less, can you click outside the window (for exemple your Windows menu) .
At this moment does the FPS increase or not ?
If yes, when you get back the focus on your canvas, does the FPS decrease again ?

On a web browser i have constant 60 fps with canvas and webgl. I removed Phaser mask and my fps grown when using WEBGl. Using canvas made no diffrence.

in mobile
type should be canvas, not auto or webgl
because webgl need higher cpu resource

in mine case webgl is faster. I dont know why

you sure?
could you show a demo ?

WebGL is faster than Canvas. I always recommend using AUTO or WEBGL.

Canvas is only faster on really old devices which do not support well WebGL.

Here some stats about webgl

Even this game with matter physics and WebGL works with around 60fps on my iPhone5.

Have you tried using Capacitor or PhoneGap?

No I haven’t. I use android studio. Is phonegap or capacitor faster?

I think they’re just as fast.

I usually use PhoneGap. But since you do know how to use android studio I recommend trying capacitor.

Any tips how to get my game faster? With Phaser 2 I had no problem with performance

I guess you configured something wrong. The performance of Phaser 3 depends a lot of your knowledge of the library and JavaScript in general.

Does it only work slow if you wrap it into a WebView app? Or does it even run slow in Chrome on Android or Safari on iOS?

To debug it. Simply uncomment one feature of your game after another and see how it impacts the performances. Once you found the inefficient code, try to improve it :+1:t2:

On my computer I have a fixed 60 fps. On the phone about 30-40 , and recently after adding an html bar with full animation in 30 seconds, the fps on the phone dropped drastically to 15-20, but I can throw it away.
The game is not smooth even when I throw out all the code and leave one tween with sprite reduction and enlargement.

Can you put your game on github?

Of course, this is the link to the code:

I cut it down a lot and threw away most of the scripts and images, but I left the jumping square, shadow and arrows. I also threw html and css.With this set I have about 40-50 fps. When I start spamming, the click drops to 25.

I found some improvements you could make.

menu.js:85 Uncaught ReferenceError: actualShape is not defined
    at menu.<anonymous> (menu.js:85)
    at arrowButton.h.emit (phaser.min.js:1)
    at initialize.processUpEvents (phaser.min.js:1)
    at initialize.update (phaser.min.js:1)
    at initialize.updateInputPlugins (phaser.min.js:1)
    at initialize.onMouseUp (phaser.min.js:1)
    at HTMLCanvasElement.onMouseUp (phaser.min.js:1)

And in index.html there is strange open tag.

</meta name="apple-mobile-web-app-capable" content="yes" />

I guess you do have to review your code again.

Also you can reduce the size of you images using https://tinypng.com/. menuBG.png could save -79%.

Thanks for the link. There is reference error because i cut a lot of code to show you where the problem is. Do you know why there is so poor performance of this code on the phone?

I tested it on my oldest phones (iPhone5 and iPhone5s). It works with 60fps on both. The iPhone 5 is now 7 year old. What phone are you using, Nokia 3330? :rofl:

Huawei y5 :smiley: I think it should works 60fps no fps decreases on any device