I have started using GameMaker:Studio this year and, since my primary mobile target is Android, transition from 1.2 to 1.3 wasn’t the most pleasant experience. To be honest, it was probably the worst. I do like those 60FPS in my simple 2D games and watching them halve after running APK built with 1.3 was devastating.
While YoYo Games are surely improving their new surface-based drawing pipeline, as much as I Googled and browsed, I couldn’t get back the smoothness I needed. Article Optimising The Draw Pipeline had some solutions, but most of them had absolutely zero impact in my projects. You should check them out and experiment for yourself, but for me only bypassing default shader increased FPS in Galaxy 10.1 tablet (had no impact in Galaxy 7).
I wasted a shameful amount of time on this, since I’m not very attentive and searching through GMC forums is usually quite unpleasant experience, but the solution exists and it’s as easy as adding single line in Create event of some object created at the start of the game:
Basically, it makes all the fancy drawing logic disappear and sets you back to the good old times of 1.2, when people with older or economic-class Android devices were running your games smoothly. And the results made my eyes teary from joy – 60FPS in both Galaxy Tab 7 (from 25-30) and Galaxy Tab 10 (from 40-60*).
Now, I ashamed to admit that, but I did find it much earlier, but in an unlucky turn of events and brain farts I confused it with application_surface_draw_enable() and lived in an illusion that taking over drawing of surface to your hands was what I needed. That being said, my quest for FPS weren’t completely without loot, so I’m to share some things, which worked for me thus explaining bold “60” in previous paragraph.
Bypassing Default Shader
This, taken from the YoYo optimization article, had the biggest impact to me in Galaxy Tab 10 boosting FPS by 10-15 when still using 1.3 surfaces. Sadly, it seemed to have no impact in the older Tab 7 (different OpenGL versions? I’m no expert here and I might have been doing something wrong, so take my words with a grain of salt). The implementation is in the example projects listed in the before-mentioned article, but if you, like me, hate adding tutorial projects in to your workspace and you, like me, have no idea, where to put those shaders, just follow this…
What you should’ve done already, is resizing surface to match your view (preferably in the same place where you should be adapting view/port to the device screen) with surface_resize(application_surface, view_wview, view_hview); and taking surface drawing in to your own hands with application_surface_draw_enable(false);.
- Right click on “Shaders” and “Create Shader”
- In the object of your preference create a “Post Draw” event
- Drop a code action and Ctrl+vomit these lines:
draw_surface_stretched(application_surface, 0, 0, view_wport, view_hport);
Build, play, check the FPS. Hopefully, the result makes you at least a bit happy. The YoYo article mentions some changes in the shader you could make, but I only downloaded the final example project and couldn’t find any differences between shader0 & shader1. I would really like to see some comments in those examples…
Faster background drawing
Now, other thing, which significant amount of those sweet sweet FPS and which I kept even after disabling usage of surfaces, was drawing backgrounds manually, since, in my case, they’re usually large images without any transparency. That being said, this is not very useful with fancy foregrounds with alpha. So, to take your background away from the sticky hands of GameMaker, you should…
- Uncheck “Visible when room starts” in the “backgrounds” tab of your room.
- Add a “Draw begin” event in an object of your choice
draw_background(background1, 0, 0); // can use draw_background_tiled() or other related functions too!
Players with low-end devices are people too. Take care of them. Jokes aside, you’re most welcome to correct me, since shaders & surfaces are not really my area of expertise.I would have been much happier if I wouldn’t have been forced to dig through this stuff. In the end, I got my 60FPS, players are happy, so I’m happy too. Until I’ll need to use surfaces….
Optimizing Your games in GameMaker: Studio
20 thoughts on “GameMaker 1.3+ and low Android performance”
Excellent article thank you for sharing!
Was all I needed to get form 25fps to 60fps on my Moto E.
Pingback: Optimizaciones para Android en GameMaker: Studio | HektorProgramador
Crystal Set Dial W
Pingback: Optimizar para Android en GameMaker: Studio - Escuela de Videojuegos
Awesome article. Helped me a lot!
A’m using large sprites with alpha, and downscaling views for mobile devices. Performance is very low, due to some driver issues with drawing surfaces on android devices. This works for me just fine. Thank you.
wow, seems incredible, but application_surface_enable(false) made the game go from 15fps to 60 on my Nexus 10 tablet :S I’d like to know why this fixes the framerate problem though.
Thanks a lot!
Yeah, it does wonders to some devices, although on others the improvement can be barely noticable. Since I don’t use surfaces at all, I just turn it off in all of my problems. Why does it make such difference? No idea. There are some ways to improve surface performance, but I got really tired trying to do so.
ohhh maaaan… thanks a very very very lot! I am looking for 4 days for this solution! Before this Lenovo A2010 is lagged… and force closed on huawei 530Y … Now running without lagging both of 2 devices!!! And it means it will running on every device without lagging! THANKS A LOT
From 20 to steady 60fps!!!!!
OMG thank you so much!!!!!!!!!!!!!!!
action number 1
of Draw Event
for object obj_supervariables:
Trying to use non-existing surface.
at gml_Object_obj_supervariables_DrawPost_1 (line 4) – draw_surface_stretched(application_surface, 0, 0, view_wport, view_hport);
did you find a solution?
with me gave the same error, could not solve =/
Is this only for those who draw a surface?
FINALLY, I’m able to run my game smoothly without fps drop… THANK YOU SO MUCH <3
THANK YOU! Finally, my game runs like butter
Butter can run?