1

我在应用程序启动时遇到了非常奇怪的崩溃。我的应用程序产生了很多线程(超过 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
4

2 回答 2

0

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

您可能遇到了设备可以同时处理的最大线程数。在您构建堆或为屏幕分配后备存储之前,500 个线程仅用于应用程序的线程堆栈就转换为大约半 GB 的 RAM。在具有 512 MB RAM 的设备(iPhone 4S 及更低版本、iPod Touch 第 5 代及更低版本、iPad 2 及更早版本、iPad Mini 第 1 代及更早版本)上,无需祈祷它会工作。即使在较新的设备上,这也是可怕的滥用行为。

看起来这是由您使用 Apple 的照片框架所做的事情触发的。如果您正在做一些涉及查看大量图片或其他东西的元数据的事情,您应该添加延迟或其他东西来限制您这样做的速度。除此之外,除了在 bugreport.apple.com 上提交错误报告并希望获得最好的结果之外,您可能无能为力。

于 2016-10-29T01:12:23.933 回答
0

好的,看来问题已经解决了。

在应用程序开始时,我正在创建PHCachingImageManager和调用startCachingImagesForAssets:targetSize:contentMode:options:. 我正在为用户拥有的所有 iCloud 资产执行此操作,因此如果您有很多资产要缓存,请小心立即开始缓存所有资产。

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

这是人们为此做的解决方法:如何使用 PHCachingImageManager

于 2016-10-31T19:29:02.097 回答