Want to Help the show? Click here!
Amazon Affiliate, Donate,
Buy Logo Stuff & More

Past Episodes

Run Activity Monitor on iOS Using Instruments

This story starts as a tale about a failing iPhone battery but it turns into an awesome new tool to allow you to use Activity Monitor on your iPhone. But since I get to tell the story you’re going to hear about my iPhone battery first!

Instruments window showing fun graphsA few weeks ago, a gentleman named Scotty Loveless wrote a fabulous blog post about fixing iPhone battery problems. He speaks from experience, as he was an Apple Genius for almost two years. He developed this set of things to look for through experience. I like that the first thing he says is that this will not be one of those posts that says to turn off everything that makes an iPhone fun. You’ve read those, right? They say to turn the screen down till you can’t see it, turn off all your mapping applications, put your phone in airplane mode, and while you’re at it wrap it in bubble wrap and bury it in a kleenex box. I know these things work – my iPad battery lasted nearly two weeks on vacation when I couldn’t use the Internet on it the whole time!

I don’t want to steal his thunder because the post is so well written over at overthought.org. I have not been happy with my iPhone 5s battery so I went through the steps to see if they would help me. One of the main things he said was an indicator of battery weirdness is if you look at Settings/General/Usage and under Time Since Last Charge it shows the same number for Usage and Standby. In a normally functioning phone, these should be vastly different because presumably you allow your phone to sleep some of the time. In my case, both usage and standby were showing the same time.

I shot out a tweet to Scotty telling him that I enjoyed the blog post and that I had discovered that things were not altogether sorted on my phone. He then suggested I check out the tool Instruments that comes with Xcode. I don’t know Scotty so I figured I couldn’t be too needy and ask him to explain how to actually run Instruments, but I wasn’t entirely sure what the application was supposed to do or how I was to use it.

I should back up a smidge here. Xcode if you haven’t played with it, is the development environment for creating iOS and OSX applications. I’ve downloaded it and dabbled a bit with it, so I started poking around in the menus but I couldn’t find Instruments. I dug around in my Applications folder, and thought that maybe Xcode is actually a package file with other stuff inside. Apple seems to like hiding the juicy bits inside other things disguised by making them package files. I right clicked on Xcode, selected Open Package Contents an started drilling down. In there I found Contents/Applications (again) and in there I found six applications, one of which was called Instruments.

Ok, now we’re cooking with gas. Still don’t know what Scotty thinks I’ll do with it but I fired it up. From here on out I’m just going to pretend that I immediately knew what to do because the narrative will make more sense than if I keep saying things like, “I clicked a bunch of buttons and they didn’t work but this did something interesting”.

When you first open up Instruments, you’ll be struck by how similar it looks to Automator. You’re faced with a bunch of template trace documents, one of which is called Activity Monitor. This made sense to me since it’s with Activity Monitor on the Mac that we can see what’s chewing up processor power, so why not on the iPhone. When you choose Activity Monitor, you’ll see it in the left sidebar of the Instruments window, to the right you can see a timeline, across the top a display for where you are in time, and a big red record button in the upper left. None of these things will do anything until you choose your phone under the All Processes pulldown.

The problem you’ll see at first is that your phone will be greyed out in the list, with then words “not for development” next to it. That stumped me for a long time, but if you open up Xcode proper, look under the Window menu for Organizer. You’ll see your iOS device in the left sidebar and a button that says “Use for Development”. You’ll get a scary window that says you have to enroll in a developer program, but you can just cancel out of that. When you go back into Instruments, your device should be selectable now. And FINALLY you can start having some fun.

Once you’ve selected the iOS device you can hit the red record button and the timer display begins to advance. You’ll be treated to a very pretty graph growing on the timeline with different colors for the different processes that are running. On the bottom half of the screen you can see three bar graphs. There’s the % CPU, CPU Time, Real Memory Usage, and Real Memory again in a pie chart. It was particularly interesting to watch the process that were running while my iPhone was asleep!

I actually started telling this story to talk about my phone, but my discovery of Instruments was more exciting than my phone. I had so much fun with Instruments that I made a tutorial for you (of course I did) so you too can play around with it. I wanted to verify some of the steps so I enlisted Dorothy, aka @maclurker to run through the steps herself. She was super excited about it and immediately got her husband to come over and see how cool it is since he’s super geeky too. I’m sure you guys are going to love it!

podfeet.com/blog/tutorials-5/activity-monitor-for-ios-using-instruments-in-xcode

battery at 3% with only 5 hrs 32 min usageThe end of my iPhone story isn’t all that interesting, but for closure I’ll let you know where I am with it. I reset my phone to factory settings and restored to backup, but no joy. Finally I broke down and made a genius bar appointment, but that didn’t bring much joy either. The genius ran tests on the phone and found nothing wrong with the hardware. He said they’d give me a new phone if I wanted, but didn’t think it would fix anything. When I started talking to him, the battery went from 20% down to 4% so he definitely believed me at least. Then a second genius leaned over and had two interesting suggestions. First he noticed a geofencing symbol (that little arrow thingy) in the upper right. I’d not noticed that and he gave me a tip. He told me to look at Settings/Privacy/Location Services, and then look for the app that has a purple arrow. It turned out to be the Reminders app. For about a week my phone had reminded me every time I got home to record that TV show, but I kept forgetting to do it. He didn’t tell me not to use reminders, but he suggested it might be a cause.

The other suggestion was very curious. He said that sometimes hard drive backups can actually have the corruption that’s causing the battery to drain but for some reason the iCloud backups don’t pick up the same problems. He said it’s worth a try to reset again and this time choose iCloud. I haven’t done that just yet, but it’s on my list. If that doesn’t work, my only option (other than using a Mophie Juice Pack) is to do a reset and add all my apps back from scratch. That’s not my first choice because you do lose some data that way (like my awesome game score in 2048!) If I ever figure it out, I’ll be sure to let you know but don’t hold your breath on that one!

2 comments to Run Activity Monitor on iOS Using Instruments

  • Nice article. :)

    BTW there is a much easier way of launching Instruments. Pull down the Xcode menu (the one just to the right of the apple menu), go down to “Open Developer Tool”, and you will find Instruments right there and waiting for you. :)

    BTW, the Reminders app doesn’t use GPS when you ask it to remind you to do X when you get to home/work/etc. It uses “significant location monitoring” which is a technology that basically uses everything *but* GPS to roughly locate you. It does this using passive scanning technology, which uses MUCH less power than GPS – basically a negligible amount. (Besides, the iPhone is doing this type of scanning anyway (scanning for cell towers, etc.) so it is no additional drain on battery. So if you ask it to remind you to do X when you get home, well, it knows where your home address is (from your contacts entry). So as you drive around, it is looking at what cell towers, WiFi networks, etc. are around it. Eventually, it sees that, hey, you just entered Cell Tower THX-1138′s effective range. It knows that that cell tower is somewhere in your neighborhood. And, hey, look, I see “Sharon’s WiFi,” and “Pete’s WiFi” Because of the WiFi location database, it knows that these WiFi’s are on the same street where you live. Therefore it can be pretty sure that you are either at home, or nearing it. Pretty cool actually.

    This technology isn’t super accurate, it can only get an approximation of your location (probably within several hundred feet if I were to guess). But it’s good enough for things like Reminders reminding you of something when you get home or get to work, and so on.

  • Launching Xcode every time would be super annoying I think. Once you’ve opened Instruments on its own once, you can then launch from Spotlight or Alfred or even slap it in your dock for easy access.

    That’s interesting about Reminders, but I don’t completely buy it. Even if it doesn’t use GPS, it’s using something to check in to see if I’m home yet. You mention it looking at Wifi networks – that’s using power, isn’t it?

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>