• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Android Game crashes on mobile due to RAM - Loading texture groups at run-time required

RyanC

Member
Hi everyone,

I've recently been experiencing issues with my game on a Sony Experia M2 phone.
The game use to work on this device a few months ago and I haven't upgraded any SDK's or NDK's.
The game is still working on my Google Nexus7 2012 model.

Any help really appreciated!
 
Last edited:

RyanC

Member
I've tried everything I can think of over the last 3 days to get the game working on this phone again including:

GMS:
Downgrading all texture pages from 2048 to 1024.
Flushing all textures in create_event.
Audio group optimization.
Resolution downgrade to 320 x 200.
Turning off all heavy draw functions.

Sony M2:
Cleared cache & data for all apps.
Freed up over 2.5 G of internal storage.
Restarted phone.
Cleared all GMS cache for the app.
Optimized RAM as much as possible by closing background application processes.

This phone use to perform the best out of all my devices and it still runs other games from Google Play but will not run my game anymore!
The room loads for about 5 seconds and everything looks fine with all animations running, then the app crashes and fails to respond.
 
Last edited:

JacPete

Member
maybe too much texture pages gets opened at the same time. i had once an issue with an nexus phone, it needed a ram booster app to clear the ram before start.
 

RyanC

Member
I think the issue is that all the texture pages are always in RAM memory.
Whats the point in draw_texture_flush? is doesn't seem to do anything!
I need to unload these texture groups from the RAM.
 

rIKmAN

Member
I think the issue is that all the texture pages are always in RAM memory.
Whats the point in draw_texture_flush? is doesn't seem to do anything!
I need to unload these texture groups from the RAM.
Run some tests to see if draw_texture_flush is actually not doing anything, seems an odd bug to not be noticed before if that is the case.
 

RyanC

Member
I've performed tests in debug mode, manually triggering draw_texture_flush.
The function is being processed, but this does not unload any textures or free up any RAM.
They seem to be all loaded at start and there's nothing I can do about it.
I have separate texture groups for all the level backgrounds enemies etc. (none on default texture page)
If I delete half of my level background sprites, the game uses less RAM and runs fine.
There are GMS games with bigger apk size currently working on this phone!
Anyone know what I'm doing wrong?
 
Last edited:

dphsw

Member
I have separate texture groups for all the level backgrounds enemies etc. (non on default texture page)
If I delete half of my level background sprites, the game uses less RAM and runs fine.
There are GMS games with bigger apk size currently working on this phone!
Anyone know what I'm doing wrong?
The apk size doesn't necessarily tell you how much memory it will take up - the textures are compressed, a bit like PNGs or gifs (though a different format) when in the APK, but are uncompressed, with every pixel taking up 4 bytes (so 1024x1024x4 = 4MB for a 1024 texture page) once they are loaded. Whether that's an issue would depend on how many texture pages you're trying to load. If you have 2 texture pages that are only half full, I would hope GameMaker would be smart enough to combine them automatically, but I'm not sure. So maybe make sure they are all full, that no space on them is being wasted. And remember the idea isn't to put things on pages by logical grouping, like all enemies on one page or something, but to put things on pages based on whether they're probably drawn around the same time, like world-1 backgrounds and world-1 enemies for example - the idea is to only need fewest possible texture pages per frame.
 

RyanC

Member
maybe too much texture pages gets opened at the same time. i had once an issue with an nexus phone, it needed a ram booster app to clear the ram before start.
This is correct!

Any ideas? @Mike @rwkay @ShaunJS
Game Maker must have a way of loading texture pages into RAM manually like all other professional game development software so we can produce professional looking games?
 
Last edited:

RyanC

Member
Correct me if I'm wrong but from my understanding GMS loads all the texture groups into RAM at the start of the game which is an issue for larger games on Android.
 

Bingdom

Googledom
As what @dphsw just said, make sure you separate the textures for each level.

Just requiring 1 texture from a texture page would require the whole texture page to be loaded.
 

RyanC

Member
As what @dphsw just said, make sure you separate the textures for each level.

Just requiring 1 texture from a texture page would require the whole texture page to be loaded.
Thanks to everyone for helping, I'm already aware of how texture pages work though. This post is about loading all the game's assets into RAM at game start, and if there's another solution?
 

JacPete

Member
just load the ones you need for the level in a loading screen before the level starts, dont load in all graphics at the beginning of the game.
 

RyanC

Member
just load the ones you need for the level in a loading screen before the level starts, dont load in all graphics at the beginning of the game.
How do you stop Game Maker from loading in all graphics at the beginning of the game?
 
P

PlayLight

Guest
Hi everyone,

I've recently been experiencing issues with my game on a Sony Experia M2 phone.
The game use to work on this device a few months ago and I haven't upgraded any SDK's or NDK's.
The game is still working on my Google Nexus7 2012 model.

Any help really appreciated!
Hey Bud,
loading programmatically in GM:S can result in more texture memory being consumed, without writing a management system and creating your own texture sheets.

That being said, i would bet dollars to donuts that this is not a texture memory issue at all, but instead an API build configuration issue, multidex configuration, support lib, run-time permissions, etc.

Before you try loading textures at runtime, would you mind posting your adb log first, so i can get a starting point to where the fs/crash is.
And the following info will help speed this up.
- GM:S version
- Build settings (build tools, support lib, min/target/compile API)
- All extensions used (if any)
- Device android version (v5.1 (Lollipop) probably?)
- Java version

You can PM me these details if you would prefer to keep this thread on it's original topic.
 

rIKmAN

Member
That being said, i would bet dollars to donuts that this is not a texture memory issue at all, but instead an API build configuration issue, multidex configuration, support lib, run-time permissions, etc.
Interested to see what your findings are, I've seen you help a lot of people with Android problems.
As someone who is planning on using different sets of sprites depending on device resolution I'm following this topic closely.

It doesn't make sense to me that it would load everything in the resource tree at startup with no way to change and manage it.

A device with 512mb ram and a 640x480 res has to load all the HD sprites for a high end device with 2gb RAM and a 1440x2560 resolution just because the sprites are in the resource tree and there is no way to workaround this?

That just can't be right - it defeats the whole point of multiple device support and Universal apps.
I also feel like something like this would have caused massive problems before now and would have been addressed, so I think there is something else going on (though I may be wrong), because I just can't get my head around it.
 
Last edited:

RyanC

Member
Just heard back from the YoYo Support team and it's not good news at all:

GameMaker: Studio will load a WAD file into RAM and the texture groups only function to manage video memory.

So basically GM loads all your assets into RAM and there's no way to unload any graphics, 12 months of development on this game and now I can't release it.

Good luck to anyone that wants to make anything professional with Game Maker Studio!
 

TsukaYuriko

☄️
Forum Staff
Moderator
Let's overwrite that with some good news, then.

If the default texture handling is too limited for your needs... just take control over it yourself: https://marketplace.yoyogames.com/assets/4543/custom-sprite-framework

This is what @Lonewolff was talking about. If static graphics are not enough, use dynamic graphics. Static graphics are always loaded and available by design. You seem to have been overlooking dynamic graphics completely so far...
 

RyanC

Member
Let's overwrite that with some good news, then.

If the default texture handling is too limited for your needs... just take control over it yourself: https://marketplace.yoyogames.com/assets/4543/custom-sprite-framework

This is what @Lonewolff was talking about. If static graphics are not enough, use dynamic graphics. Static graphics are always loaded and available by design. You seem to have been overlooking dynamic graphics completely so far...
I've already tried that package, and just tried to import it again. The scripts are missing so it appears to be useless. But thanks anyway, I can really use all the help and advice I can get right now!
 

RyanC

Member
The scripts appear on the asset's preview page... are you sure you imported all contents of the asset?

The asset can also be downloaded as simple scripts here: http://gmc.yoyogames.com/index.php?showtopic=669935
Thanks, looks like just what I'm after!

I'll be using an expansion pack with Google Play so hopefully it'l work...

Just found the latest release here in case anyone's interested: http://gmc.yoyogames.com/index.php?showtopic=669935&page=2#entry4936654
 
Last edited:

rIKmAN

Member
It still doesn't make sense to me that it loads everything with no way to control what is / isn't loaded at all - there must be some way?

What about apps that have multiple sets of graphics - low res for older devices and high res for newer devices.
Think Universal Apps targeting older phones upto an iPad Pro.

So GM forces the older device to load all the high res graphics as well (and probably crash) and you have no control over this?

I can't get my head around it - can any experts chime in on how to workaround this bizarre "feature"?
 

TsukaYuriko

☄️
Forum Staff
Moderator
It still doesn't make sense to me that it loads everything with no way to control what is / isn't loaded at all - there must be some way?

What about apps that have multiple sets of graphics - low res for older devices and high res for newer devices.
Think Universal Apps targeting older phones upto an iPad Pro.

So GM forces the older device to load all the high res graphics as well (and probably crash) and you have no control over this?

I can't get my head around it - can any experts chime in on how to workaround this bizarre "feature"?
v v v
External textures.
^ ^ ^
Take a look at my previous post for an example of such a system.
 

rIKmAN

Member
You can specify when external textures are loaded and unloaded whenever you like.
Got any links where I can do some reading on this - is it in the manual?
Also doesn't adding external sprites put each sprite on its own texture page, making it a bit useless?

v v v
Take a look at my previous post for an example of such a system.
Would that system work with Spine sprites?

It just seems really overkill for something so simple in an engine aimed primarily at beginners.
 

TsukaYuriko

☄️
Forum Staff
Moderator
I was unable to find any information on that. Given that I haven't worked with Spine sprites, I'm unsure how they are or can be loaded, including whether they even can be loaded dynamically. Someone else will have to answer this.

Got any links where I can do some reading on this - is it in the manual?
sprite_add and sprite_delete.

Also doesn't adding external sprites put each sprite on its own texture page, making it a bit useless
That's why the extension I linked to was made.
 

rIKmAN

Member
Yep it does, but there is nothing to stop you baking your textures in your own external texture page.

sprite_add or background_add in the manual should shed some light :)
Yeah I checked those manual entries out before, but I've been PMing with RyanC waiting to see what YoYo said about his problem.
I'm now seriously wondering whether to use carry on using GM at all, as it just seems crazy to me the way it enforces this "load everything" rule and seems extra work just to workaround the enforced limitations.

I'm used to having all assets "on disk" and loading them into RAM as I need them, which means no problems with memory use, texture pages, multiple resolution sprite sets etc as I only load what I need, when I need it depending on the device / resolution.

Does GMS2 do the same thing?

Also the asset @TsukaYuriko linked to also doesn't seem to be a perfect solution either.
 

RyanC

Member
Can't you still load what you need when you need anyway though?

No matter what engine you use a image will become a texture page at some point in the pipeline.
This might be ok for large backgrounds of 1024 size, or even getting four 512's on one page and then using draw_sprite_part_ext, but most of my large background gradients are already optimized at 1 pixel wide and then just stretched. The ones that aren't have way to much scaling code for that method, as they're tiled horizontally and scaled dynamically for a zooming parallax effect which took months to achieve.
As for getting the sprite animation frames in with this method, I don't see how this is possible without exchanging RAM for CPU because of all the extra code required. My artwork has been rendered from 3d models and has a large amount of frames per sprite.

This is the biggest GM shock I've had in 4 years, we can unload audio groups so why not texture groups?
 

rIKmAN

Member
Can't you still load what you need when you need anyway though?

No matter what engine you use a image will become a texture page at some point in the pipeline.
Just wrote a big reply and Safari crashed lol!

In a nutshell, if the offered solution is to use a 2yr+ old set of scripts that may/may not work (and has its own set of problems), not to mention using Spine with that system probably wouldn't work - then I doubt I'm gonna go to the hassle of implementing workarounds and cludges to something that should be very simple to manage.

Primarily being a coder I'm used to doing everything myself, if I don't specifically load/flush something it's just a file on the disk - so having GM force load everything on start just seems alien to me.
So then it seems GM is only any use for small games, or games which the creator is happy to use a single set of sprites and scale them or the surface between all resolutions and deal with the blur that will occur on higher resolution devices when scaling up.

Or you write your own custom system to manage everything.

GM is aimed at beginners that might never create a game that hits these issues as well, and that might be the problem I'm seeing which is not a fault of the software so much as myself.
But then I see the games in Showcase and think I must be missing something - although how many of them are dealing with the wider range of mobile screen sizes I have no idea.

They may also have implemented custom systems to manage exactly this, but I'm relatively new to GM and for me personally it would be easier to go and use a language I am comfortable with rather than try to implement something in GM when I'm not 100% confident in my knowledge of the tool.

I might be misunderstanding things and it might be very simple - but it just seems like something basic has been made extremely difficult, I'm sure there are reasons that I don't understand, but it does baffle me.

If you have an "GM External Textures for Dummies" link I'd be happy to read it.

Does GMS2 do things the same way, or do it differently?

edit:
I should add that I am really feeling for RyanC at the mo, so I'm being extra cautious and skeptical about things (and with my questions) as I am lucky enough to still be in a position to choose whether GM is suitable for my next game, and if not I am able to use something else which I have released apps with previously.

I'm not being awkward for the sake of it, just....weary. :)
 
Last edited:
M

Michael Gutierrez

Guest
Just heard back from the YoYo Support team and it's not good news at all:

GameMaker: Studio will load a WAD file into RAM and the texture groups only function to manage video memory.

So basically GM loads all your assets into RAM and there's no way to unload any graphics, 12 months of development on this game and now I can't release it.

Good luck to anyone that wants to make anything professional with Game Maker Studio!

Hey dude! I am going through the same thing - I made a game called ANYA: DEMONSLAYER, uploaded to Google Play and all ... tested it on my samsung galaxy note 5 (8 core 2GB of RAM), I can play start to finish with no issues. My buddy downloaded it to his Nexus and the game crashes due to this mem issue. I have spent days try to find mem leaks and checking texture flush and all that ...


My final result is this, the 700MB ver will become my HD version on Android. I am currently cutting ALL my animations in half and reducing room speeds to 30 from 60 and hoping the 350MB version should run on 4 core 1 GB android device. Bench Marking with HP 7 and Fire HD8.

My original version (1.2GB) will be the PC version. I feel your pain and hope you find a solution ... don't give up on your game dude!!


-Mike
gutichael.com

https://play.google.com/store/apps/details?id=com.gutichael.ANYA_Version_8&hl=en
 
Top