Monday, April 3, 2017 [Tweets] [Favorites]

Beware Default QoS

Apple:

A quality of service (QoS) class allows you to categorize work to be performed by NSOperation, NSOperationQueue, NSThread objects, dispatch queues, and pthreads (POSIX threads). By assigning a QoS to work, you indicate its importance, and the system prioritizes it and schedules it accordingly. For example, the system performs work initiated by a user sooner than background work that can be deferred until a more optimal time. In some cases, system resources may be reallocated away from the lower priority work and given to the higher priority work.

[…]

On iPhones, discretionary and background operations, including networking, are paused when Low Power Mode is enabled.

Drew McCormack:

Defaults for QoS can lead to nasty bugs. A lot of my ‘sync not working’ issues were due to ops not executing in low power mode.

If you have tasks using NSOperation or dispatch, and they seem to stop working in low power mode, that could be it.

Making QoS default to no-ops for low resources seems crazy to me. Apps just break. That should never be a default. Should have been opt in.

1 Comment

Steve Harris

CloudKit gets some very interesting timeouts at the default level too. It's only "documented" in one of the WWDC videos, but I think they said the default timeout is something like 7 days, which is probably not what anyone would expect.

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment