Skip to main content
Participating Frequently
April 2, 2012
Question

Battery draining faster when compared to native apps?

  • April 2, 2012
  • 1 reply
  • 2257 views

Hey all,

It seems my AIR apps are draining the battery on both iOS and Android devices noticably faster than native apps. Does anyone else experience these problems? If so, is there anything I can do to prevent this behavior?

For your information: I'm not doing any performance heavy stuff on-screen as this is a relatively simple board game. I am, however, polling a webserver every 15 seconds or so.

Thanks in advance!

This topic has been closed for replies.

1 reply

Participant
April 6, 2012

Eljo_B wrote:

Hey all,

It seems my AIR apps are draining the battery on both iOS and Android devices noticably faster than native apps. Does anyone else experience these problems? If so, is there anything I can do to prevent this behavior?

For your information: I'm not doing any performance heavy stuff on-screen as this is a relatively simple board game. I am, however, polling a webserver every 15 seconds or so.

Thanks in advance!

This, the bit in bold, could easily be the source or a contributing factor to your battery drain problem. Even with an app created with the native SDK in xcode, if you are transferring data to and receiving data from a web server constantly, you will get poorer battery performance compared to a like for like app that does not.

Without knowing exactly what you are doing when you poll the webserver, its difficult to recommend anything. What I would do, is to test whether or not the webserver polling is draining the battery. To test this, I would make a copy of the app without any webserver polling (if that is possible). Then run each version for an hour (from full charge with each) and compare.

Also its worth checking your code (this relates to the web server polling too), even though it may be a simple game, on mobile devices you need to be thinking about efficiency all the time, looking at how you achieve things as in whats the most resource efficient way to do it. Just because some code or an approach is simple, doesn't make it resource efficient.

Take your webserver polling, lets say if you are posting progress information such as the users current score or highscore to the server, do it at the end of a play session as opposed to realtime on a timer. If you are running a function on a timer, you are running a loop constantly, in the background, which uses up resources, which affects performance and affects battery performance.

Also if you are transmitting to a webserver in a window of every x seconds, your using the phones wifi or data connection - which is significant on the devices battery. If I sit there browsing the net a lot on my iPhone, my battery drains significantly faster. Part of its due to the Safari application running, a big part is due to my iPhones transmitter being active (wifi or over the 3G network), your app is no different in this respect, as you poll the webserver you are using that facility which is eating up battery life.

What I'm getting at is, that you should review how you approach these things to see whether there could be a more efficient route. I wouldn't be polling a server every 15 seconds in any of my apps unless I really had to, and if I did I'd look at making that process as efficient as possible.

Say, if you are recieving data from the server only, would the push notifications platform be better. i.e. I have an app with a private messaging facility built in, it tells you when you receive a new message from someone, this is done via push notification, not via polling a web server as that would be less efficient, considerably so (unless I was checking once every 15 minutes or something).

iBr3nt
Inspiring
April 6, 2012

I think you just answered your own question.

How do you know it's draining the battery faster than native apps? Do

you have the same app written natively to compare against? Any network

activity will drain battery. But so does everything else in an app.

I don't think there is a specific issue with AIR apps draining battery

life more than native. I can write a native app that'll kill the battery

just as easily. It's all in how you program it. Things like network

activity, sensor activity (polling GPS, Camera, etc), all of these

contribute additional load on the device, so it can seem to "drain" the

battery. Leaving things running in the background will also have a

detrimental effect on the battery life.

iBrent