- Home /
IOS Terminated due to memory issue because of a 2D animation with 60 frames in it
Hi everyone, A strange thing start happening last night, am working on [this game]() (we have more stuff now) and everything was working fine on my side (galaxy s5 and s3) but when i send the project to my client to test it on his iphone5, the game crash and log this error :
Message from debugger: Terminated due to memory issue
it was caused by a single Animation, it contain 60 Frames with a different image for each frame, and each image has a resolution of 480x480. We changed that Animation on iOS (removed 57 frame) and we no longer get the error.
The question is, why is that happening ??? The exact same game with that "big" animation is running okay on a Galaxy s3 and Galaxy s5, what make this an exception for iOS ?
Thanks
[unity 5.1.3]
Answer by phil_me_up · Jan 10, 2016 at 01:26 PM
Are all 60 frames a different 480x480 image? If so then that is a lot of memory needed to display them all, even if you are using optimal compression. Remember that if the file size of a jpeg / png etc is something like 150kb, that's not what it uses in memory on device, it will use significantly more as it will be uncompressed.
The Galaxy S3 and iPhone 5 both have (i think) 1Gb ram in in, how that ram gets used depends on the OS and on what is running in the background. That would explain the differences between platforms (also your image compression might be different between platforms).
Bottom line, when developing for mobile you need to be very conscious of your images. Some optimization tips are to try and make them PowerOfTwo and improve compression (PVR for example), or to pack sprites in one or more sheets which you then setup to use better compression.
I see ...
We did had a spritesheet for this animation but no matter what we do, the edges are always blurry.
atm i am thinking of using a render texture, or divide the animation in 4 parts or something
Thanks
I'm not sure either of those solutions would work as you'll still basically be loading in the same assets which will use the same memory. Perhaps you'll find a configuration which improves matters, but remember that there are people out there with devices that have 512$$anonymous$$b and less.
I would look at what you're actually trying to do. Does the animation need to swap between 60 different sprites, or could each frame consist of common parts which are simply re-positioned / re-coloured etc to make the whole? Think of a playing card, you don't need 52 individual sprites to make any card in a deck, just the suits, the numbers and then perhaps a couple of special cases for kings / queens etc.
Does the sprite need to be 480x480?
Depending on how frequently you need to change the sprites, you may be able to unload the assets, but you don't want to be doing this too often as it'll probably cause some stutter.
This is the animation i will look if we can reduce the sprites resolution, but tonight am gonna give GAF a try, since all of our art is made in Flash, i think this could be the perfect tool.
thanks
Your answer
Follow this Question
Related Questions
Adding animation clips via script 2 Answers
Profiler does not show objects when hooked to an iPad 1 Answer
Keyboard triggered animation not showing on IOS device 0 Answers
Android Tablet vs iOS iPad performance difference 0 Answers
Animation of terrain causes drastic performance drop (fps) 0 Answers