GameMaker android low fps issue

F

Furiosposion

Guest
hello i'm working on a platformer
in pc it runs at smooth 60fps and if i try to make roomspeed bigger i can max see 170-200 fps
but in android it's really low like 10-20 fps not even more, i tried setting application surfaces to false and setting sleep margin to 10 and it's still low.
 

Simon Gust

Member
Maybe your game is just poorly optimized. I suggest running the profiler in the Debugger. As a General rule, a phone isn't as powerful as a pc, idk what you are expecting from a phone when your pc makes 180fps.
Place this, somewhere in a create event
Code:
show_debug_overlay(1);
And you should see a red / yellow bar Pop up at the top of your screen, the longer the bar, the slower your game.
 
F

Furiosposion

Guest
drawing aka yellow bar is getting longer however i got yyc build and in pc now it's over 300-500 in android 40-80 but wierdly it's unstable so bad. and i'm only drawing few 45x45 sprites which are inside of camera view
 

FrostyCat

Redemption Seeker
The yellow bar is one thing to look for, the other is the number of texture swaps and batch breaks. If both of these are high, building with YYC wouldn't help as that only alleviates CPU-bound loads. You'd have to get your hands dirty and manually optimize your pipeline.
 

DBenji

Member
drawing aka yellow bar is getting longer however i got yyc build and in pc now it's over 300-500 in android 40-80 but wierdly it's unstable so bad. and i'm only drawing few 45x45 sprites which are inside of camera view
Have you made sure to disable alpha blending when possible? I'm also curious what android model or emulator you are using. Without more specific information (i.e. how many objects and how many have intensive step events, whether using shaders or surfaces, exact number of sprites, etc)... it's hard for anyone to help you.

You shouldn't have much trouble though if it really is just a few 45x45 sprites on a modern android phone. Try an empty project with just the sprites and measure how much performance improves.
 
F

Furiosposion

Guest
Have you made sure to disable alpha blending when possible? I'm also curious what android model or emulator you are using. Without more specific information (i.e. how many objects and how many have intensive step events, whether using shaders or surfaces, exact number of sprites, etc)... it's hard for anyone to help you.

You shouldn't have much trouble though if it really is just a few 45x45 sprites on a modern android phone. Try an empty project with just the sprites and measure how much performance improves.
i guess yes i should try drawing them on a empty project.
and btw i do have 2 surfaces (alr tried with removing them), alpha blending is always true, and 3 objects one is for ui, second is for player, last one is for system,
and this is my code for drawing:

Code:
STEP:

global.width = camera_get_view_width(view_camera[0]);
global.height = camera_get_view_height(view_camera[0]);
global.viewy = camera_get_view_y(view_camera[0]);
global.viewx = camera_get_view_x(view_camera[0]);
global.animation +=1;
Code:
DRAW:

        //background
        var sprite = asset_get_index("s_background_"+string(global.background));
        draw_sprite_ext(s_background,global.animation,global.viewx,global.viewy,1,1,0,c_white,1);
       
        var width = global.width/45;
        var height = global.height/45;
        var x_ = floor((global.viewx)/45);
        var y_ = floor((global.viewy)/45);
        for (xx = x_; xx < x_+width+1; xx+=1){
        for (yy = y_; yy < y_+height+1; yy+=1){
        //if (point_in_rectangle(xx*45,yy*45,global.viewx-90,global.viewy-90,global.width+global.viewx+90,global.height+global.viewy+90)){
   
        var tile = tile_sprite(t_block[#xx, yy]);
   
        //shadow
        draw_sprite_ext(tile,0,xx * 45+3, yy * 45+3,1,1,0,c_black,0.5);  
     
        //tile
        draw_sprite(tile,0,xx * 45, yy * 45);
}}
 
F

Furiosposion

Guest
i tried with clean project, and its 60fps stable (over 300 on real fps), however when i press with mouse the batch(white) bar gets too high load and fps drops to 2-5. (there is no event set about mouse i do only run the code i sent above)
 

DBenji

Member
i guess yes i should try drawing them on a empty project.
and btw i do have 2 surfaces (alr tried with removing them), alpha blending is always true, and 3 objects one is for ui, second is for player, last one is for system,
and this is my code for drawing:

Code:
STEP:

global.width = camera_get_view_width(view_camera[0]);
global.height = camera_get_view_height(view_camera[0]);
global.viewy = camera_get_view_y(view_camera[0]);
global.viewx = camera_get_view_x(view_camera[0]);
global.animation +=1;
Code:
DRAW:

        //background
        var sprite = asset_get_index("s_background_"+string(global.background));
        draw_sprite_ext(s_background,global.animation,global.viewx,global.viewy,1,1,0,c_white,1);
     
        var width = global.width/45;
        var height = global.height/45;
        var x_ = floor((global.viewx)/45);
        var y_ = floor((global.viewy)/45);
        for (xx = x_; xx < x_+width+1; xx+=1){
        for (yy = y_; yy < y_+height+1; yy+=1){
        //if (point_in_rectangle(xx*45,yy*45,global.viewx-90,global.viewy-90,global.width+global.viewx+90,global.height+global.viewy+90)){
 
        var tile = tile_sprite(t_block[#xx, yy]);
 
        //shadow
        draw_sprite_ext(tile,0,xx * 45+3, yy * 45+3,1,1,0,c_black,0.5);
   
        //tile
        draw_sprite(tile,0,xx * 45, yy * 45);
}}
Okay makes sense why it would be so slow... I have no idea what your "tile_sprite" script is doing, but your code looks like a bunch of unnecessary scripting gymnastics just to draw sprites which you call tiles within view... add to that the fact that alpha is still enabled (which yyg recommend to disable whenever possible esp. for mobile) and how you are performing draw_sprite twice (normal + ext + whatever tile_sprite is doing) for every iteration of an iteration in a for loop within a for loop. Sounds like overkill.

Sadly, gms1.4 does not have the benefit of the an incredibly optimized tile layer system which gms2 has. It would be very handy in this case. But I would recommend you try the old tile system or just a background with all your sprites baked onto it. Be sure to disable alpha too.
 
F

Furiosposion

Guest
i'm using gms2, the tile_sprite is just like this
if (argument0 = 1)return s_grass_block;
i also tried with setting gpu_set_blendenable(false);
gtg check out that doc you mentioned
 
F

Furiosposion

Guest
i cannot use tiles as tileset or background because the grid's tiles are much interacted in-game.
it's editing world based game.
 

DBenji

Member
i cannot use tiles as tileset or background because the grid's tiles are much interacted in-game.
it's editing world based game.
Um, I'm pretty sure you can. Have you heard of tile-based collisions? Also, there are a ton of functions for dealing with tiles. I'm pretty sure you just need to be using the tile functions combined with tile-based collision. You might also need to switch between emptying tiles and drawing a sprite which the player is interacting with depending on how your game works. Scrap what I said about backgrounds - I assumed you were using gms1.4 where backgrounds are part of the asset framework.
 
F

Furiosposion

Guest
oh good to hear, i'll get a build with it and test in android quick, are tile sets optimized drawing with camera view by built in?
 

DBenji

Member
Tiles are so optimized that only whatever is within the screen view is processed. Gms2's tile system is arguably more powerful than what Unity currently offers straight out of the box. Yet most GM users stick to using sprites or asset layers probably because not enough people are talking about how powerful the current tile layer system truly is.
I will say though that editing tiles in a room can be a pain depending on how large your tilemap is and how small your tiles are. If your tiles are tiny (say 8x8) and your tile map is 4000x4000 then your room IDE editing will lag like hell.
 
F

Furiosposion

Guest
actually i won't be editing it on tile editor, it's based on player's build from using blocks from inventory, and i tested with bluestacks's possible very low limits and it worked perfectly 60fps that means it won't be lagging on %90 of devices such as low-end ones, also may i know is it possible to use an animated tile or do i need to edit tile on step to make it look like animated?
 

DBenji

Member
Read the manual. Tile animation is a thing. Also, Bluestacks? Last I checked this tool was only for gamers who wanted to play android games on pc - it was never intended for mobile developers. Have you used Android Studio? It is officially supported by Google and you can get far more accurate emulators of various phones there. Bluestacks is not a reliable metric to be using to profile your performance + it has a shady reputation.
 
F

Furiosposion

Guest
i just used it as a low-end test, i limited it's gpu ram usage to low etc.
 
Top