App freezes once resume from breakpoint on simulator Xcode9 - deadlock/bug? - ios

Since moving to Xcode 9 I observe a strange behaviour while resuming from a breakpoint on Simulator.
My app uses multiple threads significantly, and some breakpoints are set in the code on different threads.
Once the app stops on a breakpoint and then is resumed (repeated a couple of times on different breakpoints)
it freezes eventually forever, which looks like a deadlock on a main thread:
UI is unresponsive
(however some UI animations are played) and the callstack shows __ulock_wait on the main thread.
In the same time
other background threads shows various actions e.g. on logging mechanism (CocoaLumberjack),
downloading pictures (Alamofire), etc.
This is not happening while testing on the same breakpoints on a device connected to the Xcode or on previous version of Xcode.
I've also tested the behaviour on one of many PODs' demo app used in the app with the same result.
Described behaviour brings debugging experience to annoying level and even breaks possibility to debug some part of the code completely.
Could anyone confirm a similar, unwanted behaviour?

Related

How to debug intermittent slow iOS iPhone app load times in Xcode?

I have an iOS Xcode project that previously would load fast, but from time to time, now will hang for five seconds or more during loading. When the app is run on an iPhone, the launch screen displays instantly, but sometimes, not always, and unpredictably, the app just hangs for around 5 seconds or more until the actual interface is displayed. It occurs both on the simulator and device across different iOS versions 7, 8, 9.
Recently, a UIView's class that contains a drawRect function was changed slightly, it has an outlet connection to one of the ViewControllers, but no significant changes made overall. One ViewController has code in the ViewDidLoad, ViewWillAppear, ViewDidAppear functions. All these things I'm investigating if they are impacting the load time.
When I terminate the app, the next time I try running it, it loads super fast without issue. I have no idea what to make of this load behaviour.
Questions
1 - What methods can I use in Xcode to debug an app that loads slowly at irregular and unpredictable times?
2 - What obvious items should I be on the look out in the project that typically cause slow or prolonged load times?
3 - Does Xcode include tools to monitor the processes operating live while loading occurs?
4 - Is it possible to print output for load processes I can review?
Any experienced advice really appreciated. Thanks.
Not sure if you have looked instrumentation. It is the best way to determine this kind of issues with your app.
https://developer.apple.com/library/watchos/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/index.html
When I terminate the app, the next time I try running it, it loads super fast without issue. I have no idea what to make of this load behavior.
Do you mean exiting the app? Or actually killing it? Cause if it is the former, then the reason is the app was just launched from a suspended state.
I would suggest take a closer look at didFinishLaunchingWithOptions:, and check if you are doing something that takes more time than needed. Run your app with the time profiler instrument, it will tell you where is your bottleneck.

Strange app crash when returning from background

This appears to be an iOS 8 problem only. I haven't seen it anywhere else, and it only happens on iOS 8. This is not local to my app, as it seems to affect nearly every app on my phone, including ones that haven't been updated to iOS 8. The crash is a EXC_CRASH (SIGABRT) which seems to trigger on random threads. The back trace is of no help of course because I can't re-symbolicate the crash reports from different builds and applications. So I decided to run my app in Xcode and recreate events that lead up to this crash. Essentially I just run my app so it's loaded, press the home button to switch to another app, do some stuff on my phone and return back to my app several seconds later. When I did get it to crash, and returned back to my app, instead of getting a SIGABRT and getting a stack trace, instead I get a SIGKILL and a (lldb) message in the console. This is strange because it does not crash while in the background but instead when returning to the foreground so any background process are uninterrupted. And because there is no stack trace, I have no idea why this is happening. To my knowledge, a SIGKILL is only given by Xcode when I press the stop button and when an app uses too much memory. Neither events occured. Has any one experienced this and/or solved it?

Objective c program behaving differently with and without breakpoints (XCode)

I am new to iOS development and i am facing an issue.
Putting breakpoints in my app before running the app in simulator is causing unexpected behavior.
If I put breakpoints in my app then I am not able to type in to text controls or click buttons i.e. it makes entire view read only.
If I disable the breakpoints, my app runs fine.
Any pointers to this issue will be really helpful.
Thanks
You are hitting a breakpoint which pauses execution of the main (UI) thread. Your application will not be able to process touch events when it is paused. Click the play button in Xcode to resume execution.

App crashes on regain focus

I am getting a strange behavior when I reopen my app after it loses focus from the home button. On the simulator the app screen goes black for 5 seconds or more before the application is resumed. On the test device, the application either does the long delay or quits entirely and resets to starting state. I have put NSLog debug comments in the “applicationWillEnterForeground” and “applicationDidBecomeActive” but these only appear after the long delay so I will assume for now that nothing in these functions cause this delay.
I am using the following components in my program:
* a Tab Bar Controller
* 2 Timers, the Map kit
* IP socket streams
* 24 ViewControllers strung together on a storyboard.
* quite a few background images and image buttons
I would happily post code if I know what parts of the program was causing this error, but as it is I am clueless. Has anyone else experienced this type of error? Do any of the components I have listed have a history of causing similar errors?
I was quite far in development when this bug was discovered and I did not test for loss of focus via home button during the incremental development process. Other, smaller projects (which used sockets and timers) did not suffer from the same bug on the same test hardware.
I am using “applicationWillResignActive” to disable the timers, and close the streams. I am using “applicationDidBecomeActive” to restart the timers, and reopen the streams. The delay is occurring before “applicationWillEnterForeground” and “applicationDidBecomeActive” is run. Further more I tried disabling the code that initiates the streams and timers, but this did not have any effect on the bug.
I am using xCode4.4.1, ios6, and am building exclusively for iPads.
It's possible that the debugger is playing tricks with your mind regarding when it shows that you hit a breakpoint and the code execution of applicationWillEnterForeground. I suggest you commit your most recent code to source control and start deleting sections one at a time till you see the behavior go away.

What are causes of freezing in an iOS app after returning from background?

This is very difficult issue, since it doesn't occur every time.
When an app is just launched, returning from background, it is fine without any freezing.
After some time being in background, when I re-activate it, the whole UI is frozen for while, even the activity indicator is not animating. As time goes on, this freezing gets longer and finally causes the app to be terminated by iOS for not resuming in time.
I would like to learn what are the generic causes of an app to be unresponsive, especially if the app is supporting background running feature and re-activating after a period of being in background.
It looks like I have missed some fundamental techniques that should be respected to avoid freezing problems.
UPDATE: I am suspicious if saving UIImage into Core Data object can be the main reason. At launch, it's not visible, however, as time passes, numerous saveManagedObjectContext are performed while UIImage is still referenced.
Maybe I should have listened to the instruction not to save any image in Core Data?
check for your crash log if you are getting this
Exception Codes: 0x8badf00d
then its most probably your application is taking much time either in launch or while moving in background or terminate, actually app take much time in launch/shut iOS suspend it and our app freeze, there is no such time define in documents but as i experienced it should not be more then 4-5 seconds. check your app delegate applicationDidFinishLaunch or multitasking delegates there is some code which is taking time in completion. For more info lokk at these
http://developer.apple.com/library/ios/#technotes/tn2151/_index.html
http://en.wikipedia.org/wiki/Hexspeak

Resources