Using Shark to profile an iPhone game, pressing "Start" doesn't do anything - iphone

I've done a decent amount of reading about how to profile iPod applications using Shark, and all works well until I try to click "Start" (and nothing happens). I've tried profiling an individual process (app), all processes, and it doesn't seem to Start. This tutorial is one place that I used to set it up (so I think I'm following all the steps):
http://rudifa.wordpress.com/2009/09/16/profiling-an-iphone-application-with-shark/
(I've also rebooted my mac and iPod)
Anyone have any ideas on what to try next?

Shark support has been dropped on iOS 4. Official Apple position can be seen here:
https://devforums.apple.com/message/243237
They expect you to use Instruments and Time Profiler instead.

Have you tried the Time Profiler instrument? Apple seems to be moving in that direction.

Related

Profiling a running iOS app without a computer attached

I would like to profile a running app without a computer attached. Pretty much what the sample command does on Mac OS X. Is it possible ?
I would like to do this without any computer attached because my app gets into an endless loop only at certain GPS locations. I tried reproducing the problem by faking GPS fixes but I couldn't. Yet the issue is 100% reproductible in the field…
You can try logging suspected method and loop entry/exits to a file, and recover the file later using iTunes Document sharing or Xcode.
No - I'm pretty sure it isn't, as Apple does not allow developers to use any iOS-development tools on the platform itself. You might be able to build analytical stuff into your own app (RAM monitor etc.), but not by using another app.
Anyway, your computer is much better suited to the task than a device - so sick with it.
Maybe some day Apple will let us test/write iPhone apps from iPads...

iPhone 4 profile power consumption (with instruments)

I have an app that I added a lot of animation to. The app also used "iPhone sleep preventer" to play silent audio. Since then, I noticed that the battery consumption increased by up to 4 times! I'd like to find a method to profile the power consumption (I think I saw an option in Instruments) to find and eliminate the offending method(s).
Where would I start looking for information like this? Currently I have the phone left on the desk for ~3 hours to record power drain over time. Is there a better method to predict when the app will run out of power if running my app continuously?
An extra side question: are the % of battery left displayed in the status bar linear or is there some non-linearity towards the end of the battery life?
Edit: I found a "power" preset in xcode>product>profile>CPU>Energy diagnostics. It doesn't seem to work perfectly, as the power consumption level is always 0/20. But it does tell me how much of the CPU time is spent on app foreground, graphics and music!
Now I dont know how the CPU power is managed, is running the CPU at 75% more power consuming than lets say 30%? Intuitively it feels like it should...
Thank you!
I'm no expert. Im fact I am only starting to power profile a iphone today, and looked upon your question here in hope off learning.
So I will share with what I've found in meanwhile.
On IOS Developer Library I have found the following:
Connect the device to your development system.
Launch Xcode or Instruments.
On the device, choose Settings > Developer and turn on power logging.
Disconnect the device and perform the desired tests.
Reconnect the device.
In Instruments, open the Energy Diagnostics template.
Choose File > Import Energy Diagnostics from Device.
And you have a report of Cpu and energy during the time of the log.
You can find this steps and many more info on this section of the IOS Dev. lib.
I am still a bit fresh on this matter, so if you find anything that you think is meaningful please post that info here.
Edit: The apple dev lib suffered some changes. Updated link

How to bind Shark to an running iPhone app on the device?

I was reading at an apple site that shark captures everything that is running on my mac. Thats stupid. I want it to be constrained only to my iPhone app on the device, but there's just nothing to select the executable or something like that. Also in xcode, "Run > Run with Performance Tool > Shark" is grayed out. But shark 4.6x is running.
Are there any videos (except the WWDC stuff for 1500 bucks) that show how to use Shark with an iPhone app on a device? (I mean how to analyze performance while an app runs on the device)
If you create your symbols manually, according to this doc, Shark will show the application name instead of the address space, according to this doc. Don't know of any videos, but that second document should walk you through it pretty clearly.
Basically, in Shark, select Sampling > Network/iPhone profiling (shift-command-N).

Game crashes on the actual iPhone but simulator? memory problem?

I have built my first game using Cocos2D. It worked fine on the simulator. But when it runs on the actual iPhone, it crashes. I don know why. Thought it was memory leaks, so i tried to detect, but no leaks found. I tried to increase and decrease frame rate, neither both succeeded. Anyone experienced please help me out. I am really stressed now. If anyone had the same issue please share with me your opinion.
Yours thanksfully.
I've run into similar issues (I also use Cocos, but I don't think this is Cocos specific). The best thing to do is plug-in your iPhone and watch the stacktrace when it crashes (or retrieve the stacktrace after the fact)
This happened to me a lot because the resources between the iPhone and the simulator were not in sync; in other words, some how resources would be available to the simulator (eg: images) but those same resources were not transferred to the iPhone for whatever reason. Sometimes, if I ran 'clean' on the simulator, I would observe the same issue.
It's extremely frustrating to debug these types of issues, but you'll get used to it.
I agree with Dominic - we definitely need more information to be able to help you - do you have the output from the console or the stack from the debugger?
Also, while memory leaks are a Bad Thing, they rarely lead to crashes directly. They will increase the amount of memory used by your app so if you're memory intensive then you might get a problem but they're not the first place I'd look to try to debug this.
Try running the app in Instruments and watch the memory usage graph - then not only can you see the total that your app is using but you can get an idea of which sections of your app use the most and can focus your efforts in reducing it.
Sam
Sorry, but you need to specify more details. How does it crash? What does the error log say? One thing you might look into is the amount of memory, your game consumes. If it uses more than 64 MB on the actual device, the OS will very likely just terminate it. In the simulator on the other hand, your app might use lots more memory without a problem.
I have found tools like Instruments and NSZombieEnabled to be very helpful in tracking down issues such as these.
Without more information, I would try the following steps:
Delete the app from the device and simulator (using the tap-and-hold technique to make your icons jiggle) and reinstall it. Sometimes a setting (or lack of a setting) in the user defaults will cause a crash, and those don't get wiped out unless you delete and re-run your app.
Also try the "simulate memory warning" option in the simulator and see if that gets it to crash.

Debugging j2me on a Device

Has anybody had any success ever attaching a debugger to a tethered device? I am able to debug my j2me application in the emulator, but have a lot of trouble sorting out phone-specific problems when they come up. The phone I'm using is a Nokia N95, but ideally the debug process would work on any phone.
Is this possible? If so does anyone have steps they've used to set it up?
Sony Ericsson supports debugging on ebery phone at least since K700, this is done by using KDWP. UIQ 3 communicators also can be debugged the same way.
By the way, it the latest phones by SE it is even possible to monitor memory consumption and CPU profiling. So if you wanna debug your apps on real phones, I would suggest also using SE phones, they are really good at it. I use Netbeans, and it works without any problems with any SE phone.
Motorola phones support a debugging interface called KDWP(Motodev registration required).Their MIDway tool can also be useful for getting debug trace information from a midlet running on a device.
As other stated, on device debug is something that strictly depends on manufacturer's will and often it's nearly impossible. However, i can address you to Gear Java Mobile Framework that gives you the opportunity to use an on-device debug console to print your messages and thus read phone specific issues. If you need some explanation on how to use it, take a look to this tutorial
Unfortunately this is not generally possible. Some makers (like Sony-Erricson) support this on some of their phones but not all. I am not sure if there is on-device-debugging tool for N95 but you can use Nokia's emulator which should be pretty close to the device. The new Java ME SDK comes with promise of real ODD in near future. But it still very much depends on OEM cooperation.
I find a good debugging method is to control a string value which gets painted on top of everything else when it is not null. This will work anywhere, though obviously isn't ideal, but can be used to catch Exceptions, print values etc. Of course you're limited to the small screen, but in theory you could even code some scrolling functionality.
Some people use RMS logging but personally I could never be bothered.
As others have said here, Motorola have Midway which I think is great.
Others are correct here in that on-device debugging is very much device specific. I haven't done anything with Series 60, but at least on Series 40 phones, I had to open up a CommConnection and write out to it in order to see much of anything going on. The device emulators are again a mixed bag, but you usually can get 90% of the way to your application working on them and can usually get your debugger connected to them. If you aren't making use of any of the hardware on the phone, that should get you most of the way there.
I've used the Blackberry tools on occasion to debug J2ME applications (without using RIM APIs) but it is very slow and still is only emulation, not the actual device (but it sometimes does help to shake the odd thing out). I agree it is frustrating when you have something running on an emulator only to find that it doesn't run on the hardware.
You can not debug step by step like android or other SDK.
In J2ME you can trace the error by adding the log statement in the code and add another midlet and display that log screen in that midlet.
Example: add Log.p("Log statement.....");
LogMidlet.java
// Add the following line in the startup method of this midlet.
Log.getInstance().showLog();
This way you can somehow track the error in j2me.
I think it is possible to add additional debugging information on preprocess step. Like this:
public void myMethod() {
Debug.traceMethod("myMethod");
int var = 1;
Debug.newLine();
var++;
Debug.newLine();
...
}