iPhoto performs blocking network operations on the main thread

Originator:michael
Number:rdar://7705843 Date Originated:02-Mar-2010 11:40 AM
Status:Open Resolved:
Product:iApps Product Version:iPhoto 8.0.3
Classification:Performance Reproducible:Always
 
02-Mar-2010 11:40 AM Mike Tyson:
'iPhoto-Blocking.zip' was successfully uploaded

02-Mar-2010 11:40 AM Mike Tyson:
Summary: 
Upon startup, iPhoto performs blocking network operations on the main thread

Steps to Reproduce:
1. Start iPhoto
2. iPhoto hangs while network operation completes - this is particularly apparent on a slow internet connection

Expected Results:
Network operations occur on a thread, without blocking the interface

Actual Results:
Operations occur on the main thread, blocking the interface

Regression:
Unknown

Notes:
See attached 'sample' output, showing use of network operations on main thread.

Analysis of sampling iPhoto (pid 40953) every 1 millisecond
Call graph:
    8664 Thread_1576445   DispatchQueue_1: com.apple.main-thread  (serial)
      8664 0x349a
        8664 0x122f06
          8664 NSApplicationMain
            8664 -[NSApplication run]
              8664 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
                8664 _DPSNextEvent
                  8664 AEProcessAppleEvent
                    8664 aeProcessAppleEvent
                      8664 dispatchEventAndSendReply(AEDesc const*, AEDesc*)
                        8664 aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned long, unsigned char*)
                          8664 _NSAppleEventManagerGenericHandler
                            8664 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:]
                              8664 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:]
                                8664 -[NSApplication(NSAppleEventHandling) _handleAEOpen:]
                                  8664 -[NSApplication _sendFinishLaunchingNotification]
                                    8664 -[NSApplication _postDidFinishNotification]
                                      8664 -[NSNotificationCenter postNotificationName:object:]
                                        8664 -[NSNotificationCenter postNotificationName:object:userInfo:]
                                          8664 _CFXNotificationPostNotification
                                            8664 __CFXNotificationPost
                                              8664 _nsnote_callback
                                                8664 0x64cf7
                                                  8664 0x9eb77
                                                    8664 0x9d76e
                                                      8664 0xa8ccf
                                                        8664 0x27c86
                                                          8664 0x3724c
                                                            8664 0x35df4
                                                              8664 0x5ba7fb
                                                                8664 0x5ba9e5
                                                                  8664 0x500a12
                                                                    8664 +[NSString stringWithContentsOfURL:encoding:error:]
                                                                      8664 -[NSString initWithContentsOfURL:encoding:error:]
                                                                        8664 +[NSURLConnection sendSynchronousRequest:returningResponse:error:]
                                                                          8664 CFURLConnectionSendSynchronousRequest
                                                                            8664 CFRunLoopRunInMode
                                                                              8664 CFRunLoopRunSpecific
                                                                                8664 __CFRunLoopRun
                                                                                  8664 mach_msg
                                                                                    8664 mach_msg_trap
    8664 Thread_1576451   DispatchQueue_2: com.apple.libdispatch-manager  (serial)
      8664 start_wqthread
        8664 _pthread_wqthread
          8664 _dispatch_worker_thread2
            8664 _dispatch_queue_invoke
              8664 _dispatch_mgr_invoke
                8664 kevent
    8664 Thread_1576454
      8664 thread_start
        8664 _pthread_start
          8664 __NSThread__main__
            8664 -[NSThread main]
              8664 -[XTThread run:]
                8664 -[XTMsgQueue waitForMessage]
                  8664 -[NSConditionLock lockWhenCondition:]
                    8664 -[NSConditionLock lockWhenCondition:beforeDate:]
                      8664 -[NSCondition waitUntilDate:]
                        8664 pthread_cond_timedwait_relative_np
                          8664 _pthread_cond_wait
                            8664 semaphore_timedwait_signal_trap
    8664 Thread_1576474
      8664 thread_start
        8664 _pthread_start
          8664 __NSThread__main__
            8664 -[NSThread main]
              8664 -[XTThread run:]
                8664 -[XTMsgQueue waitForMessage]
                  8664 -[NSConditionLock lockWhenCondition:]
                    8664 -[NSConditionLock lockWhenCondition:beforeDate:]
                      8664 -[NSCondition waitUntilDate:]
                        8664 pthread_cond_timedwait_relative_np
                          8664 _pthread_cond_wait
                            8664 semaphore_timedwait_signal_trap
    8664 Thread_1576475
      8664 thread_start
        8664 _pthread_start
          8664 __NSThread__main__
            8664 -[NSThread main]
              8664 -[XTRunLoopThread run:]
                8664 -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
                  8664 CFRunLoopRunInMode
                    8664 CFRunLoopRunSpecific
                      8664 __CFRunLoopRun
                        8664 mach_msg
                          8664 mach_msg_trap
    8664 Thread_1576477
      8664 thread_start
        8664 _pthread_start
          8664 __NSThread__main__
            8664 -[NSThread main]
              8664 0x50074b
                8664 pthread_cond_wait$UNIX2003
                  8664 _pthread_cond_wait
                    8664 __semwait_signal
    8664 Thread_1576480
      8664 thread_start
        8664 _pthread_start
          8664 __NSThread__main__
            8664 -[NSThread main]
              8664 0x50074b
                8664 pthread_cond_wait$UNIX2003
                  8664 _pthread_cond_wait
                    8664 __semwait_signal
    8664 Thread_1576481
      8664 thread_start
        8664 _pthread_start
          8664 __NSThread__main__
            8664 -[NSThread main]
              8664 +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:]
                8664 CFRunLoopRunInMode
                  8664 CFRunLoopRunSpecific
                    8664 __CFRunLoopRun
                      8664 mach_msg
                        8664 mach_msg_trap
    8664 Thread_1576482
      8664 thread_start
        8664 _pthread_start
          8664 si_async_launchpad
            8664 si_addrinfo
              8664 search_addrinfo
                8664 _mdns_addrinfo
                  8664 _mdns_search
                    8664 _mdns_query_mDNSResponder
                      8663 kevent
                      1 _mdns_query_start
                        1 DNSServiceQueryRecord
                          1 deliver_request
                            1 read_all
                              1 recv$NOCANCEL$UNIX2003
                                1 recvfrom$NOCANCEL$UNIX2003
    8664 Thread_1576605
      8664 start_wqthread
        8664 _pthread_wqthread
          8664 __workq_kernreturn

Total number in stack (recursive counted multiple, when >=5):
        7       _pthread_start
        7       thread_start
        6       -[NSThread main]
        6       __NSThread__main__

Sort by top of stack, same collapsed (when >= 5):
        mach_msg_trap        25992
        __semwait_signal        17328
        semaphore_timedwait_signal_trap        17328
        kevent        17327
        __workq_kernreturn        8664






Analysis of sampling iPhoto (pid 40953) every 1 millisecond
Call graph:
    7953 Thread_1576445   DispatchQueue_1: com.apple.main-thread  (serial)
      7953 0x349a
        7953 0x122f06
          7953 NSApplicationMain
            7953 -[NSApplication run]
              7953 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
                7953 _DPSNextEvent
                  7953 BlockUntilNextEventMatchingListInMode
                    7953 ReceiveNextEventCommon
                      7953 RunCurrentEventLoopInMode
                        7953 CFRunLoopRunInMode
                          7953 CFRunLoopRunSpecific
                            7953 __CFRunLoopRun
                              7953 _ShortTimerCallBack(__CFRunLoopTimer*, void*)
                                7953 _netServiceDispatchCallbackForResolving
                                  7953 0xacf6
                                    7953 0xb0c6
                                      7953 0x69b4d
                                        7953 0x6a075
                                          7953 +[NSHost hostWithName:]
                                            7953 getnameinfo
                                              7953 si_nameinfo
                                                7953 search_host_byaddr
                                                  7953 _mdns_hostbyaddr
                                                    7953 _mdns_search
                                                      7953 _mdns_query_mDNSResponder
                                                        7953 kevent
    7953 Thread_1576451   DispatchQueue_2: com.apple.libdispatch-manager  (serial)
      7953 start_wqthread
        7953 _pthread_wqthread
          7953 _dispatch_worker_thread2
            7953 _dispatch_queue_invoke
              7953 _dispatch_mgr_invoke
                7953 kevent
    7953 Thread_1576454
      7953 thread_start
        7953 _pthread_start
          7953 __NSThread__main__
            7953 -[NSThread main]
              7953 -[XTThread run:]
                7953 -[XTMsgQueue waitForMessage]
                  7953 -[NSConditionLock lockWhenCondition:]
                    7953 -[NSConditionLock lockWhenCondition:beforeDate:]
                      7953 -[NSCondition waitUntilDate:]
                        7953 pthread_cond_timedwait_relative_np
                          7953 _pthread_cond_wait
                            7953 semaphore_timedwait_signal_trap
    7953 Thread_1576474
      7953 thread_start
        7953 _pthread_start
          7953 __NSThread__main__
            7953 -[NSThread main]
              7953 -[XTThread run:]
                7953 -[XTMsgQueue waitForMessage]
                  7953 -[NSConditionLock lockWhenCondition:]
                    7953 -[NSConditionLock lockWhenCondition:beforeDate:]
                      7953 -[NSCondition waitUntilDate:]
                        7953 pthread_cond_timedwait_relative_np
                          7953 _pthread_cond_wait
                            7953 semaphore_timedwait_signal_trap
    7953 Thread_1576475
      7953 thread_start
        7953 _pthread_start
          7953 __NSThread__main__
            7953 -[NSThread main]
              7953 -[XTRunLoopThread run:]
                7953 -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
                  7953 CFRunLoopRunInMode
                    7953 CFRunLoopRunSpecific
                      7953 __CFRunLoopRun
                        7953 mach_msg
                          7953 mach_msg_trap
    7953 Thread_1576477
      7953 thread_start
        7953 _pthread_start
          7953 __NSThread__main__
            7953 -[NSThread main]
              7953 0x50074b
                7953 pthread_cond_wait$UNIX2003
                  7953 _pthread_cond_wait
                    7953 __semwait_signal
    7953 Thread_1576480
      7953 thread_start
        7953 _pthread_start
          7953 __NSThread__main__
            7953 -[NSThread main]
              7953 0x50074b
                7953 pthread_cond_wait$UNIX2003
                  7953 _pthread_cond_wait
                    7953 __semwait_signal
    7953 Thread_1576481
      7953 thread_start
        7953 _pthread_start
          7953 __NSThread__main__
            7953 -[NSThread main]
              7953 +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:]
                7953 CFRunLoopRunInMode
                  7953 CFRunLoopRunSpecific
                    7953 __CFRunLoopRun
                      7953 mach_msg
                        7953 mach_msg_trap
    7953 Thread_1577131
      7953 thread_start
        7953 _pthread_start
          7953 si_async_launchpad
            7953 si_addrinfo
              7953 search_addrinfo
                7953 _mdns_addrinfo
                  7953 _mdns_search
                    7953 _mdns_query_mDNSResponder
                      7952 kevent
                      1 __spin_lock
    7953 Thread_1577145
      7953 thread_start
        7953 _pthread_start
          7953 0x2cf07c
            7953 0x2cf01b
              7953 0x2888b5
                7953 accept$UNIX2003
    7953 Thread_1577147
      7953 thread_start
        7953 _pthread_start
          7953 __CFSocketManager
            7953 select$DARWIN_EXTSN
    7953 Thread_1577155
      7953 thread_start
        7953 _pthread_start
          7953 __NSThread__main__
            7953 -[NSThread main]
              7953 -[XTRunLoopThread run:]
                7953 -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
                  7953 CFRunLoopRunInMode
                    7953 CFRunLoopRunSpecific
                      7953 __CFRunLoopRun
                        7953 mach_msg
                          7953 mach_msg_trap
    7953 Thread_1577156
      7953 thread_start
        7953 _pthread_start
          7953 __NSThread__main__
            7953 -[NSThread main]
              7953 -[XTRunLoopThread run:]
                7953 -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
                  7953 CFRunLoopRunInMode
                    7953 CFRunLoopRunSpecific
                      7953 __CFRunLoopRun
                        7953 mach_msg
                          7953 mach_msg_trap
    7953 Thread_1577157
      7953 thread_start
        7953 _pthread_start
          7953 si_async_launchpad
            7953 si_addrinfo
              7953 search_addrinfo
                7953 _mdns_addrinfo
                  7953 _mdns_search
                    7953 _mdns_query_mDNSResponder
                      7953 kevent
    7953 Thread_1577194
      7953 thread_start
        7953 _pthread_start
          7953 si_async_launchpad
            7953 si_addrinfo
              7953 search_addrinfo
                7953 _mdns_addrinfo
                  7953 _mdns_search
                    7953 _mdns_query_mDNSResponder
                      7953 kevent
    7951 Thread_1576605
      7951 start_wqthread
        7951 _pthread_wqthread
          7951 __workq_kernreturn
    2 Thread_1576605   DispatchQueue_7: com.apple.root.default-overcommit-priority  (serial)
      2 start_wqthread
        2 _pthread_wqthread
          2 _dispatch_worker_thread2
            1 _CFAutoreleasePoolPop
              1 pthread_self
            1 _CFAutoreleasePoolPush

Total number in stack (recursive counted multiple, when >=5):
        13       _pthread_start
        13       thread_start
        8       -[NSThread main]
        8       __NSThread__main__
        5       CFRunLoopRunInMode
        5       CFRunLoopRunSpecific
        5       __CFRunLoopRun
        5       kevent

Sort by top of stack, same collapsed (when >= 5):
        kevent        39764
        mach_msg_trap        31812
        __semwait_signal        15906
        semaphore_timedwait_signal_trap        15906
        accept$UNIX2003        7953
        select$DARWIN_EXTSN        7953
        __workq_kernreturn        7951

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!