I'm getting very strange crash at the start of the app. My app spawns a lot of threads (over 500, most of them are related to PLPreheatItem, I can not paste full crash log here, cause stackoverflow has limit to 30K symbols).
The problem is that I can not reproduce it on my device. Also it happens on clean install for my customer almost every run.
I am using NSURLSession with background session and NSOperationQueue with 4 concurrent operations. These are the most weak parts as I think.
Could someone suggest where do I need to dig. Cause I'm really have no idea what to do.
Thank you.
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
Ok, seems the issue is resolved.
At the start of the app I was creating PHCachingImageManager
and calling startCachingImagesForAssets:targetSize:contentMode:options:
. I was doing this for all iCloud assets that user have, so If you have a lot of assets to cache be careful just to start caching all of them immediately.
As the result PHCachingImageManager
spawned dozens of threads in serial queue for each asset separately. (more than 500 for my customer). So application finally run out of memory.
Here is workaround people do for this: How to use PHCachingImageManager