• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

iOS Mobile devices heating up: causes and solutions?

SnoutUp

Member
Hey there,

I have received a few complaints about phones heating up during relatively short play sessions (10-20) of my game. Lately it was mostly from iOS beta testers, but I think Android users mentioned something too. While it could potentially be that my game is just THAT hot, I'd like to know other possible causes and hopefully resolve some issues before the launch.

Game is a turn-based card crawler, low object count, generally not that intensive (with few exceptions mentioned below). Here's what I'm thinking about, but don't have enough technical knowledge to rule or confirm things out:
  • Game is running at 60FPS (would capping this to 30-50 help?) (didn't help)
  • Doing a lot of calculations every turn (mostly data structure manipulation)
  • Auto-save every few turns (a lot of data structures being created, converted to JSON and written to file (file_text_write_string))
  • Application surface is disabled (I still do that since I noticed performance boost in older Android devices ages ago)
  • A single surface is being drawn (backgrounds) and only updated when view size changes
What do you think about these points? Any other possible cause comes to mind maybe? I'm kind of leaning towards auto-save being the main culprit, since it is pretty damn intense. Maybe using some kind of alternative (buffers?) to file_text_write_string help?

Let me know what you think!
 
Last edited:

Roderick

Member
Overheating happens when the processor is close to its load limit for an extended period of time. Anything that you can do to reduce the total number of calculations per second will help.

Reducing the frame rate will probably help, and it will improve battery usage as well.

Can you simplify code anywhere? Do you have things that rarely or never change that you're recalculating every time they're used? If so, look at caching those values to reduce calculations (For example, when you equip a weapon, increase attack and reduce it on unequip, as opposed to looking up every piece of equipment and buff and adding them together each time attack is referenced). I'm not sure how your code is set up, so you'd have to look for specific things that could improve your code, but if you're constantly rebuilding those data structures you mentioned, consider finding a way to keep them constant, and only change the individual values as they're updated.
 

O.Stogden

Member
I've not fiddled around with it, but could your "sleep margin" setting be too high on Android/iOS? I know setting it too high can cause the CPU to never relax, which could cause battery and heating issues.
 

SnoutUp

Member
Overheating happens when the processor is close to its load limit for an extended period of time. Anything that you can do to reduce the total number of calculations per second will help.

Reducing the frame rate will probably help, and it will improve battery usage as well.

Can you simplify code anywhere? Do you have things that rarely or never change that you're recalculating every time they're used? If so, look at caching those values to reduce calculations (For example, when you equip a weapon, increase attack and reduce it on unequip, as opposed to looking up every piece of equipment and buff and adding them together each time attack is referenced). I'm not sure how your code is set up, so you'd have to look for specific things that could improve your code, but if you're constantly rebuilding those data structures you mentioned, consider finding a way to keep them constant, and only change the individual values as they're updated.
Thank you very much, this is giving me some good pointers. For over a week now I was working on optimization (unrelated to heating issues, tried to achieve 60FPS on a 5 year old Android device), so many calculations are spread out or happen only when really needed. I'll have to look into ways to optimize the game save code, there should be room to make it easier on the CPU.

I'm gonna try lowering FPS too. Also an effect to battery consumption should be easy to test!
 

SnoutUp

Member
I've not fiddled around with it, but could your "sleep margin" setting be too high on Android/iOS? I know setting it too high can cause the CPU to never relax, which could cause battery and heating issues.
I'm too scared to touch that value, so it remains at default. Maybe lowering it more would help..?
 

O.Stogden

Member

This topic goes into it a little.

It really is on a game-by-game basis, setting it too low could cause slow-down, setting it too high can cause overheating or excessive drain on the battery.

Generally setting it too high isn't an issue for Windows/Mac computers, as we naturally assume they'd get hot while playing a game (as is mentioned by the GM Dev in that thread). However mobile users probably aren't used to their devices running hot when playing a game. Although I have played a few games that make my phone run hot, and some phones naturally have poor cooling or overheating problems.

The 1st image in that thread explains it well.

Your game logic and drawing is processed, let's say for your game, it takes 7ms. We now have 9ms until the next frame and logic is needed to be processed. (Frame is 16ms long)

If sleep margin is set to 9ms, we basically keep the CPU powered up for all the remaining time, and then it's good to go as soon as the next frame is needed. The downside being, the CPU never gets a rest.

If sleep margin is set to 5ms for example, then we give the CPU a 4ms break per frame where it can relax, and not keep running. This could potentially cause a slowdown as the CPU could switch clockspeeds during gameplay, but the upside of this is that the CPU gets a chance to cool.

16 - (Processing + Sleep Margin) = CPU idle/rest time. For a 60FPS game.
 
Last edited:

SnoutUp

Member
Your game logic and drawing is processed, let's say for your game, it takes 7ms. We now have 9ms until the next frame and logic is needed to be processed. (Frame is 16ms long)

If sleep margin is set to 9ms, we basically keep the CPU powered up for all the remaining time, and then it's good to go as soon as the next frame is needed. The downside being, the CPU never gets a rest.

If sleep margin is set to 5ms for example, then we give the CPU a 4ms break per frame where it can relax, and not keep running. This could potentially cause a slowdown as the CPU could switch clockspeeds during gameplay, but the upside of this is that the CPU gets a chance to cool.

16 - (Processing + Sleep Margin) = CPU idle/rest time. For a 60FPS game.
Oh, thank you so much! This is the best and clearest explanation of sleep margin I've seen so far. Even I get it now!
 

Ricardo

Member
My experience with sleep margin: if too low, it causes issues on Desktop as slightly slowdown/stuttering. If too high, the CPU works too much (causing fans to spin and high CPU usage, but the game usually runs well).
You need to find a sweet spot for your project. I'd use display_set_sleep_margin to tweak it dynamically. You can try a lower value for mobile to avoid overheat and use a higher value for PC if needed.
 

SnoutUp

Member
My experience with sleep margin: if too low, it causes issues on Desktop as slightly slowdown/stuttering. If too high, the CPU works too much (causing fans to spin and high CPU usage, but the game usually runs well).
You need to find a sweet spot for your project. I'd use display_set_sleep_margin to tweak it dynamically. You can try a lower value for mobile to avoid overheat and use a higher value for PC if needed.
Thank you! As far as settings go, Android already has way lower default value (4ms), so not much room to go lower (and I'm a bit nervous about doing so) and iOS doesn't have that setting at all.
 

SnoutUp

Member
Bumping this thread, since I launched the game on App Store and getting more reports about devices heating up and batteries being drained unusually fast. There's already a FPS cap and an option to disable auto-save, but it doesn't look like that's enough. I did a lot of code optimizations too...

Any more ideas..?
 

TsukaYuriko

☄️
Forum Staff
Moderator
Is this about Card Hog? If so, I wouldn't consider either of the issues discussed in this topic as normal and to be expected. That's not to say that the problem lies with your code, though.

To approach this from a different side than what's been mentioned already... do you know the specs of the devices this issue occurs on and how long they have been in use? Not to be the "blame the user" person, but there is a very real chance they are using old devices. Mobile devices are known to develop issues with battery life and heat, and manufacturers come up with all sorts of ways to combat them (or ignore them).

Do you have access to a wide variety of mobile devices to test the game on? Failing that, maybe relatives can lend their devices? This would let you check things from the hardware and age sides.

The reason why I'm approaching it from this side is that it doesn't sound like the majority of your users are reporting this issue. Also, you've already optimized a lot of possible problem sources, all to no avail. If optimization doesn't resolve or at least mitigate the problem, chances are the source isn't a lack of optimization in the first place.
 

rwkay

YoYo Games Staff
YYG Staff
We fixed an issue on IOS that was causing the CPU to be run heavily, this is fixed in the current Beta you should test that out

Russell
 

SnoutUp

Member
We fixed an issue on IOS that was causing the CPU to be run heavily, this is fixed in the current Beta you should test that out
Russell
I rolled a pretty stressful update built with GM Beta and just got some good news from one of the players who experienced battery drain. Will wait for more confirmations before celebrating, but my stress levels are going down already.

Have to say the new update has done great job on the battery drain. Played for about half an hour and it only went down 3% and my phone isn’t getting hot either. Thanks for fixing it so quickly
 
Top