Fully-loaded global concurrent queue hangs NSXPCConnection and Cocoa UI
| Originator: | matt.mower | ||
| Number: | rdar://10490954 | Date Originated: | 28/11/2011 |
| Status: | Open | Resolved: | |
| Product: | MAC OS X | Product Version: | 10.7.2 |
| Classification: | Hang | Reproducible: | Always |
28-Nov-2011 05:34 PM Matt Mower: 'TestGCD.zip' and 'Shaddam.spx' were successfully uploaded 28-Nov-2011 05:34 PM Matt Mower: Summary: Using a queue with DISPATCH_QUEUE_CONCURRENT can hang your applications Cocoa UI when you mouse into the menu. Steps to Reproduce: Schedule a number of high-CPU blocks onto the queue. At the point where the queue is fully loaded try to use the menubar of the application. The main thread will get blocked and the app will beach-ball. PLEASE SEE EXAMPLE PROJECT ATTACHED. Expected Results: No blockage on the main thread. Actual Results: The main thread is blocked until the queue has finished processing all queued blocks. Here's the stack trace: #0 0x00007fff8e4936b6 in semaphore_wait_trap () #1 0x00007fff8965a03e in _dispatch_semaphore_wait_slow () #2 0x00007fff8f7b72c9 in -[NSXPCConnection sendMessage:waitForAck:] () #3 0x00007fff8f782852 in _CFXNotificationPost () #4 0x00007fff8f793da8 in CFNotificationCenterPostNotification () #5 0x00007fff924b584a in HIS_XPC_CFNotificationCenterPostNotification () #6 0x00007fff8f4b5f2f in BroadcastToolboxMessage () #7 0x00007fff8f4279ef in SendMenuOpening(MenuSelectData*, MenuData*, double, unsigned int, unsigned int, __CFDictionary*, unsigned char, unsigned char*) () #8 0x00007fff8f42aff5 in DrawTheMenu(MenuSelectData*, __CFArray**, unsigned char, unsigned char*) () #9 0x00007fff8f42b4ff in MenuChanged(MenuSelectData*, unsigned char, unsigned char) () #10 0x00007fff8f2fccaf in TrackMenuCommon(MenuSelectData&, unsigned char*) () #11 0x00007fff8f2f818f in MenuSelectCore(MenuData*, Point, double, unsigned int, OpaqueMenuRef**, unsigned short*) () #12 0x00007fff8f2f780e in _HandleMenuSelection2 () #13 0x00007fff888e44ce in _NSHandleCarbonMenuEvent () #14 0x00007fff88879941 in _DPSNextEvent () #15 0x00007fff88878cf5 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] () #16 0x00007fff8887562d in -[NSApplication run] () #17 0x00007fff88af480c in NSApplicationMain () #18 0x00000001000015d2 in main at /Volumes/Corrino/matt/Projects/smartfish/TestGCD/TestGCD/main.m:13 Notes: Uncommenting the line to change the concurrent queue to use a low priority queue works around the problem but it seems like NSXPCConnection should be using a higher priority queue itself.
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!
Since I can't upload the test project here I'll link to a gist of the main file:
https://gist.github.com/7a8cf0da4b7e6a84c70b
The project was a standard Cocoa template app.