Finding performance-related release-only bugs in Cocoa - objective-c

I am currently developing a project and I'm working in debug during development.
Typically, I'm just working in release mode before I am releasing the next update to check if everything works as expected.
During the last release tests, I found a bug that just appears in release mode.
As soon as I set the optimization level to 1 or higher (I'm using LLVM 4.2), the bug starts to appear.
I don't have any clue what the error could be related to.
Does anyone have an idea what I could do to find the reason of the error?
Instruments maybe? Didn't find a mode that would fit.
It's a performance-related error and I can't seem to find it with breakpoints.
My first guess is that the main thread is running full so that not all events can be processed in time.
If that was it, why would that not happen in debug mode?

Related

Titanium NSInvalidArgumentException

I'm trying to build a crossplatform (Android-ios) mobile application, using Titanium SDK. I didn't have a chance for a long time to build it for ios, I only used my Windows-android combination, to test it, and it works great on the Android system. But when i try to build it on the mac for the ios, i get this message, and the application shuts down in a second:
The application has crashed with an uncaught exception
'NSInvalidArgumentException'.
Since i can not provide any relevant code, because the exception doesn't show what's the problem with my javascript code, and I certainly didn't write any native, ios specific code, i have no idea, what to do.
From the few posts i have found here is what i have tried:
Restart Titanium Studio
Clean the project
Made sure to close any ResultSet, and DB objects when done with
them (as suggested here: topic)
Test the code on both 3.0.0 and 2.x.x versions
I'm looking forward to any advice, on how you solved this problem, if you had it!
Thanks in advance!
Update:
The problem was the following: I called hasOwnProperty on Titanium UI elements, and on the ios version these elements don't have this function (which is weird, since every javascript objects have it, if i'm not mistaken).
If you have similar problems, i recomend reading this article, besides mr.VVoos answer, it helps a lot in avoiding the problems i had!
I'm developing with Titanim and iOS & Android for a long time. Usually there are many differences between iOS and Android parts of the code.
In most cases this exceptions means that an operation is called that is not available for the called class. (In Java this would mean: Class.method() -> Class has no method called method()).
You can try to run the app in debug mode (on iOS Simulator). There is a big advantage debuggin iOS compared to Android. Usually the iOS simulator stops if there is an exception and it shows the JavaScript code that caused the exception. Unfortunately this doesn't work all the time and it only works on simulator.
If this does not provide any further information you can do the following:
- go to your app.js and set a breakpoint in one of the first lines.
- start app in debug mode.
- move on this breakpoint each time until your app crashes - maybe then you are able to detect the error or provide further information.
One last tip: Check your code if there are any platform-specific parts. (Like Android Intents and something that is not available on iOS).
I know that this can be very ugly but we had to solve many of these nasty issues while migrating from iOS to Android.

Accidental delete iOS framework

So i have been having the hardest time getting my iphone application approved. And i sorta when on a little rampage through some of my code.
In my shear stupidity I thought that maybe I did not need the SenTestingKit.framework. So i attempted to remove it from my program, and when asked if i would like to delete or remove references i accidently clicked delete.
However upon reviewing some crash logs PRE-Deletion of SenTestingKit.framework I found the following...
Again this error was before I deleted the framework. The crash code to this is 0xe7ffdefe
Could someone please tell me where i might get the sentestingkit.framework from? And also if you have anyidea why it is causing the crash that would be so amazing to hear.
Thanks!!!
To restore that framework, just re-install Xcode. Or maybe your trash still has it.
About the iOS devices that complain about not finding the SenTestkingKit: I'd assume so, as it's a Xcode-only framework used for test cases. You aren't supposed to link it when distributing the app. Why would the user want to run test cases?

How to debug crash in reference project?

I have a project in which I'm taking reference of another library. I have changed something in the classes of reference project. How do i find that crash is occurring because of the changes. Gdb shows nothing when application crashes.
The simpliest way i see is testing without the changes you made, and see if the app is still crashing...
If you find out the modifications are not the source of crash, post some code, it will be better to solve your problem.

Help diagnosing crash in Cocoa framework - possible memory leak?

I'm currently migrating the Fragaria framework from a GC-only environment to GC being supported. After the work was done (or what I thought had to be done to make it work) I was able to run the examples that come with the framework without any problems and Instruments didn't show any major memory leaks.
I included non-GC Fragaria in my non-GC application and it crashes as soon as I place the cursor on it. To be honest the usage pattern is different from the examples as I'm embedding it in an instance of NSViewController instead of NSDocument.
Can you give me some tips on how to debug this? I'm a bit lost on where to proceed now.
First thing to do is Build and Analyze the code, then fix any problems it finds.
Next, try running with Zombie detection enabled (google NSZombie).
Finally, each crash's stacktrace should give you a pretty good idea where things have gone off the rails.

iPhone Simulator is slow compared to device

I've been working on a new app, and when I run it on the simulator, it's VERY slow. There's nothing fancy in the app, just UINavigationControllers and text. The slowness only occurs if I launch the app from Xcode (with or without debugging on, doesn't matter). If I run the app on my iPhone or launch it directly from the simulator by clicking it's icon from SpringBoard, the performance problems all disappear.
For what it's worth, all my other apps perform just fine when run launched from Xcode in the simulator, so it must be something specific to this app. Has anyone experienced this before?
UPDATE: There is no performance hit when the app is run through Instruments either. I'm not using any 3rd party libraries. It's all calls to the Apple SDK.
Thanks,
Arash
Have you looked at it in Instruments to see where it's spending its time? No reason to guess when you can test.
Running an app in the simulator while in active debugging will always make the app slower. Always, and in a way that is exactly what you are describing.
Basically, "Build and Go" will be slow because its running the debugger.
This is different from "Debug" vs. "Release". The debug build will run fast if you aren't actually debugging it.
Are you using NSLog() to print a large amount of information? When you launch through Xcode, that information is piped to the debugging console and, if there's a lot, will take time to update the window. When you launch directly or on the device, the data is simply stored in a file, which generates less overhead.
I once reduced a program's run time from several minutes to a few seconds simply by removing logging statements. Unfortunately, it was for a timed programming contest.
I had the exact same problem and spent about 2hrs now to solve it. In my case I think it was because I had "Enable Guard Malloc" set. If it wasn't that, my other guess is bad karma.
Simulator Debug, You should need to be ensure when your app running on simulator debug->slow animations isn't check marked