1

My app got stuck for 15sec and then released, during this period complete UI got frozen and user can't click on anything. Its a production app and not reproducible in debug mode.

Is there any way to log the thread stack trace when app hangs (similar to ANR for Android)?

Shiva Reddy
  • 456
  • 1
  • 7
  • 26

2 Answers2

0

You can try to put exception breakpoint to you project / workspace.

Breakpoint tab

Go to Breakpoint tab on left pane and hit the plus(+) symbol on left side. And then just add exception breakpoint.

Exception breakpoint

Then you can also edit the breakpoint to have it only for Objc exceptions. You can reveal the reason the app crashes this way but it also can be caused by memory exception etc.

If you won't find an answer this way, you can try to use Instruments. Here is a good tut how to use it. `Ray Wenderlich - Instruments tutorial

Radim Halfar
  • 536
  • 2
  • 6
  • 15
  • Thanks Radim Halfar for the response. The above steps are helpful when we debug the app but I would like to log (kind of developer logging) the thread stack trace of production (Appstore) app. I am expecting something /data/anr/traces.txt file in Android. – Shiva Reddy Sep 08 '15 at 13:31
  • Then I can suggest you to use Crashlytics - Very nice and helpful framework. See more in here : [Crahlytics](https://try.crashlytics.com) Please see also @Candost Dagdeviren answer. – Radim Halfar Sep 08 '15 at 14:12
  • All I know about Crashlytics is it sends thread stack trace when an app is crashed, not sure whether it does the same even when app hangs for some time. Will check more, if you find any blog/doc please share. – Shiva Reddy Sep 09 '15 at 09:42
  • Crashlytics logs only when app crashed not when freezes. Can some one please let me know the possible solution. – Shiva Reddy Feb 15 '16 at 09:56
0

Connect your device to your computer. Open Xcode. On the tab bar there is a menu named "Window" select "Devices" option from it. On the left column, you will see your devices. Select your phone. On the same screen there will be a log console which outputs devices logs and user logs (written using NSLog)

To write your NSLog logs into a file you should write a custom method to do that. For this you can see this question there is a few ways to implement it. It'll be useful for you.

Community
  • 1
  • 1
Candost
  • 1,029
  • 1
  • 12
  • 28
  • Thanks Cadost Dagdeviren for the response. Does it logs when thread hangs for some time? How can we write that into a file programmatically say into the Developer log file stored in app's Documents/tmp folder. – Shiva Reddy Sep 09 '15 at 09:39
  • @ShivaReddy I updated the answer please check it. Also I'm not sure about it is logging when the thread hangs some time. I think, if the thread stuck you should be able to see some logs about stuck. – Candost Sep 09 '15 at 10:51
  • I am writing general screen navigation and action items network activity into a file stored in Documents folder so would like to write stuck thread trace as well to the same path if there is any way to get it. – Shiva Reddy Sep 09 '15 at 13:41