modo-studio/SugarRecord

watchdog kill app when using CoreDataDefaultStorage in applicationDidBecomeActive

tonnylitao opened this issue · 1 comments

App crash when launch after iOS system updated

Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d
Triggered by Thread: 0

Filtered syslog:
None found

Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x000000018ef7d188 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x000000018ef7cff8 mach_msg + 72
2 CoreFoundation 0x000000018ff7a5d0 __CFRunLoopServiceMachPort + 192
3 CoreFoundation 0x000000018ff781ec __CFRunLoopRun + 1132
4 CoreFoundation 0x000000018fea62b8 CFRunLoopRunSpecific + 444
5 GraphicsServices 0x000000019195a198 GSEventRunModal + 180
6 UIKit 0x0000000195eed7fc -[UIApplication _run] + 684
7 UIKit 0x0000000195ee8534 UIApplicationMain + 208
8 MyApp 0x000000010003ec2c main (CoreDataDefaultStorage.swift:19)
9 libdyld.dylib 0x000000018ee895b8 start + 4

Context

I initial CoreData db with SugarRecord in applicationDidBecomeActive(). From the crashlog, it seems CoreDataDefaultStorage initial takes too much time to launch app. And system watchdog kill it.

Any suggestions? Should I initialise db in other places rather in applicationDidBecomeActive?

@TonnyTao it shouldn't be in applicationDidBecomeActive because this method is called every time the app comes from the background. You should add it to applicationDidFinishLaunching, that is called when the the app is first opened.