> On 2 May 2015, at 2:42 am, Kyle Sluder <k...@ksluder.com> wrote:
> 
>> Well that’s an interesting result - creating my own NSOperation with a
>> QoS of NSOperationQualityOfServiceBackground and adding it to my queue
>> produces a perfectly smooth and non-blocking app. If I use
>> -addOperationWithBlock: things are screwed up.
> 
> Please file a radar!
> 
> --Kyle Sluder


Radar: #20789132


I attached a simple demo app that reproduces the issue: 
http://apptree.net/code/NSOperationQueueBug.zip


Radar report:

Summary:
NSOperationQueue and related (NSOperation) documentation claims that its 
default Quality Of Service (QoS) should be set to 
NSOperationQualityOfServiceBackground. However, it ends up set much higher, 
which under some circumstances can cause the main thread to become blocked and 
unresponsive for potentially long periods. The user will experience this as a 
hang. The problem is especially acute if the work performed by the operation is 
lengthy and CPU intensive.

Steps to Reproduce:
The attached demo code quickly displays this problem. It can be opened and 
compiled in XCode.

1. Uncheck "demonstrate bug" and click "Run Tasks". A number of CPU-intensive 
tasks are added to an operation queue. These take many seconds to complete, but 
while they are executing, the main thread runs normally. This can be verified 
by clicking and dragging in the menubar to show the menus, and also observing 
the spinning busy indicator.

2. Check "demonstrate bug" and click 'Run Tasks". The same tasks are run, but 
this time with the default setting of NSOperationQueue and NSBlockOperation for 
the QoS property. Click in the menubar and the main thread will block until the 
tasks complete. Observe also that the spinning indicator does not animate as 
its thread never gets scheduled.

Expected Results:
According to documentation, the default QoS property for NSOperationQueue and 
NSOperation is NSOperationQualityOfServiceBackground. This should give the main 
thread and other threads time even if the operations are CPU intensive. The 
documentation goes on to say that developers should not usually change the 
default QoS setting from this value.

Actual Results:
In reality, the default setting for QoS ends up as such a high priority that no 
other threads, including the main thread, can get time and can end up blocked.

Version:
10.10.3

Notes:
A workaround is to deliberately set the QoS to 
NSOperationQualityOfServiceBackground rather than leave it at the default 
value. However, this is at odds with current documentation and expectations.

Configuration:
This was observed on 3.2 GHz Intel Core i3 CPU (iMac mid 2010 model) but was 
also verified by other developers on various current models.

Attachments:
'NSOperationQueueBug.zip' was successfully uploaded.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to