Why Does Pokémon Go Eat My Phone’s Battery?

Simple answer: it’s the GPS. The cool augmented reality stuff isn’t easy either, but shut that off—even flip your phone upside down for power-save mode—and GPS is still going to be the power hog. There are ways to alleviate that, but no way to stop it. We should know. We built an app that did the same thing two years ago.

Swag’r is a startup that combines geolocation with special offers and scavenger-hunt games to provide three channels of promotion: follow your map to a specific place at a specific time (channel one) and pick up a cool coupon or limited offer, completely free (channel two). You can swap or gift offers to your friends, as well (channel three!). The creators of Swag’r visualized it very much as a game that would provide a fun repeat experience and a challenge. Interesting game designs require strong constraints, which made the “yeah, you actually have to go there in real life” aspect crucial. Niantic Labs clearly had similar ideas with both their first game Ingress and with Pokémon Go, which provoked a lot of startled reactions back in July when people realized they couldn’t play this phone game from the couch.

As part of our discovery and design process, which continues throughout the lifetime of building an app, Swag’r performed several rounds of beta testing with randomly selected college students. The testers gave great feedback and an enthusiastic reception to the app, with one thing that particularly stood out: “this really wears out my battery!” We investigated several avenues for reducing power drain, some of which we were able to successfully incorporate. None of them came close to the power savings offered by simply leaving the app and returning to it when you wanted to grab an offer.

Many of us at DevelopmentNow are avid Pokémon Go players, so we were curious to see what steps Niantic had taken to circumvent the “keep it open, exhaust your phone” issue. And the answer is… they couldn’t solve it either! There’s just not a lot to be done about the physical limitations of battery power, distant beacons, and wandering players. Why is that, exactly? To understand the answer, we have to understand what’s going on with your phone’s GPS capabilities.

What exactly is GPS?

You probably know that GPS stands for Global Positioning System, and that it uses data from satellites to figure out your latitude and longitude. You might also know that the GPS satellites were launched starting back in the 1970s, and that they’re not actually doing the work to tell you where you are. A GPS satellite is just a very expensive clock radio. It spins around the Earth in a predictable orbit, holding a precise atomic clock, and broadcasts the current universal time on a particular frequency, over and over again. (It also syncs its clock with other satellites and base stations, and transmits an “almanac” of where all the other satellites should be.)

If you’re listening to those frequencies, and you know what time it is where YOU are, then microseconds of difference in the time you get from a satellite will tell you how far away it is. If you remember forgetting what you learned about trigonometry, like me, you can probably guess the next part: listen to another satellite, and another, and figure out how far they are too. (You have to have a “line of sight” to several satellites to do this—which is why GPS can get wonky when you’re surrounded by tall buildings!) Then solve a LOT of equations, account for the fact that relativity makes clocks in space go weird, figure out the one place where you could possibly be centered among them, and do some more math to place that point on the surface of a not-quite-spherical shape like the Earth. Congratulations! Your phone can now show you as a blue dot—or a Team Mystic trainer—on a map.

Meanwhile, back on Earth

GPS data is only available to civilians in a “coarse” frequency (more precise ones are restricted to military use), which leaves about ten meters of uncertainty as to where you actually are. Phones do lots of tricks to narrow it down further: figuring out your distance from known wi-fi base stations or cell towers, for instance, or guessing that if you’re moving at 60 miles per hour you’re PROBABLY on a road. But GPS is the core of all of that, and when it’s in use, it has to be powering its antenna constantly. To get good data from a distant signal, you have to either increase the power of the broadcast—which the satellites can’t do—or boost and filter what you get at the point of receipt. GPS signals are weak, so again, it’s your pocket computer doing the work. Work takes energy; energy comes from your battery; and maybe now it’s clearer why playing this game makes your phone so hot.

pokemon_passenger

By tracking your location over time, Pokémon Go also tries to establish how fast you’re going—so it knows whether you’re walking—and how far you’ve gone. But because of that radius of uncertainty, you may sometimes appear to wander around even when you’re standing still. For that reason, and to attempt to save some battery, the app only RECORDS your location at an interval, maybe a couple times a minute, and then draws lines between those points to measure. (This is why it sometimes seems like we’ve been cheated out of distance while trying to hatch eggs: the game literally cuts corners.)

This stuff is complicated! And it seems miraculous sometimes, whether you’re aware of its mechanics or not. But the power of that system lets us do all kinds of interesting things, like navigate our cars, or scavenger-hunt for free chicken strips, or catch invisible pocket monsters.

But wait, how do those chicken strips and Squirtles get placed on the map? Nobody told the satellites about them. To determine that, we have to understand another structure that Swag’r and Pokémon Go have in common: client-server protocol.

Client-Server Protocol

Even if you don’t work in tech, you probably know that a server is just a computer somewhere, plugged into the Internet and waiting for requests. When you search Wikipedia for an article, you’re making a request of a server, and getting back data in the form of a web page. When you open up an app and look for things around you, like coupons or Pidgeys, it’s the same process—but the data is coming back in a stripped-down format, like the popular, lightweight JSON. It might look like this:

YOU: “Hey server, it’s me, Brendan. Here’s a long, unique sequence of characters as proof. My latitude is 45.522756 and my longitude is -122.662958! What’s nearby?”

SERVER: “Hey, Brendan. Here you go.”

{ objects:
[
{
"name": "25% Off A $10 Purchase!",
"id": 2398739,
"lat": 45.522762,
"lon": -122.662944
"picture": "http://example.com/25-percent-coupon.jpg"
},
{
"name": "Zubat",
"id": 2398739,
"lat": 45.522759,
"lon": -122.662961
"CP": 142
}
] }

How does the server know those things are near you? It looks them up in a database, possibly by checking all points within an adjusted oblate spheroid surface based on the Haversine Formula. Or maybe by just calculating a square and cutting off the corners. Either way, this allows a distant server to maintain a relatively simple master list of all the things that can be found in its world, and only parcel out the relevant information to clients (like us!), who can then apply it to our surroundings.

Now, if you were interested in finding coupon codes outside your immediate range… well, the owners of those businesses probably wouldn’t mind too much as long as it got you in the door! But if you were trying to cheat at Pokémon Go by lying about your location, Niantic Labs wouldn’t be too happy, and indeed has been retaliating against suspected “spoofers” by banning their accounts. We wouldn’t know, as we’ve never tried it. Honest. Cross our hearts.

cough cough

There are a lot of interesting pieces underlying the design of games like these. The results can seem like magic when we’re exchanging excited shouts with strangers about finding a rare beast in the wild. But the more we examine the systems at work, the more intriguing they become. If you happen to be a Portlander who finds this stuff as fascinating to take apart and reassemble as we do, you might consider applying for Velocity, our 5 week accelerator program! New talent and inquisitive minds are always welcome here. Especially if you know a good place to catch Snorlax.

3