Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find root cause Crashed: com.apple.main-thread in production app?

i have such a report from Crashlytics:

Thread : Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x000000019503fbd0 objc_msgSend + 16
1  CoreFoundation                 0x00000001836e5458 CFRelease + 524
2  CoreFoundation                 0x00000001836f1a18 -[__NSArrayM dealloc] + 152
3  libobjc.A.dylib                0x0000000195045724 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 564
4  CoreFoundation                 0x00000001836e9074 _CFAutoreleasePoolPop + 28
5  Foundation                     0x000000018461a588 -[NSAutoreleasePool release] + 148
6  UIKit                          0x00000001882b4460 -[UIApplication _run] + 588
7  UIKit                          0x00000001882aefac UIApplicationMain + 1488

Is there anything I can do to catch such an issue? It happens on customer devices so I have no chance to reproduce it.

like image 489
Arnie Schwarzvogel Avatar asked Jun 15 '15 21:06

Arnie Schwarzvogel


2 Answers

For crashes like this one, if the crash is reproducible, turn on NSZombies in your project's environment variables. This will keep deallocated objects alive (zombies) and when one of them is messaged, the caller and message will be captured on the crashing object.

Turn it off when done as it can block the memory of the app due to the objects not being released for zombie tracking.

like image 102
some_id Avatar answered Oct 04 '22 17:10

some_id


Some of logic code need to be run in background. You need to try debug where is code is error and then add this code

DispatchQueue.main.async(execute: {
     // your code
})
like image 20
Supanat Techasothon Avatar answered Oct 04 '22 18:10

Supanat Techasothon