简体   繁体   English

iOS中的NSLogger冻结了我的应用程序

[英]NSLogger in iOS freeze my app

I am integrate NSLogger into my iOS app, I found that after integrate NSLogger, My app become easy to freeze, especially when there is no internet. 我将NSLogger集成到我的iOS应用程序中,我发现在集成NSLogger之后,我的应用程序变得容易冻结,尤其是在没有互联网时。 I added code below to main.m, anyone know why? 我在下面添加了代码到main.m,有谁知道为什么?

Logger *logger = LoggerGetDefaultLogger();
LoggerSetOptions(logger,
                     kLoggerOption_BufferLogsUntilConnection |
                     kLoggerOption_CaptureSystemConsole |
                     kLoggerOption_BrowseBonjour |
                     kLoggerOption_BrowseOnlyLocalDomain);
LoggerSetupBonjour(logger, NULL, NULL));

this is crash log: 这是崩溃日志:

Incident Identifier: 5278EF6A-1128-49D6-B31A-B6AA03AC856C
CrashReporter Key:   848d8e4999dd36db808023480dc660a86c173fee
Hardware Model:      iPad6,7
Process:             My App [386]
Path:                /private/var/containers/Bundle/Application/579502B0-20F3-4C83-82F0-ED50BC79C831/My App.app/My App
Identifier:          com.xiang.My App
Version:             1140 (1.0)
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           com.xiang.My App [490]


Date/Time:           2016-11-18 13:41:18.1326 +0900
Launch Time:         2016-11-18 13:33:07.3810 +0900
OS Version:          iPhone OS 10.1.1 (14B100)
Report Version:      104

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          0x000000018e8d9948 writev + 8
1   CoreFoundation                  0x000000018f909cc0 _CFLogvEx2Predicate + 452
2   CoreFoundation                  0x000000018f909eec _CFLogvEx3 + 408
3   Foundation                      0x00000001903f0454 _NSLogv + 132
4   Foundation                      0x000000019031735c NSLog + 32
5   My App                          0x00000001000511a4 0x100030000 + 135588
6   My App                          0x0000000100050f2c 0x100030000 + 134956
7   My App                          0x000000010008b18c 0x100030000 + 373132
8   My App                          0x0000000100089530 0x100030000 + 365872
9   UIKit                           0x00000001958a7dc0 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 728
10  UIKit                           0x0000000195958b34 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 268
11  UIKit                           0x0000000195a0bd5c _runAfterCACommitDeferredBlocks + 292
12  UIKit                           0x00000001959fdb10 _cleanUpAfterCAFlushAndRunDeferredBlocks + 560
13  UIKit                           0x000000019576c854 _afterCACommitHandler + 168
14  CoreFoundation                  0x000000018f8d37dc __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
15  CoreFoundation                  0x000000018f8d140c __CFRunLoopDoObservers + 372
16  CoreFoundation                  0x000000018f8d189c __CFRunLoopRun + 1024
17  CoreFoundation                  0x000000018f800048 CFRunLoopRunSpecific + 444
18  GraphicsServices                0x0000000191286198 GSEventRunModal + 180
19  UIKit                           0x00000001957e52fc -[UIApplication _run] + 684
20  UIKit                           0x00000001957e0034 UIApplicationMain + 208
21  GroundStation Pro               0x00000001000f27b0 0x100030000 + 796592
22  libdyld.dylib                   0x000000018e7e45b8 start + 4

Firstly you should not be adding code to main.m . 首先,您不应该向main.m添加代码。 Look into placing code like this in your application delegate. 考虑在您的应用程序委托中放置这样的代码。

Secondly, the 0x8badf00d crash is a known error caused by your application taking too long to start. 其次, 0x8badf00d崩溃是由于您的应用程序启动时间太长而导致的已知错误。 This may be because you have the log start code in the wrong location as I've said above. 这可能是因为您将日志启动代码放在错误的位置,如上所述。 Or it may be something else. 或者它可能是别的东西。

As a general rule, anything you have in the startup of your application take may take time, should be either delayed or placed on a back ground thread. 作为一般规则,在启动应用程序时所拥有的任何内容都可能需要一些时间,应该延迟或放在后台线程上。 Application startup should get the user to the home screen of your app as soon as possible. 应用程序启动应尽快让用户进入应用程序的主屏幕。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM