

Why GroupMe kills the battery on your iPhone - RandallBrown
http://fredandrandall.com/blog/2012/02/08/why-groupme-kills-the-battery-on-your-iphone/

======
oasisbob
This is not a good idea. HTTP polling is enough traffic to put the mobile
radio into its DCH state, which uses a lot of power. (Second only to the
screen on most phones.) Once you're in DCH, there's a timer (typically ~8
seconds) before it turns off again. When polling, you just wasted orders of
magnitude more power to wake the radio than was used to actively communicate
for that 500ms or so.

One of the great things about the internet is that you can neglect
considerations of the physical layer when you design your app.

One of the sad things about the mobile web is that you can't neglect
considerations of the physical layer when you design your app.

Some things that seem like a great idea at first (eg lazy loading of lists as
the user scrolls) can actually be detrimental and counter-productive when it
comes to battery life.

~~~
simonw
Could you expand on your point about loading more content as the user scrolls?
Why would that affect power usage?

~~~
jarek
This is a bit simplified since often your app's activity won't be the only
thing on the radio, but:

Full load: large transmission to start off, but radio is idle after, if the
list is long or user scrolls slowly radio might go to sleep after its
programmed idle timer (8 seconds in GP's post)

Lazy load: keep on making transmissions periodically, either waking up the
radio (and keeping it on for another 8 seconds) or outright never letting it
sleep (if you lazy load every 7 seconds or less)

------
graiz
Good find. They clearly know how to do push and in timing tests push
notification is well under a second if done correctly. Apple Push is stupid
fast. (probably a good separate post)

I suspect they are using a 3rd party push service and perhaps are trying to
save a buck when the app is open. Not sure why they don't just keep a socket
open?

~~~
mahyarm
For a company that's pretty push heavy, I'm surprised they didn't implement
their own push service, since they manage the chat room logs anyway. It isn't
complicated.

------
jarek
If only there was an established way, maybe a pattern, perhaps a device
service, for getting notifications without constantly doing an HTTP poll
request.

------
kalleboo
I thought this wasn't a valid use of multitasking by the App Store rules? Are
Apple just not policing multitasking use at all right now?

edit: does this fall under "Local notifications"?

> Multitasking apps may only use background services for their intended
> purposes: VoIP, audio playback, location, task completion, local
> notifications, etc.

This could also be seen as violating this

> Apps that provide Push Notifications without using the Apple Push
> Notification (APN) API will be rejected

~~~
eridius
They're not using multitasking. They're using the basic limited background
task functionality, whereby you can request additional time to complete
actions when closing the app. The system puts a hard limit on you at 10
minutes, at which point it will kill your app. This is designed for doing
things like saving data, posting that tweet the user just wrote, syncing
modified data to your server, etc. This app is abusing this functionality in a
very stupid way.

------
adamjernst
Huh, interesting. I'd bet that this is a bug.

The only other explanation I can think of is that push notifications can take
about 3-5 seconds to be delivered as they are routed through Apple's servers.
If these are long-poll HTTP requests directly to GroupMe's servers, then the
message would be delivered instantaneously.

~~~
RandallBrown
I filed a bug report with them about it awhile back before I knew what was
actually going on.

I'd much rather have that short delay than have my phone die after using it.
Right now I force kill GroupMe every time I leave it.

~~~
dkasper
It's not only the notification delay. They also do it so that the app doesn't
have to reconnect if you reopen it within 10 minutes.

~~~
eridius
That's a valid reason for using a background task, but it doesn't require
constantly polling the server.

------
art_vandelay
They do this because it allows them to then use local notifications for those
10 minutes to ensure delivery of the notification of a new message, this
reliability doesn't exist with push notifications.

Verbs, another instant messaging app for the iPhone, does the same thing.

~~~
RandallBrown
I figured that was what it was for, but it just doesn't seem worth it.

