应用开始时的Ocassional崩溃

时间:2016-10-25 11:30:30

标签: grand-central-dispatch nsurlsession ios-multithreading

我在应用程序启动时遇到了非常奇怪的崩溃。我的应用程序产生了很多线程(超过500个,大多数都与PLPreheatItem有关,我不能在这里粘贴完整的崩溃日志,导致stackoverflow限制为30K符号)。

问题是我无法在我的设备上重现它。此外,它几乎每次运行都会在我的客户的干净安装中发生。

我正在使用带有后台会话的NSURLSession和带有4个并发操作的NSOperationQueue。这些是我认为最脆弱的部分。

有人可以建议我在哪里挖掘。因为我真的不知道该怎么做。

谢谢。

Incident Identifier: 3808D96D-CAA3-4DC3-9278-B1DF7CEFEF9D
CrashReporter Key:   0f11c86163cc36bdb756e72a5b65b3db93ad673d
Hardware Model:      iPhone8,1
Process:             ******** [1991]
Path:                /private/var/containers/Bundle/Application/87DD6538-DE78-4B6A-9834-58FF8C2AE22F/********.app/********
Identifier:          ********
Version:             75 (1.1.8)
Code Type:           ARM-64 (Native)
Parent Process:      launchd [1]

Date/Time:           2016-10-24 15:21:42.42 +0200
Launch Time:         2016-10-24 15:21:37.37 +0200
OS Version:          iOS 9.3.5 (13G36)
Report Version:      105

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000018171e7c4
Triggered by Thread:  40

Filtered syslog:
None found

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
0   libsystem_kernel.dylib          0x0000000181608fd8 mach_msg_trap + 8
1   libsystem_kernel.dylib          0x0000000181608e54 mach_msg + 72
2   CoreFoundation                  0x0000000181a40c60 __CFRunLoopServiceMachPort + 196
3   CoreFoundation                  0x0000000181a3e964 __CFRunLoopRun + 1032
4   CoreFoundation                  0x0000000181968c50 CFRunLoopRunSpecific + 384
5   GraphicsServices                0x0000000183250088 GSEventRunModal + 180
6   UIKit                           0x0000000186c56088 UIApplicationMain + 204
7   MyApp                           0x00000001000e1430 main (main.m:14)
8   libdyld.dylib                   0x00000001815068b8 start + 4

Thread 1 name:  Dispatch queue: PLPreheatItem
Thread 1:
0   libsystem_kernel.dylib          0x000000018162441c __semwait_signal + 8
1   libsystem_c.dylib               0x000000018154122c nanosleep + 212
2   libsystem_c.dylib               0x00000001815aa0b8 sleep + 44
3   libxpc.dylib                    0x0000000181733ca8 _waiting4memory + 16
4   libxpc.dylib                    0x000000018171f6d4 _xpc_mach_port_allocate + 92
5   libxpc.dylib                    0x000000018171f62c _xpc_connection_setup_reply_port + 40
6   libxpc.dylib                    0x000000018171f5ac xpc_connection_send_message_with_reply + 108
7   AssetsLibraryServices           0x000000018a6f2e18 -[PLGatekeeperClient cancelCPLDownloadImageDataWithVirtualTaskIdentifiers:completionHandler:] + 332
8   PhotoLibraryServices            0x000000018af023d0 __59-[PLPreheatItem cancelPreheatRequestWithCompletionHandler:]_block_invoke + 252
9   AssetsLibraryServices           0x000000018a6ec508 __pl_dispatch_async_block_invoke + 36
10  libdispatch.dylib               0x00000001814d54bc _dispatch_call_block_and_release + 24
11  libdispatch.dylib               0x00000001814d547c _dispatch_client_callout + 16
12  libdispatch.dylib               0x00000001814e14c0 _dispatch_queue_drain + 864
13  libdispatch.dylib               0x00000001814d8f80 _dispatch_queue_invoke + 464
14  libdispatch.dylib               0x00000001814e3390 _dispatch_root_queue_drain + 728
15  libdispatch.dylib               0x00000001814e30b0 _dispatch_worker_thread3 + 112
16  libsystem_pthread.dylib         0x00000001816ed470 _pthread_wqthread + 1092
17  libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 2 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 2:
0   libsystem_kernel.dylib          0x0000000181608fd8 mach_msg_trap + 8
1   libsystem_kernel.dylib          0x0000000181608e54 mach_msg + 72
2   libdispatch.dylib               0x00000001814e91dc _dispatch_mach_msg_send + 1716
3   libdispatch.dylib               0x00000001814e94d8 _dispatch_mach_send_drain + 236
4   libdispatch.dylib               0x00000001814e8968 _dispatch_mach_notify_merge + 308
5   libdispatch.dylib               0x00000001814da204 _dispatch_mach_notify_send_possible + 28
6   libdispatch.dylib               0x00000001814d5fec _Xmach_notify_send_possible + 52
7   libdispatch.dylib               0x00000001814d5adc libdispatch_internal_protocol_server + 104
8   libdispatch.dylib               0x00000001814ecfdc _dispatch_mach_notify_source_invoke + 28
9   libdispatch.dylib               0x00000001814edd48 _dispatch_kevent_mach_msg_recv + 280
10  libdispatch.dylib               0x00000001814e8730 _dispatch_mgr_invoke + 64
11  libdispatch.dylib               0x00000001814d7648 _dispatch_source_invoke + 0

Thread 3 name:  Dispatch queue: PLPreheatItem
Thread 3:
0   libsystem_kernel.dylib          0x000000018162441c __semwait_signal + 8
1   libsystem_c.dylib               0x000000018154122c nanosleep + 212
2   libsystem_c.dylib               0x00000001815aa0b8 sleep + 44
3   libxpc.dylib                    0x0000000181733ca8 _waiting4memory + 16
4   libxpc.dylib                    0x000000018171f6d4 _xpc_mach_port_allocate + 92
5   libxpc.dylib                    0x000000018171f62c _xpc_connection_setup_reply_port + 40
6   libxpc.dylib                    0x000000018171f5ac xpc_connection_send_message_with_reply + 108
7   AssetsLibraryServices           0x000000018a6f2e18 -[PLGatekeeperClient cancelCPLDownloadImageDataWithVirtualTaskIdentifiers:completionHandler:] + 332
8   PhotoLibraryServices            0x000000018af023d0 __59-[PLPreheatItem cancelPreheatRequestWithCompletionHandler:]_block_invoke + 252
9   AssetsLibraryServices           0x000000018a6ec508 __pl_dispatch_async_block_invoke + 36
10  libdispatch.dylib               0x00000001814d54bc _dispatch_call_block_and_release + 24
11  libdispatch.dylib               0x00000001814d547c _dispatch_client_callout + 16
12  libdispatch.dylib               0x00000001814e14c0 _dispatch_queue_drain + 864
13  libdispatch.dylib               0x00000001814d8f80 _dispatch_queue_invoke + 464
14  libdispatch.dylib               0x00000001814e3390 _dispatch_root_queue_drain + 728
15  libdispatch.dylib               0x00000001814e30b0 _dispatch_worker_thread3 + 112
16  libsystem_pthread.dylib         0x00000001816ed470 _pthread_wqthread + 1092
17  libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 4 name:  Dispatch queue: PLPreheatItem
Thread 4:
0   libsystem_kernel.dylib          0x000000018162441c __semwait_signal + 8
1   libsystem_c.dylib               0x000000018154122c nanosleep + 212
2   libsystem_c.dylib               0x00000001815aa0b8 sleep + 44
3   libxpc.dylib                    0x0000000181733ca8 _waiting4memory + 16
4   libxpc.dylib                    0x000000018171f6d4 _xpc_mach_port_allocate + 92
5   libxpc.dylib                    0x000000018171f62c _xpc_connection_setup_reply_port + 40
6   libxpc.dylib                    0x000000018171f5ac xpc_connection_send_message_with_reply + 108
7   AssetsLibraryServices           0x000000018a6f2e18 -[PLGatekeeperClient cancelCPLDownloadImageDataWithVirtualTaskIdentifiers:completionHandler:] + 332
8   PhotoLibraryServices            0x000000018af023d0 __59-[PLPreheatItem cancelPreheatRequestWithCompletionHandler:]_block_invoke + 252
9   AssetsLibraryServices           0x000000018a6ec508 __pl_dispatch_async_block_invoke + 36
10  libdispatch.dylib               0x00000001814d54bc _dispatch_call_block_and_release + 24
11  libdispatch.dylib               0x00000001814d547c _dispatch_client_callout + 16
12  libdispatch.dylib               0x00000001814e14c0 _dispatch_queue_drain + 864
13  libdispatch.dylib               0x00000001814d8f80 _dispatch_queue_invoke + 464
14  libdispatch.dylib               0x00000001814e3390 _dispatch_root_queue_drain + 728
15  libdispatch.dylib               0x00000001814e30b0 _dispatch_worker_thread3 + 112
16  libsystem_pthread.dylib         0x00000001816ed470 _pthread_wqthread + 1092
17  libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 5 name:  WebThread
Thread 5:
0   libsystem_kernel.dylib          0x0000000181608fd8 mach_msg_trap + 8
1   libsystem_kernel.dylib          0x0000000181608e54 mach_msg + 72
2   CoreFoundation                  0x0000000181a40c60 __CFRunLoopServiceMachPort + 196
3   CoreFoundation                  0x0000000181a3e964 __CFRunLoopRun + 1032
4   CoreFoundation                  0x0000000181968c50 CFRunLoopRunSpecific + 384
5   WebCore                         0x000000018595a108 RunWebThread(void*) + 456
6   libsystem_pthread.dylib         0x00000001816efb28 _pthread_body + 156
7   libsystem_pthread.dylib         0x00000001816efa8c _pthread_body + 0
8   libsystem_pthread.dylib         0x00000001816ed028 thread_start + 4

Thread 6:
0   libsystem_kernel.dylib          0x0000000181624b48 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x00000001816ed530 _pthread_wqthread + 1284
2   libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4
Thread 8:
0   libsystem_kernel.dylib          0x0000000181624b48 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x00000001816ed530 _pthread_wqthread + 1284
2   libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 9 name:  com.apple.NSURLConnectionLoader
Thread 9:
0   libsystem_kernel.dylib          0x0000000181608fd8 mach_msg_trap + 8
1   libsystem_kernel.dylib          0x0000000181608e54 mach_msg + 72
2   CoreFoundation                  0x0000000181a40c60 __CFRunLoopServiceMachPort + 196
3   CoreFoundation                  0x0000000181a3e964 __CFRunLoopRun + 1032
4   CoreFoundation                  0x0000000181968c50 CFRunLoopRunSpecific + 384
5   CFNetwork                       0x00000001820e9bcc +[NSURLConnection(Loader) _resourceLoadLoop:] + 412
6   Foundation                      0x000000018245fe4c __NSThread__start__ + 1000
7   libsystem_pthread.dylib         0x00000001816efb28 _pthread_body + 156
8   libsystem_pthread.dylib         0x00000001816efa8c _pthread_body + 0
9   libsystem_pthread.dylib         0x00000001816ed028 thread_start + 4

Thread 10 name:  com.apple.CFSocket.private
Thread 10:
0   libsystem_kernel.dylib          0x0000000181624344 __select + 8
1   CoreFoundation                  0x0000000181a471c8 __CFSocketManager + 648
2   libsystem_pthread.dylib         0x00000001816efb28 _pthread_body + 156
3   libsystem_pthread.dylib         0x00000001816efa8c _pthread_body + 0
4   libsystem_pthread.dylib         0x00000001816ed028 thread_start + 4

Thread 11:
0   libsystem_kernel.dylib          0x0000000181624b48 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x00000001816ed530 _pthread_wqthread + 1284
2   libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 12 name:  Dispatch queue: PLPreheatItem
Thread 12:
0   libsystem_kernel.dylib          0x000000018162441c __semwait_signal + 8
1   libsystem_c.dylib               0x000000018154122c nanosleep + 212
2   libsystem_c.dylib               0x00000001815aa0b8 sleep + 44
3   libxpc.dylib                    0x0000000181733ca8 _waiting4memory + 16
4   libxpc.dylib                    0x000000018171f6d4 _xpc_mach_port_allocate + 92
5   libxpc.dylib                    0x000000018171f62c _xpc_connection_setup_reply_port + 40
6   libxpc.dylib                    0x000000018171f5ac xpc_connection_send_message_with_reply + 108
7   AssetsLibraryServices           0x000000018a6f2e18 -[PLGatekeeperClient cancelCPLDownloadImageDataWithVirtualTaskIdentifiers:completionHandler:] + 332
8   PhotoLibraryServices            0x000000018af023d0 __59-[PLPreheatItem cancelPreheatRequestWithCompletionHandler:]_block_invoke + 252
9   AssetsLibraryServices           0x000000018a6ec508 __pl_dispatch_async_block_invoke + 36
10  libdispatch.dylib               0x00000001814d54bc _dispatch_call_block_and_release + 24
11  libdispatch.dylib               0x00000001814d547c _dispatch_client_callout + 16
12  libdispatch.dylib               0x00000001814e14c0 _dispatch_queue_drain + 864
13  libdispatch.dylib               0x00000001814d8f80 _dispatch_queue_invoke + 464
14  libdispatch.dylib               0x00000001814e3390 _dispatch_root_queue_drain + 728
15  libdispatch.dylib               0x00000001814e30b0 _dispatch_worker_thread3 + 112
16  libsystem_pthread.dylib         0x00000001816ed470 _pthread_wqthread + 1092
17  libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 13 name:  Dispatch queue: PLPreheatItem
Thread 13:
0   libsystem_kernel.dylib          0x000000018162441c __semwait_signal + 8
1   libsystem_c.dylib               0x000000018154122c nanosleep + 212
2   libsystem_c.dylib               0x00000001815aa0b8 sleep + 44
3   libxpc.dylib                    0x0000000181733ca8 _waiting4memory + 16
4   libxpc.dylib                    0x000000018171f6d4 _xpc_mach_port_allocate + 92
5   libxpc.dylib                    0x000000018171f62c _xpc_connection_setup_reply_port + 40
6   libxpc.dylib                    0x000000018171f5ac xpc_connection_send_message_with_reply + 108
7   AssetsLibraryServices           0x000000018a6f2e18 -[PLGatekeeperClient cancelCPLDownloadImageDataWithVirtualTaskIdentifiers:completionHandler:] + 332
8   PhotoLibraryServices            0x000000018af023d0 __59-[PLPreheatItem cancelPreheatRequestWithCompletionHandler:]_block_invoke + 252
9   AssetsLibraryServices           0x000000018a6ec508 __pl_dispatch_async_block_invoke + 36
10  libdispatch.dylib               0x00000001814d54bc _dispatch_call_block_and_release + 24
11  libdispatch.dylib               0x00000001814d547c _dispatch_client_callout + 16
12  libdispatch.dylib               0x00000001814e14c0 _dispatch_queue_drain + 864
13  libdispatch.dylib               0x00000001814d8f80 _dispatch_queue_invoke + 464
14  libdispatch.dylib               0x00000001814e3390 _dispatch_root_queue_drain + 728
15  libdispatch.dylib               0x00000001814e30b0 _dispatch_worker_thread3 + 112
16  libsystem_pthread.dylib         0x00000001816ed470 _pthread_wqthread + 1092
17  libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 14:
0   libsystem_kernel.dylib          0x0000000181624b48 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x00000001816ed530 _pthread_wqthread + 1284
2   libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 15 name:  Dispatch queue: PLPreheatItem
Thread 15:
0   libsystem_kernel.dylib          0x000000018162441c __semwait_signal + 8
1   libsystem_c.dylib               0x000000018154122c nanosleep + 212
2   libsystem_c.dylib               0x00000001815aa0b8 sleep + 44
3   libxpc.dylib                    0x0000000181733ca8 _waiting4memory + 16
4   libxpc.dylib                    0x000000018171f6d4 _xpc_mach_port_allocate + 92
5   libxpc.dylib                    0x000000018171f62c _xpc_connection_setup_reply_port + 40
6   libxpc.dylib                    0x000000018171f5ac xpc_connection_send_message_with_reply + 108
7   AssetsLibraryServices           0x000000018a6f2e18 -[PLGatekeeperClient cancelCPLDownloadImageDataWithVirtualTaskIdentifiers:completionHandler:] + 332
8   PhotoLibraryServices            0x000000018af023d0 __59-[PLPreheatItem cancelPreheatRequestWithCompletionHandler:]_block_invoke + 252
9   AssetsLibraryServices           0x000000018a6ec508 __pl_dispatch_async_block_invoke + 36
10  libdispatch.dylib               0x00000001814d54bc _dispatch_call_block_and_release + 24
11  libdispatch.dylib               0x00000001814d547c _dispatch_client_callout + 16
12  libdispatch.dylib               0x00000001814e14c0 _dispatch_queue_drain + 864
13  libdispatch.dylib               0x00000001814d8f80 _dispatch_queue_invoke + 464
14  libdispatch.dylib               0x00000001814e3390 _dispatch_root_queue_drain + 728
15  libdispatch.dylib               0x00000001814e30b0 _dispatch_worker_thread3 + 112
16  libsystem_pthread.dylib         0x00000001816ed470 _pthread_wqthread + 1092
17  libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 16:
0   libsystem_kernel.dylib          0x0000000181624b48 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x00000001816ed530 _pthread_wqthread + 1284
2   libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 17:
0   libsystem_kernel.dylib          0x0000000181624b48 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x00000001816ed530 _pthread_wqthread + 1284
2   libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 18:
0   libsystem_kernel.dylib          0x0000000181624b48 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x00000001816ed530 _pthread_wqthread + 1284
2   libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 19:
0   libsystem_kernel.dylib          0x0000000181624b48 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x00000001816ed530 _pthread_wqthread + 1284
2   libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 20:
0   libsystem_kernel.dylib          0x0000000181624b48 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x00000001816ed530 _pthread_wqthread + 1284
2   libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 21 name:  Dispatch queue: PLPreheatItem
Thread 21:
0   libsystem_kernel.dylib          0x000000018162441c __semwait_signal + 8
1   libsystem_c.dylib               0x000000018154122c nanosleep + 212
2   libsystem_c.dylib               0x00000001815aa0b8 sleep + 44
3   libxpc.dylib                    0x0000000181733ca8 _waiting4memory + 16
4   libxpc.dylib                    0x000000018171f6d4 _xpc_mach_port_allocate + 92
5   libxpc.dylib                    0x000000018171f62c _xpc_connection_setup_reply_port + 40
6   libxpc.dylib                    0x000000018171f5ac xpc_connection_send_message_with_reply + 108
7   AssetsLibraryServices           0x000000018a6f2e18 -[PLGatekeeperClient cancelCPLDownloadImageDataWithVirtualTaskIdentifiers:completionHandler:] + 332
8   PhotoLibraryServices            0x000000018af023d0 __59-[PLPreheatItem cancelPreheatRequestWithCompletionHandler:]_block_invoke + 252
9   AssetsLibraryServices           0x000000018a6ec508 __pl_dispatch_async_block_invoke + 36
10  libdispatch.dylib               0x00000001814d54bc _dispatch_call_block_and_release + 24
11  libdispatch.dylib               0x00000001814d547c _dispatch_client_callout + 16
12  libdispatch.dylib               0x00000001814e14c0 _dispatch_queue_drain + 864
13  libdispatch.dylib               0x00000001814d8f80 _dispatch_queue_invoke + 464
14  libdispatch.dylib               0x00000001814e3390 _dispatch_root_queue_drain + 728
15  libdispatch.dylib               0x00000001814e30b0 _dispatch_worker_thread3 + 112
16  libsystem_pthread.dylib         0x00000001816ed470 _pthread_wqthread + 1092
17  libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 22:
0   libsystem_kernel.dylib          0x0000000181624b48 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x00000001816ed530 _pthread_wqthread + 1284
2   libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 23 name:  Dispatch queue: PLPreheatItem
Thread 23:
0   libsystem_kernel.dylib          0x0000000181623f6c __psynch_mutexwait + 8
1   libsystem_pthread.dylib         0x00000001816f239c _pthread_mutex_lock_wait + 96
2   libsystem_pthread.dylib         0x00000001816f257c _pthread_mutex_lock_slow + 296
3   libsystem_c.dylib               0x000000018153b77c vfprintf_l + 36
4   libsystem_c.dylib               0x000000018153b748 fprintf + 76
5   libsystem_c.dylib               0x00000001815411ec nanosleep + 148
6   libsystem_c.dylib               0x00000001815aa0b8 sleep + 44
7   libxpc.dylib                    0x0000000181733ca8 _waiting4memory + 16
8   libxpc.dylib                    0x000000018171f6d4 _xpc_mach_port_allocate + 92
9   libxpc.dylib                    0x000000018171f62c _xpc_connection_setup_reply_port + 40
10  libxpc.dylib                    0x000000018171f5ac xpc_connection_send_message_with_reply + 108
11  AssetsLibraryServices           0x000000018a6f2e18 -[PLGatekeeperClient cancelCPLDownloadImageDataWithVirtualTaskIdentifiers:completionHandler:] + 332
12  PhotoLibraryServices            0x000000018af023d0 __59-[PLPreheatItem cancelPreheatRequestWithCompletionHandler:]_block_invoke + 252
13  AssetsLibraryServices           0x000000018a6ec508 __pl_dispatch_async_block_invoke + 36
14  libdispatch.dylib               0x00000001814d54bc _dispatch_call_block_and_release + 24
15  libdispatch.dylib               0x00000001814d547c _dispatch_client_callout + 16
16  libdispatch.dylib               0x00000001814e14c0 _dispatch_queue_drain + 864
17  libdispatch.dylib               0x00000001814d8f80 _dispatch_queue_invoke + 464
18  libdispatch.dylib               0x00000001814e3390 _dispatch_root_queue_drain + 728
19  libdispatch.dylib               0x00000001814e30b0 _dispatch_worker_thread3 + 112
20  libsystem_pthread.dylib         0x00000001816ed470 _pthread_wqthread + 1092
21  libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 24:
0   libsystem_kernel.dylib          0x0000000181624b48 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x00000001816ed530 _pthread_wqthread + 1284
2   libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4
Thread 36 name:  Dispatch queue: PLPreheatItem
Thread 36:
0   libsystem_kernel.dylib          0x000000018162441c __semwait_signal + 8
1   libsystem_c.dylib               0x000000018154122c nanosleep + 212
2   libsystem_c.dylib               0x00000001815aa0b8 sleep + 44
3   libxpc.dylib                    0x0000000181733ca8 _waiting4memory + 16
4   libxpc.dylib                    0x000000018171f6d4 _xpc_mach_port_allocate + 92
5   libxpc.dylib                    0x000000018171f62c _xpc_connection_setup_reply_port + 40
6   libxpc.dylib                    0x000000018171f5ac xpc_connection_send_message_with_reply + 108
7   AssetsLibraryServices           0x000000018a6f2e18 -[PLGatekeeperClient cancelCPLDownloadImageDataWithVirtualTaskIdentifiers:completionHandler:] + 332
8   PhotoLibraryServices            0x000000018af023d0 __59-[PLPreheatItem cancelPreheatRequestWithCompletionHandler:]_block_invoke + 252
9   AssetsLibraryServices           0x000000018a6ec508 __pl_dispatch_async_block_invoke + 36
10  libdispatch.dylib               0x00000001814d54bc _dispatch_call_block_and_release + 24
11  libdispatch.dylib               0x00000001814d547c _dispatch_client_callout + 16
12  libdispatch.dylib               0x00000001814e14c0 _dispatch_queue_drain + 864
13  libdispatch.dylib               0x00000001814d8f80 _dispatch_queue_invoke + 464
14  libdispatch.dylib               0x00000001814e3390 _dispatch_root_queue_drain + 728
15  libdispatch.dylib               0x00000001814e30b0 _dispatch_worker_thread3 + 112
16  libsystem_pthread.dylib         0x00000001816ed470 _pthread_wqthread + 1092
17  libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 37 name:  Dispatch queue: PLPreheatItem
Thread 37:
0   libsystem_kernel.dylib          0x000000018162441c __semwait_signal + 8
1   libsystem_c.dylib               0x000000018154122c nanosleep + 212
2   libsystem_c.dylib               0x00000001815aa0b8 sleep + 44
3   libxpc.dylib                    0x0000000181733ca8 _waiting4memory + 16
4   libxpc.dylib                    0x000000018171f6d4 _xpc_mach_port_allocate + 92
5   libxpc.dylib                    0x000000018171f62c _xpc_connection_setup_reply_port + 40
6   libxpc.dylib                    0x000000018171f5ac xpc_connection_send_message_with_reply + 108
7   AssetsLibraryServices           0x000000018a6f2e18 -[PLGatekeeperClient cancelCPLDownloadImageDataWithVirtualTaskIdentifiers:completionHandler:] + 332
8   PhotoLibraryServices            0x000000018af023d0 __59-[PLPreheatItem cancelPreheatRequestWithCompletionHandler:]_block_invoke + 252
9   AssetsLibraryServices           0x000000018a6ec508 __pl_dispatch_async_block_invoke + 36
10  libdispatch.dylib               0x00000001814d54bc _dispatch_call_block_and_release + 24
11  libdispatch.dylib               0x00000001814d547c _dispatch_client_callout + 16
12  libdispatch.dylib               0x00000001814e14c0 _dispatch_queue_drain + 864
13  libdispatch.dylib               0x00000001814d8f80 _dispatch_queue_invoke + 464
14  libdispatch.dylib               0x00000001814e3390 _dispatch_root_queue_drain + 728
15  libdispatch.dylib               0x00000001814e30b0 _dispatch_worker_thread3 + 112
16  libsystem_pthread.dylib         0x00000001816ed470 _pthread_wqthread + 1092
17  libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 38:
0   libsystem_kernel.dylib          0x0000000181624b48 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x00000001816ed530 _pthread_wqthread + 1284
2   libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 39:
0   libsystem_kernel.dylib          0x0000000181624b48 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x00000001816ed530 _pthread_wqthread + 1284
2   libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Thread 40 name:  Kernel bug: The kernel cannot allocate memory needed for the ps  Dispatch queue: com.apple.root.default-qos
Thread 40 Crashed:
0   libxpc.dylib                    0x000000018171e7c4 _xpc_connection_mach_event + 776
1   libxpc.dylib                    0x000000018171e7c4 _xpc_connection_mach_event + 776
2   libdispatch.dylib               0x00000001814d5578 _dispatch_client_callout4 + 16
3   libdispatch.dylib               0x00000001814d9864 _dispatch_mach_msg_invoke + 656
4   libdispatch.dylib               0x00000001814e1694 _dispatch_queue_drain + 1332
5   libdispatch.dylib               0x00000001814d8978 _dispatch_mach_invoke + 600
6   libdispatch.dylib               0x00000001814d547c _dispatch_client_callout + 16
7   libdispatch.dylib               0x00000001814e3914 _dispatch_root_queue_drain + 2140
8   libdispatch.dylib               0x00000001814e30b0 _dispatch_worker_thread3 + 112
9   libsystem_pthread.dylib         0x00000001816ed470 _pthread_wqthread + 1092
10  libsystem_pthread.dylib         0x00000001816ed020 start_wqthread + 4

Activity ID:             0x0000000000156343
Activity Name:           starting resolver activity
Activity Image Path:     /usr/lib/system/libsystem_network.dylib
Activity Image UUID:     A8E4200A-ECC7-3E56-A845-8A0E9CB4A6F0
Activity Offset:         0x0003333c
Activity Running Time:   5.357751 sec

2 个答案:

答案 0 :(得分:0)

错误消息被截断。显然"内核无法分配伪接收所需的内存。"

您可能遇到设备可以同时处理的最大线程数。在您构建堆或为屏幕分配后备存储之前,500个线程仅为您的应用程序的线程堆栈转换为大约半千兆字节的RAM。在具有512 MB RAM(iPhone 4S及更低版本,iPod Touch第5代及更低版本,iPad 2及更早版本,iPad Mini第1代及更早版本)的设备上,没有任何祈祷可以使用。即使在较新的设备上,这也是可怕的辱骂。

看起来这是由您在Apple的照片框架中所做的事情引发的。如果您正在执行涉及查看大量图片或其他内容的元数据的内容,则应添加延迟或某些内容以限制执行此操作的速率。除此之外,除了在bugreport.apple.com上提交错误报告并希望获得最佳效果之外,您可能无能为力。

答案 1 :(得分:0)

好的,问题似乎已经解决了。

在应用开始时,我创建了PHCachingImageManager并致电startCachingImagesForAssets:targetSize:contentMode:options:。我正在为用户拥有的所有iCloud资产执行此操作,因此,如果您有很多要缓存的资产,请注意立即开始缓存所有这些资产。

结果PHCachingImageManager分别为每个资产在串行队列中产生了数十个线程。 (我的客户超过500)。因此应用程序最终耗尽内存。

以下是人们为此做的解决方法:How to use PHCachingImageManager